Sites
This commit is contained in:
parent
bd16f01192
commit
6422ffb13c
13 changed files with 142 additions and 5 deletions
9
scripts/multiplayer/plant_site/plant_deadzone.gd
Normal file
9
scripts/multiplayer/plant_site/plant_deadzone.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
extends Area3D
|
||||
|
||||
@export var bound_plant: Area3D
|
||||
|
||||
func _ready() -> void:
|
||||
if multiplayer.is_server():
|
||||
Session.plant_deadzones[bound_plant.name] = self
|
||||
else:
|
||||
queue_free()
|
||||
1
scripts/multiplayer/plant_site/plant_deadzone.gd.uid
Normal file
1
scripts/multiplayer/plant_site/plant_deadzone.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b4cpux52fmx5o
|
||||
23
scripts/multiplayer/plant_site/plant_site.gd
Normal file
23
scripts/multiplayer/plant_site/plant_site.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends Area3D
|
||||
|
||||
class_name PlantSite
|
||||
|
||||
var players_on_site: Array[int]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
body_entered.connect(on_body_entered)
|
||||
body_exited.connect(on_body_exited)
|
||||
|
||||
Session.plants.append(self)
|
||||
|
||||
func on_body_entered(body: Node3D):
|
||||
if body is Player:
|
||||
players_on_site.append(int(body.name))
|
||||
|
||||
func on_body_exited(body: Node3D):
|
||||
if body is Player:
|
||||
players_on_site.erase(int(body.name))
|
||||
|
||||
func is_player_on_site(id: int):
|
||||
return players_on_site.has(id)
|
||||
1
scripts/multiplayer/plant_site/plant_site.gd.uid
Normal file
1
scripts/multiplayer/plant_site/plant_site.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dk1gjbuydemmb
|
||||
|
|
@ -12,6 +12,8 @@ const DEFENCE_LAYER: int = 0b100000
|
|||
var player_nodes: Dictionary[int,Player] = {}
|
||||
|
||||
var dynamic_objects_spawner: MultiplayerSpawner
|
||||
var plants: Array[PlantSite]
|
||||
var plant_deadzones: Dictionary[StringName, Area3D]
|
||||
|
||||
## Spawns dynamic object at game scene [br]
|
||||
## Dictionary keys: [br]
|
||||
|
|
@ -76,4 +78,23 @@ func shoot_internal(id:int , damage: int) -> void:
|
|||
var collision = space.intersect_ray(ray)
|
||||
if collision != {} and collision["collider"] is Player:
|
||||
collision["collider"].take_damage.rpc_id(int(collision["collider"].name),damage)
|
||||
|
||||
|
||||
func is_on_site() -> bool:
|
||||
for plant in plants:
|
||||
if plant.is_player_on_site(multiplayer.get_unique_id()):
|
||||
return true
|
||||
return false
|
||||
|
||||
func get_site() -> PlantSite:
|
||||
for plant in plants:
|
||||
if plant.is_player_on_site(multiplayer.get_unique_id()):
|
||||
return plant
|
||||
return null
|
||||
|
||||
func kill_site(site: StringName) -> void:
|
||||
if multiplayer.is_server() == false:
|
||||
return
|
||||
|
||||
for body in plant_deadzones[site].get_overlapping_bodies():
|
||||
if body is Player:
|
||||
body.die()
|
||||
|
|
|
|||
|
|
@ -15,5 +15,10 @@ func request_spawn(data: Variant) -> Node:
|
|||
node.slot = data.slot
|
||||
|
||||
node.apply_impulse(data.impulse)
|
||||
|
||||
for key in data.keys():
|
||||
if key in ["scene","ammo","remaining_ammo","slot","position","rotation"]:
|
||||
continue
|
||||
node.set(key,data[key])
|
||||
return node
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue