Fix update_visibility in PlayerGDBase. Also fix spawn_for in the entity spawner.

This commit is contained in:
Relintai 2021-08-29 23:32:54 +02:00
parent 3dd4f4592a
commit f8803b99ab
3 changed files with 19 additions and 10 deletions

View File

@ -820,4 +820,5 @@ func teleport(teleport_to : Vector3):
placed = false
# just_place = true
func get_entity() -> Entity:
return entity

View File

@ -59,10 +59,17 @@ func update_visibility() -> void:
for collision in res:
var collider = collision["collider"]
if collider is Entity and not currenty_sees.has(collider):
currenty_sees.append(collider)
if !collider.has_method("get_entity"):
continue
var entity : Entity = collider.get_entity()
if !entity:
continue
if !currenty_sees.has(entity):
currenty_sees.append(entity)
#warning-ignore:unassigned_variable
var used_to_see : Array = Array()
@ -70,8 +77,7 @@ func update_visibility() -> void:
var ent : Entity = sees_gets(i)
used_to_see.append(ent)
#warning-ignore:unassigned_variable
var currenty_sees_filtered : Array = Array()
@ -86,7 +92,7 @@ func update_visibility() -> void:
for e in used_to_see:
var ent : Entity = e as Entity
if self.get_network_master() != 1:
if get_network_master() != 1:
ESS.entity_spawner.despawn_for(self, ent)
sees_removes(ent)
@ -94,7 +100,7 @@ func update_visibility() -> void:
for e in currenty_sees_filtered:
var ent : Entity = e as Entity
if self.get_network_master() != 1:
if get_network_master() != 1:
ESS.entity_spawner.spawn_for(self, ent)
sees_adds(ent)

View File

@ -52,10 +52,12 @@ func on_network_peer_packet(id : int, packet : PoolByteArray) ->void:
func spawn_for(player : Entity, target: Entity) -> void:
Logger.info("spawnfor " + target.name)
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.translation)
print("spawnfor " + target.name)
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.get_transform_3d())
func despawn_for(player : Entity, target: Entity) -> void:
Logger.info("despawnfor " + target.name)
print("despawnfor " + target.name)
rpc_id(player.get_network_master(), "creceive_despawn_for", target.get_path())
remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity: