mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-14 16:04:50 +00:00
👽 interstellar delivery
This commit is contained in:
parent
547c97bfba
commit
97c8292858
257 changed files with 7309 additions and 4637 deletions
|
|
@ -14,37 +14,45 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name Flag extends RigidBody3D
|
||||
|
||||
signal grabbed(grabber : Player)
|
||||
signal regrabbed(grabber : Player)
|
||||
signal dropped(dropper : Player)
|
||||
signal grabbed(carry: FlagCarryComponent)
|
||||
signal dropped(carry: FlagCarryComponent)
|
||||
|
||||
enum FlagState { ON_STAND, DROPPED, TAKEN }
|
||||
enum FlagState {
|
||||
ON_STAND,
|
||||
DROPPED,
|
||||
TAKEN
|
||||
}
|
||||
|
||||
@export var state : FlagState = FlagState.ON_STAND
|
||||
|
||||
@onready var area : Area3D = $GripArea3D
|
||||
@onready var mesh : Node3D = $Mesh
|
||||
|
||||
var last_carrier : Player = null
|
||||
var last_carrier : FlagCarryComponent
|
||||
|
||||
func _ready() -> void:
|
||||
area.body_entered.connect(_on_body_entered)
|
||||
|
||||
func _on_grabbed(grabber : Player) -> void:
|
||||
if state != FlagState.TAKEN:
|
||||
hide()
|
||||
state = FlagState.TAKEN
|
||||
if (last_carrier == null) or (grabber != last_carrier):
|
||||
last_carrier = grabber
|
||||
else:
|
||||
regrabbed.emit(grabber)
|
||||
|
||||
func _on_dropped(_dropper : Player) -> void:
|
||||
if state == FlagState.TAKEN:
|
||||
show()
|
||||
state = FlagState.DROPPED
|
||||
grabbed.connect(_on_grabbed)
|
||||
dropped.connect(_on_dropped)
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
if body is Player:
|
||||
assert(body.flag_carry_component)
|
||||
body.flag_carry_component.grab(self)
|
||||
if state < FlagState.TAKEN:
|
||||
body.flag_carry_component.grab(self)
|
||||
hide()
|
||||
|
||||
func _on_grabbed(_carry: FlagCarryComponent) -> void:
|
||||
assert(state < FlagState.TAKEN)
|
||||
hide()
|
||||
state = FlagState.TAKEN
|
||||
sleeping = true
|
||||
area.set_deferred("monitoring", false)
|
||||
|
||||
func _on_dropped(carry: FlagCarryComponent) -> void:
|
||||
assert(state == FlagState.TAKEN)
|
||||
sleeping = false
|
||||
area.set_deferred("monitoring", true)
|
||||
state = FlagState.DROPPED
|
||||
last_carrier = carry
|
||||
show()
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ properties/2/replication_mode = 2
|
|||
properties/3/path = NodePath(".:state")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
properties/4/path = NodePath(".:sleeping")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 2
|
||||
|
||||
[node name="Flag" type="RigidBody3D"]
|
||||
collision_layer = 8
|
||||
|
|
@ -55,6 +58,3 @@ foreground_color = Color(0, 0.75, 0.75, 1)
|
|||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_lpijf")
|
||||
|
||||
[connection signal="dropped" from="." to="." method="_on_dropped"]
|
||||
[connection signal="grabbed" from="." to="." method="_on_grabbed"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue