Refactor Part II
This commit is contained in:
parent
cd20f952ce
commit
3f99f1b8dd
56 changed files with 193 additions and 168 deletions
|
|
@ -1,5 +1,4 @@
|
|||
extends Label
|
||||
|
||||
|
||||
func on_ammo_updated(ammo: int, remaining_ammo: int):
|
||||
text = str(ammo)+"/"+str(remaining_ammo)
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ script = ExtResource("11_02ic3")
|
|||
exlusion_list = [NodePath("MultiplayerSpawner"), NodePath("Bomb"), NodePath("Parenter")]
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="DynamicObjectsContainer"]
|
||||
_spawnable_scenes = PackedStringArray("uid://cxdgk74ln5xpn", "uid://l4t1mflutm3t", "uid://b6qahd6q60js7")
|
||||
_spawnable_scenes = PackedStringArray("uid://cxdgk74ln5xpn", "uid://dtbpyfdawb02b", "uid://dgfqppi21c2u0", "uid://b6qahd6q60js7", "uid://l4t1mflutm3t")
|
||||
spawn_path = NodePath("..")
|
||||
|
||||
[node name="Parenter" type="Node" parent="DynamicObjectsContainer"]
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func spawn():
|
|||
spawn_spectator(specator)
|
||||
|
||||
func spawn_player(id: int) -> void:
|
||||
var player: PackedScene = load("res://scenes/molikman.tscn")
|
||||
var player: PackedScene = preload("uid://dpsr6ug3pkb40")
|
||||
var inst: Player = player.instantiate()
|
||||
Session.player_nodes[id] = inst
|
||||
inst.name = str(id)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,5 @@
|
|||
extends Area3D
|
||||
|
||||
@export var weapon_spawner: MultiplayerSpawner
|
||||
@export var weapon_system: WeaponSystem
|
||||
var disabled: bool
|
||||
|
||||
|
|
@ -18,12 +17,8 @@ func on_body_entered(body: Node3D):
|
|||
if body is DroppableWeapon:
|
||||
if weapon_system.can_add(body.slot) == false or (body.team != Session.TEAMS.UNASSIGNED and get_parent().team != body.team):
|
||||
return
|
||||
weapon_spawner.spawn({
|
||||
"ammo": body.weapon.ammo,
|
||||
"remaining_ammo": body.weapon.remaining_ammo,
|
||||
"scene_file_path": body.weapon.scene_file_path,
|
||||
"slot": body.slot
|
||||
})
|
||||
var weapon: WeaponSubStateMachine = body.weapon.duplicate()
|
||||
weapon_system.add(weapon,weapon.slot)
|
||||
|
||||
body.queue_free()
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ckjabjcvgki6n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://systems/player/spectator.gd" id="1_jjbhc"]
|
||||
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://spectator.gd" id="1_jjbhc"]
|
||||
|
||||
[node name="Spectator" type="Camera3D"]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||
5
players/weapon_spawner.tscn
Normal file
5
players/weapon_spawner.tscn
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[gd_scene format=3 uid="uid://eaali3lbode2"]
|
||||
|
||||
[node name="WeaponSpawner" type="MultiplayerSpawner"]
|
||||
_spawnable_scenes = PackedStringArray("uid://djwjl8xll53vn", "uid://ts4xccpkjd3g", "uid://bxdatd1ilfgmc", "uid://c5q7e5dj86187")
|
||||
spawn_path = NodePath("..")
|
||||
|
|
@ -20,7 +20,7 @@ config/icon="res://icon.svg"
|
|||
|
||||
[autoload]
|
||||
|
||||
PlayerGlobal="*res://systems/player/player_global.gd"
|
||||
PlayerGlobal="*res://players/player/player_global.gd"
|
||||
Lobby="*res://multiplayer/lobby.gd"
|
||||
Session="*res://multiplayer/session.gd"
|
||||
ClientSettings="*res://gui/client_settings/client_settings.gd"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
extends Node
|
||||
|
||||
@export var starting_pistol: StringName
|
||||
@export var starting_knife: StringName
|
||||
@export var weapon_spawner: MultiplayerSpawner
|
||||
@export var starting_pistol: PackedScene
|
||||
@export var starting_knife: PackedScene
|
||||
@export var weapon_system: WeaponSystem
|
||||
|
||||
func _ready() -> void:
|
||||
deferred_ready.call_deferred()
|
||||
|
||||
func deferred_ready() -> void:
|
||||
if is_multiplayer_authority():
|
||||
weapon_spawner.spawn({"scene_file_path": starting_pistol})
|
||||
weapon_spawner.spawn({"scene_file_path": starting_knife})
|
||||
weapon_system.add(starting_pistol.instantiate(),"secondary")
|
||||
weapon_system.add(starting_knife.instantiate(),"knife")
|
||||
queue_free()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class_name WeaponSubStateMachine
|
|||
remaining_ammo = 0
|
||||
else:
|
||||
remaining_ammo = value
|
||||
ammo_updated.emit()
|
||||
|
||||
@export var speed_modifier: float = 1.0
|
||||
@export var can_be_previous: bool = true
|
||||
|
|
@ -53,6 +54,16 @@ func _ready() -> void:
|
|||
child.transition.connect(on_transition_required)
|
||||
child.return_to_previous.connect(request_return.emit)
|
||||
|
||||
var parent = get_parent()
|
||||
if parent is WeaponSystem:
|
||||
system = parent
|
||||
animation_player = system.animation_player
|
||||
player_camera = system.camera
|
||||
player = system.player
|
||||
request_return.connect(system.return_to_previous)
|
||||
ammo_depleted.connect(system.check_for_empty)
|
||||
ammo_updated.connect(system.on_ammo_updated)
|
||||
|
||||
func enter() -> void:
|
||||
super()
|
||||
player.weapon_models[visibility_target].show()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ signal slots_updated(slots: Dictionary[StringName,WeaponSubStateMachine])
|
|||
signal ammo_updated(ammo: int, remaining_ammo: int)
|
||||
|
||||
func _ready() -> void:
|
||||
$WeaponSpawner.spawn_function = pick_up_weapon
|
||||
player_input.drop.connect(drop_current)
|
||||
player_input.fire_begin.connect(use_begin)
|
||||
player_input.fire_end.connect(use_end)
|
||||
|
|
@ -43,27 +42,15 @@ func get_speed_modifier() -> float:
|
|||
func can_add(slot: StringName) -> bool:
|
||||
return slots.has(slot) and slots[slot] == null
|
||||
|
||||
@rpc("call_local","reliable")
|
||||
func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = false) -> void:
|
||||
func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
if can_add(slot) == false:
|
||||
return
|
||||
|
||||
if ignore_parent == false:
|
||||
if state.get_parent() == null:
|
||||
add_child(state, true)
|
||||
if state.get_parent() != self:
|
||||
state.get_parent().remove_child(state)
|
||||
add_child(state,true)
|
||||
state.ready.emit()
|
||||
|
||||
slots[slot] = state
|
||||
state.system = self
|
||||
state.animation_player = animation_player
|
||||
state.player_camera = camera
|
||||
state.player = player
|
||||
state.request_return.connect(return_to_previous)
|
||||
state.ammo_depleted.connect(check_for_empty)
|
||||
state.ammo_updated.connect(on_ammo_updated)
|
||||
slots_updated.emit(slots)
|
||||
|
||||
if current_state == null:
|
||||
|
|
@ -71,6 +58,17 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
|
|||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
state.enter.call_deferred()
|
||||
|
||||
|
||||
func process_spawned_weapon(weapon_node: Node):
|
||||
var weapon = weapon_node as WeaponSubStateMachine
|
||||
|
||||
slots[weapon.slot] = weapon
|
||||
slots_updated.emit(slots)
|
||||
|
||||
if current_state == null:
|
||||
current_state = weapon
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
|
||||
func get_empty_ability_slot() -> StringName:
|
||||
if slots["ability_first"] == null:
|
||||
return "ability_first"
|
||||
|
|
@ -133,32 +131,6 @@ func drop_slot(slot: StringName):
|
|||
return
|
||||
drop(slots[slot])
|
||||
|
||||
# Spawn function
|
||||
# Data should be a dictionary with these keys:
|
||||
# ammo
|
||||
# remaining_ammo
|
||||
# scene_file_path
|
||||
func pick_up_weapon(data: Variant) -> Node:
|
||||
if data.has("scene_file_path") == false:
|
||||
return Node.new()
|
||||
if data.has_all(["ammo","remaining_ammo"]):
|
||||
var scene: WeaponSubStateMachine = load(data["scene_file_path"]).instantiate()
|
||||
scene.ammo = data["ammo"]
|
||||
scene.remaining_ammo = data["remaining_ammo"]
|
||||
scene.slot = data["slot"]
|
||||
scene.set_multiplayer_authority(get_multiplayer_authority())
|
||||
|
||||
add(scene,scene.slot,true)
|
||||
|
||||
return scene
|
||||
else:
|
||||
var scene: WeaponSubStateMachine = load(data["scene_file_path"]).instantiate()
|
||||
scene.set_multiplayer_authority(get_multiplayer_authority())
|
||||
|
||||
add(scene,scene.slot,true)
|
||||
|
||||
return scene
|
||||
|
||||
func check_for_empty() -> void:
|
||||
if is_multiplayer_authority() == false:
|
||||
return
|
||||
|
|
@ -167,6 +139,7 @@ func check_for_empty() -> void:
|
|||
child.queue_free()
|
||||
|
||||
func on_ammo_updated() -> void:
|
||||
if current_state != null:
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
|
||||
func disable() -> void:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bxdatd1ilfgmc"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bxdatd1ilfgmc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_krsgt"]
|
||||
[ext_resource type="Script" uid="uid://rx78vdadldm7" path="res://weapons/bomb/bomb_main_state.gd" id="2_870cc"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtbpyfdawb02b" path="res://weapons/bomb/active_bomb.tscn" id="2_j5dxu"]
|
||||
[ext_resource type="Script" uid="uid://cx7j3kr1laq3s" path="res://weapons/bomb/bomb_idle_state.gd" id="3_1x0so"]
|
||||
[ext_resource type="Script" uid="uid://dmyir46aricwi" path="res://weapons/bomb/bomb_intro_state.gd" id="4_fv3ha"]
|
||||
[ext_resource type="Script" uid="uid://b5eapvgoni1pj" path="res://weapons/bomb/bomb_dropper.gd" id="5_fv3ha"]
|
||||
|
|
@ -21,6 +22,7 @@ metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
|||
|
||||
[node name="Plant" type="Node" parent="."]
|
||||
script = ExtResource("2_870cc")
|
||||
bomb_scene = ExtResource("2_j5dxu")
|
||||
|
||||
[node name="Idle" type="Node" parent="."]
|
||||
script = ExtResource("3_1x0so")
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ func exit() -> void:
|
|||
func on_animation_finished(animation):
|
||||
if animation == with_morphems("reload"):
|
||||
if machine.remaining_ammo > machine.max_ammo:
|
||||
machine.remaining_ammo -= machine.max_ammo-machine.ammo
|
||||
machine.ammo = machine.max_ammo
|
||||
machine.remaining_ammo -= machine.max_ammo
|
||||
else:
|
||||
machine.ammo = machine.remaining_ammo
|
||||
machine.remaining_ammo = 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://djwjl8xll53vn"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://djwjl8xll53vn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_g7s1i"]
|
||||
[ext_resource type="Script" uid="uid://ofv4e3dsfe8" path="res://weapons/gun/idle_state.gd" id="2_cmn6f"]
|
||||
|
|
@ -18,6 +18,14 @@ _limits = [-0.02, 0.02, 0.0, 20.0]
|
|||
_data = [Vector2(0, -9.313226e-10), 0.0, 0.0, 0, 0, Vector2(4.959569, 0.0044327714), 0.0, 0.0, 0, 0, Vector2(9.919138, -0.0075840354), 0.0, 0.0, 0, 0, Vector2(15.09434, 0.011533612), 0.0, 0.0, 0, 0, Vector2(20, -0.014684878), 0.0, 0.0, 0, 0]
|
||||
point_count = 5
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_bwg3m"]
|
||||
properties/0/path = NodePath(".:ammo")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 2
|
||||
properties/1/path = NodePath(".:remaining_ammo")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 2
|
||||
|
||||
[node name="StartingPistol" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||
script = ExtResource("1_g7s1i")
|
||||
animation_prefix = &"baked_sp_"
|
||||
|
|
@ -52,3 +60,6 @@ emptyable = true
|
|||
[node name="FireTimer" type="Timer" parent="."]
|
||||
wait_time = 0.15
|
||||
one_shot = true
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_bwg3m")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var contacts: int = 0
|
|||
func _on_body_entered(_body: Node) -> void:
|
||||
contacts += 1
|
||||
if contacts > 2:
|
||||
var grenade = load("res://scenes/projectiles/molikman/molikman_molotov_fire.tscn").instantiate()
|
||||
Session.dynamic_objects_parent.add_child(grenade,true)
|
||||
grenade.global_position = global_position
|
||||
var fire = preload("uid://l4t1mflutm3t").instantiate()
|
||||
Session.dynamic_objects_parent.add_child(fire,true)
|
||||
fire.global_position = global_position
|
||||
queue_free()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://b6qahd6q60js7"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://b6qahd6q60js7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://y1s64ppporww" path="res://weapons/molikman/molik/molik.gd" id="1_aqokr"]
|
||||
|
||||
|
|
@ -12,6 +12,11 @@ height = 0.1
|
|||
[sub_resource type="SphereShape3D" id="SphereShape3D_aqokr"]
|
||||
radius = 0.05
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_6ic6f"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
|
||||
[node name="Molik" type="RigidBody3D"]
|
||||
collision_layer = 8
|
||||
physics_material_override = SubResource("PhysicsMaterial_aqokr")
|
||||
|
|
@ -27,4 +32,7 @@ mesh = SubResource("SphereMesh_fwcyt")
|
|||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_aqokr")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_6ic6f")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
|
@ -1,10 +1,18 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://c5q7e5dj86187"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://c5q7e5dj86187"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_e53aq"]
|
||||
[ext_resource type="Script" uid="uid://js2rkse5mka0" path="res://weapons/molikman/molik/intro_state.gd" id="2_8q75j"]
|
||||
[ext_resource type="Script" uid="uid://cnre3f01a2n88" path="res://weapons/molikman/molik/idle_state.gd" id="3_p1i4u"]
|
||||
[ext_resource type="Script" uid="uid://b6eio68csxw7v" path="res://weapons/molikman/molik/throw.gd" id="4_1la3w"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_i1uig"]
|
||||
properties/0/path = NodePath(".:ammo")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:remaining_ammo")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
|
||||
[node name="MolikmanMolik" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||
script = ExtResource("1_e53aq")
|
||||
animation_prefix = &"baked_sp_"
|
||||
|
|
@ -22,3 +30,6 @@ script = ExtResource("3_p1i4u")
|
|||
|
||||
[node name="Throw" type="Node" parent="."]
|
||||
script = ExtResource("4_1la3w")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_i1uig")
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://l4t1mflutm3t"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://l4t1mflutm3t"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bmnqvop2dy5pm" path="res://textures/prototype_yellow_256x256.png" id="1_hr7p8"]
|
||||
[ext_resource type="Script" uid="uid://bo0ij4miuksua" path="res://scenes/projectiles/molikman/molikman_molotov_fire.gd" id="1_qokq0"]
|
||||
[ext_resource type="Script" uid="uid://bo0ij4miuksua" path="res://weapons/molikman/molik/molikman_molotov_fire.gd" id="1_qokq0"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8aqstr5es5x4" path="res://textures/prototype_orange_256x256.png" id="2_qokq0"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_hr7p8"]
|
||||
|
|
@ -33,6 +33,11 @@ color_ramp = SubResource("GradientTexture1D_qokq0")
|
|||
material = SubResource("StandardMaterial3D_qokq0")
|
||||
text = "fire"
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ykxjp"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
|
||||
[node name="MolikmanMolotovFire" type="Area3D" node_paths=PackedStringArray("damage_timer")]
|
||||
collision_layer = 8
|
||||
collision_mask = 2
|
||||
|
|
@ -65,5 +70,8 @@ autostart = true
|
|||
wait_time = 0.25
|
||||
autostart = true
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_ykxjp")
|
||||
|
||||
[connection signal="timeout" from="DieTimer" to="." method="queue_free"]
|
||||
[connection signal="timeout" from="DamageTimer" to="." method="damage"]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
extends WeaponState
|
||||
|
||||
const molik: PackedScene = preload("res://scenes/weapons/molik.tscn")
|
||||
const molik: PackedScene = preload("uid://b6qahd6q60js7")
|
||||
|
||||
func enter() -> void:
|
||||
fire()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="Texture2D" uid="uid://bmnqvop2dy5pm" path="res://textures/prototype_yellow_256x256.png" id="1_hmyxe"]
|
||||
[ext_resource type="Script" uid="uid://bvnn2eiwqbu7t" path="res://systems/weapon_system/weapon_resource.gd" id="1_ktfgd"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5q7e5dj86187" path="res://scenes/weapons/molikman_molik.tscn" id="3_6mu31"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5q7e5dj86187" path="res://weapons/molikman/molik/molikman_molik.tscn" id="3_6mu31"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ktfgd")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue