Spawnables
This commit is contained in:
parent
6b5e768faf
commit
ea4f70f5ef
25 changed files with 4784 additions and 4436 deletions
|
|
@ -5,20 +5,40 @@ func _ready() -> void:
|
|||
Session.dynamic_objects_spawner = self
|
||||
|
||||
func request_spawn(data: Variant) -> Node:
|
||||
if data.has("scene") == false:
|
||||
if is_multiplayer_authority() == false: return
|
||||
if data.has("type") == false or data.has("spawn_name") == false:
|
||||
return Node.new()
|
||||
var node = load(data.scene).instantiate()
|
||||
if data.has("impulse"):
|
||||
if data.has_all(["ammo","remaining_ammo","slot"]):
|
||||
node.weapon.ammo = data.ammo
|
||||
node.weapon.remaining_ammo = data.remaining_ammo
|
||||
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
|
||||
match data.type:
|
||||
"weapon":
|
||||
var weapon: DroppableWeapon = Registry.weapons[data.spawn_name].dropped_scene.instantiate()
|
||||
weapon.apply_central_impulse(data.impulse)
|
||||
weapon.weapon.ammo = data.ammo
|
||||
weapon.weapon.remaining_ammo = data.remaining_ammo
|
||||
weapon.slot = Registry.weapons[data.spawn_name].slot
|
||||
|
||||
for key in data.keys():
|
||||
if key == "impulse" or key == "ammo" or key == "remaining_ammo":
|
||||
continue
|
||||
weapon.set(key,data[key])
|
||||
|
||||
return weapon
|
||||
"projectile":
|
||||
var projectile: RigidBody3D = Registry.spawnable_objects[data.spawn_name].instantiate()
|
||||
projectile.apply_central_impulse(data.impulse)
|
||||
|
||||
for key in data.keys():
|
||||
if key == "impulse":
|
||||
continue
|
||||
projectile.set(key,data[key])
|
||||
|
||||
return projectile
|
||||
"object":
|
||||
var object: Node3D = Registry.spawnable_objects[data.spawn_name].instantiate()
|
||||
|
||||
for key in data.keys():
|
||||
object.set(key,data[key])
|
||||
|
||||
return object
|
||||
_:
|
||||
return Node.new()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue