feat: implement multiplayer network manager and player movement controller with base game entities and UI

This commit is contained in:
DottsGit
2026-06-06 14:03:57 -04:00
parent 168bd8f1ce
commit 9adbff3968
6 changed files with 120 additions and 24 deletions
+21 -1
View File
@@ -11,6 +11,7 @@ var max_shield: float = 100.0
var shield: float = 100.0
var is_dead: bool = false
var recent_attackers: Dictionary = {} # attacker_id: timestamp
var ragdoll_instance: Node3D = null
var pending_impulse: Vector3 = Vector3.ZERO
@@ -85,6 +86,18 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null) -> v
if is_dead:
return
var attacker_id = 0
if source:
if source.has_method("get_multiplayer_authority"):
attacker_id = source.get_multiplayer_authority()
elif "owner_player" in source and source.owner_player:
attacker_id = int(str(source.owner_player.name))
elif source is CharacterBody3D:
attacker_id = int(str(source.name))
if attacker_id != 0:
recent_attackers[attacker_id] = Time.get_ticks_msec() / 1000.0
var dmg_taken = amount
if shield > 0:
if shield >= amount:
@@ -119,7 +132,14 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null) -> v
if source.has_method("get_weapon_name"):
weapon_name = source.get_weapon_name()
nm.register_kill.rpc(-1, killer_id, weapon_name, "Walking Dummy")
var assist_ids: Array = []
var now = Time.get_ticks_msec() / 1000.0
for aid in recent_attackers.keys():
if now - recent_attackers[aid] <= 10.0:
assist_ids.append(aid)
nm.register_kill.rpc(-1, killer_id, weapon_name, "Walking Dummy", assist_ids)
else:
_wiggle()