Updated entity's body related methods.

This commit is contained in:
Relintai 2023-10-08 20:32:04 +02:00
parent 740e7520f9
commit e0f8afc75a
13 changed files with 37 additions and 37 deletions

View File

@ -44,7 +44,7 @@ enum CharacterFacing {
# sprite = get_node(sprite_path) as Sprite
func _enter_tree():
sprite = get_node("/root/Main").get_body().instance()
sprite = get_node("/root/Main").body_get().instance()
add_child(sprite)
func update_facing(input_direction : Vector2) -> void:

View File

@ -319,7 +319,7 @@ func move_towards_target():
if !t:
return
var bp : Vector2 = t.get_body().get_tile_position()
var bp : Vector2 = t.body_get().get_tile_position()
var my_point = world.nav_graph.get_closest_point(get_tile_position())
var target_point = world.nav_graph.get_closest_point(bp)
@ -334,7 +334,7 @@ func move_towards_target():
return
for e in world.enemies:
if e.get_body().get_tile_position() == move_tile:
if e.body_get().get_tile_position() == move_tile:
return
set_tile_position(move_tile)
@ -352,7 +352,7 @@ func target(position : Vector2, keep_target : bool = false) -> bool:
var enemy : Entity = world.get_enemy_at_tile(pos.x, pos.y)
if enemy:
if !enemy.get_body().visible:
if !enemy.body_get().visible:
return false
if entity.target_getc() != enemy:
@ -371,7 +371,7 @@ func cmouseover(position : Vector2):
var enemy : Entity = world.get_enemy_at_tile(pos.x, pos.y)
if enemy:
if !enemy.get_body().visible:
if !enemy.body_get().visible:
return false
if last_mouse_over != null and last_mouse_over != entity:

View File

@ -80,7 +80,7 @@ func _ready() -> void:
_is_front_side = false
#func _enter_tree():
# var body = get_node("/root/Main").get_body().instance()
# var body = get_node("/root/Main").body_get().instance()
# add_child(body)

View File

@ -102,7 +102,7 @@ func _notification_sdeath():
func set_position(position : Vector3, rotation : Vector3) -> void:
get_body().set_position(position, rotation)
body_get().set_position(position, rotation)
func _notification_sdamage(what, info):
if what == SpellEnums.NOTIFICATION_DAMAGE_DAMAGE_DEALT:
@ -111,11 +111,11 @@ func _notification_sdamage(what, info):
func _notification_cdamage(what, info):
if what == SpellEnums.NOTIFICATION_DAMAGE_DAMAGE_DEALT:
WorldNumbers.damage(get_body().position, 46, info.damage, info.crit)
WorldNumbers.damage(body_get().position, 46, info.damage, info.crit)
func _notification_cheal(what, info):
if what == SpellEnums.NOTIFICATION_DAMAGE_DAMAGE_DEALT:
WorldNumbers.heal(get_body().position, 46, info.heal, info.crit)
WorldNumbers.heal(body_get().position, 46, info.heal, info.crit)
func _notification_sxp_gained(value : int) -> void:
if not ESS.can_character_level_up(slevel):

View File

@ -94,7 +94,7 @@ func _process(delta):
if (get_scale() - target_scale).length() < 0.04:
interpolating = false
var position : Vector2 = entity.get_body().position
var position : Vector2 = entity.body_get().position
position.x -= (rect_size.x / 2.0) * rect_scale.x
position.y -= offset

View File

@ -32,10 +32,10 @@ func _from_dict(dict):
#The world will propbably need to set these later
#func update_visibility() -> void:
# _query.collision_layer = get_body().get_collision_layer()
# _query.collision_layer = body_get().get_collision_layer()
#
# _query.transform = Transform2D(0, get_body().position)
# var res : Array = get_body().get_world_2d().direct_space_state.intersect_shape(_query)
# _query.transform = Transform2D(0, body_get().position)
# var res : Array = body_get().get_world_2d().direct_space_state.intersect_shape(_query)
#
# #warning-ignore:unassigned_variable
# var currenty_sees : Array = Array()
@ -88,5 +88,5 @@ func _from_dict(dict):
# if get_tree().is_network_server():
# rpc("set_position_remote", pos)
# #print(position)
# get_body().position = pos
# body_get().position = pos

View File

@ -25,10 +25,10 @@ extends Entity
#The world will need to set these
#func update_visibility() -> void:
# _query.collision_layer = get_body().get_collision_layer()
# _query.collision_layer = body_get().get_collision_layer()
#
# _query.transform = Transform2D(0, get_body().position)
# var res : Array = get_body().get_world_2d().direct_space_state.intersect_shape(_query)
# _query.transform = Transform2D(0, body_get().position)
# var res : Array = body_get().get_world_2d().direct_space_state.intersect_shape(_query)
#
# #warning-ignore:unassigned_variable
# var currenty_sees : Array = Array()
@ -81,5 +81,5 @@ extends Entity
# if get_tree().is_network_server():
# rpc("set_position_remote", pos)
# #print(position)
# get_body().position = pos
# body_get().position = pos

View File

@ -205,6 +205,6 @@ func character_selection_changed() -> void:
return
for e in player_display_container_node.get_children():
e.get_body().hide()
e.body_get().hide()
b.entity.get_body().show()
b.entity.body_get().show()

View File

@ -73,7 +73,7 @@ func place_player(player: Entity) -> void:
if !generated:
build()
_player.get_body().transform = entrance_position
_player.body_get().transform = entrance_position
call_deferred("update_visibility")
@ -98,7 +98,7 @@ func build():
var blocked = false
for enemy in enemies:
var body = enemy.get_body()
var body = enemy.body_get()
var bp = body.get_tile_position()
if bp.x == x && bp.y == y:
blocked = true
@ -132,7 +132,7 @@ func update_visibility():
if _player == null:
return
var body = _player.get_body()
var body = _player.body_get()
if body == null:
return
@ -155,7 +155,7 @@ func update_visibility():
# var test_rect : Rect2 = Rect2(tp, Vector2(10, 10))
for e in enemies:
var b = e.get_body()
var b = e.body_get()
if !b.visible:
var tpos : Vector2 = b.get_tile_position()
@ -205,7 +205,7 @@ func is_position_walkable(x : int, y : int) -> bool:
return false
for e in enemies:
var pos : Vector2 = e.get_body().get_tile_position()
var pos : Vector2 = e.body_get().get_tile_position()
if pos.x == x && pos.y == y:
return false
@ -213,7 +213,7 @@ func is_position_walkable(x : int, y : int) -> bool:
func get_enemy_at_tile(x : int, y : int) -> Entity:
for e in enemies:
var pos : Vector2 = e.get_body().get_tile_position()
var pos : Vector2 = e.body_get().get_tile_position()
if pos.x == x && pos.y == y:
return e
@ -490,14 +490,14 @@ func set_editor_generate(value : bool) -> void:
func on_visibility_changed():
if visible:
for e in discovered_enemies:
var b = e.get_body()
var b = e.body_get()
if b.visible:
b.set_visibility(true)
e.target_sets(_player)
else:
for e in discovered_enemies:
var b = e.get_body()
var b = e.body_get()
if b.visible:
b.set_visibility(false)

View File

@ -97,7 +97,7 @@ func get_world():
func get_world_scale():
return world_scale
func get_body():
func body_get():
return bodies[randi() % bodies.size()]
func get_tile_size():

View File

@ -26,7 +26,7 @@ func _unhandled_key_input(event):
switch_to_level(l)
func switch_to_level(level_index : int):
_player.get_body().hide()
_player.body_get().hide()
if current_level != -1:
levels[current_level].hide()
@ -41,14 +41,14 @@ func switch_to_level(level_index : int):
levels[current_level].add_child(_player)
levels[current_level].place_player(_player)
# _player.get_body().world = levels[current_level]
_player.get_body().show()
# _player.body_get().world = levels[current_level]
_player.body_get().show()
func load_character(file_name: String) -> void:
_player_file_name = file_name
_player = ESS.entity_spawner.load_player(_player_file_name, Vector3.ZERO, 1) as Entity
_player.get_body().hide()
_player.body_get().hide()
#Server.sset_seed(_player.sseed)
call_deferred("switch_to_level", 0)

View File

@ -122,11 +122,11 @@ func attack(delta):
if owner.cast_is_castings():
return
var dir : Vector2 = target.get_body().get_tile_position() - owner.get_body().get_tile_position()
var dir : Vector2 = target.body_get().get_tile_position() - owner.body_get().get_tile_position()
var l = dir.length()
if l > 1:
owner.get_body().move_towards_target()
owner.body_get().move_towards_target()
func sort_spells_by_rank(a, b):
if a == null or b == null:

View File

@ -57,8 +57,8 @@ func _cast_starts(info : SpellCastInfo) -> void:
if range_enabled:
if info.caster != info.target:
var c : Vector2 = info.caster.get_body().position
var t : Vector2 = info.target.get_body().position
var c : Vector2 = info.caster.body_get().position
var t : Vector2 = info.target.body_get().position
if (c - t).length() > range_range:
return