Renamed a bunch of player stuff to pawn stuff and implemented extensive work on getting single-address 'netplay' code working. Not sure if I've created issues with single player but in theory it should all transfer across as if the player is simply always the host.

This commit is contained in:
2026-01-08 07:15:20 -05:00
parent 9fe376e27e
commit ec02685065
69 changed files with 1525 additions and 708 deletions

View File

@@ -28,6 +28,7 @@ const trap_icons : Dictionary = {
const bomb_explosion_template = preload("res://templates/explosion.tscn")
const mine_explosion_template = preload("res://templates/explosion.tscn")
const pitfall_template = preload("res://templates/pitfall.tscn")
const switch_explosion_template = preload("res://templates/explosion.tscn")
const gas_emitter_template = preload("res://templates/gas_emitter.tscn")
const force_activate_sound = preload("res://audio/sounds/TomWinandySFX_UI_ScifiTech_Start_06.wav")
@@ -46,6 +47,7 @@ var square : Vector3i
var trap_owner : int
var direction : Vector3
var expended : bool = false
var disarming : bool
var disarm_id : int
@@ -55,6 +57,8 @@ var damage : int = 10
var just_revealed : bool = false
signal removed(type : Trap.Type)
signal disarmed(type : Trap.Type)
signal activated(type : Trap.Type)
@@ -66,6 +70,10 @@ func setup(type : Type, direction : Vector3, trap_owner : int) -> void:
var cardinal : float = roundi(r * 2 / PI) * PI / 2
self.direction = Vector3(cos(cardinal), 0, sin(cardinal))
func remove() -> void:
removed.emit(type)
queue_free()
func disarm() -> void:
disarmed.emit(type)
queue_free()
@@ -113,12 +121,20 @@ func _ready() -> void:
func _process(delta: float) -> void:
just_revealed = false
func blast(body : Player) -> void:
func blast(body : PawnController) -> void:
body.hurt(damage)
body.knockup((global_position.direction_to(body.global_position) + Vector3(0,2,0)) * 3)
func activate() -> void:
if expended:
return
var explode : bool = false
match(type):
Type.PITFALL:
generate_pitfall(square)
for body in get_overlapping_bodies():
body.start_pitfall(square, 6.0)
#Generate the circle here
Type.FORCE_PANEL:
Game.oneshot(force_activate_sound)
for body in get_overlapping_bodies():
@@ -146,15 +162,21 @@ func activate() -> void:
trigger_adjacent_bombs()
blast_players()
expended = true
Game.level.remove_trap_square(square)
activated.emit(type)
queue_free()
func trigger_adjacent_bombs() -> void:
for trap : Trap in range_area.get_overlapping_areas():
if trap.type == Type.BOMB:
if trap.type == Type.BOMB and trap != self:
trap.delay_trigger()
func generate_pitfall(suqare : Vector3i) -> void:
var pitfall = pitfall_template.instantiate()
pitfall.duration = 6.0
Game.level.add_vfx(pitfall, square)
func blast_players() -> void:
for body in range_area.get_overlapping_bodies():
blast(body)
@@ -168,7 +190,7 @@ func delay_trigger() -> void:
func _on_body_entered(body: Node3D) -> void:
if type == Type.GAS:
if type == Type.GAS or type == Type.BOMB:
return
if body.id == trap_owner: