Compare commits
2 commits
b94e4cdf30
...
2c7903e95d
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c7903e95d | |||
| e2540d8417 |
4 changed files with 23 additions and 12 deletions
|
|
@ -271,15 +271,15 @@ func stop_interact() -> void:
|
||||||
var id = multiplayer.get_remote_sender_id()
|
var id = multiplayer.get_remote_sender_id()
|
||||||
player_stopped_interacting.emit(id)
|
player_stopped_interacting.emit(id)
|
||||||
|
|
||||||
func is_on_site() -> bool:
|
func is_on_site(id: int) -> bool:
|
||||||
for plant in plants:
|
for plant in plants:
|
||||||
if plant.is_player_on_site(multiplayer.get_unique_id()):
|
if plant.is_player_on_site(id):
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func get_site() -> PlantSite:
|
func get_site(id: int) -> PlantSite:
|
||||||
for plant in plants:
|
for plant in plants:
|
||||||
if plant.is_player_on_site(multiplayer.get_unique_id()):
|
if plant.is_player_on_site(id):
|
||||||
return plant
|
return plant
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ func enter() -> void:
|
||||||
func exit() -> void:
|
func exit() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func use_begin() -> void:
|
||||||
if event.is_action("plr_bomb") and Session.is_on_site():
|
if Session.is_on_site(machine.player.player_id):
|
||||||
transition.emit("Plant")
|
transition.emit("Plant")
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,13 @@ func on_animation_finished(animation: StringName):
|
||||||
return
|
return
|
||||||
if animation == machine.animation_prefix + "plant":
|
if animation == machine.animation_prefix + "plant":
|
||||||
|
|
||||||
Session.spawn({"scene": active_bomb, "position": machine.player_camera.get_parent().global_position,"plant": Session.get_site().name})
|
Session.spawn({"scene": active_bomb, "position": machine.player_camera.get_parent().global_position,"plant": Session.get_site(machine.player.player_id).name})
|
||||||
|
|
||||||
machine.ammo -= 1
|
machine.ammo -= 1
|
||||||
return_to_previous.emit()
|
return_to_previous.emit()
|
||||||
|
|
||||||
func state_input(event: InputEvent) -> void:
|
func use_end() -> void:
|
||||||
if is_multiplayer_authority() == false:
|
if is_multiplayer_authority() == false:
|
||||||
return
|
return
|
||||||
if event.is_action_released("plr_bomb"):
|
transition.emit("Idle")
|
||||||
transition.emit("Idle")
|
machine.player.get_node("PlantAudio").multiplayer_stop()
|
||||||
machine.player.get_node("PlantAudio").multiplayer_stop()
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ func _ready() -> void:
|
||||||
player_input.drop.connect(drop_current)
|
player_input.drop.connect(drop_current)
|
||||||
player_input.fire_begin.connect(use_begin)
|
player_input.fire_begin.connect(use_begin)
|
||||||
player_input.fire_end.connect(use_end)
|
player_input.fire_end.connect(use_end)
|
||||||
|
player_input.switch_weapon.connect(switch)
|
||||||
|
player_input.alternate_state.connect(alternate_state)
|
||||||
|
player_input.switch_firemode.connect(switch_mode)
|
||||||
|
|
||||||
func get_speed_modifier() -> float:
|
func get_speed_modifier() -> float:
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
|
|
@ -68,8 +71,9 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
|
||||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||||
state.enter.call_deferred()
|
state.enter.call_deferred()
|
||||||
|
|
||||||
|
@rpc("authority","call_remote","reliable")
|
||||||
func switch(to: StringName, exit: bool = true):
|
func switch(to: StringName, exit: bool = true):
|
||||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or is_multiplayer_authority() == false:
|
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false):
|
||||||
return
|
return
|
||||||
if current_state != null and exit:
|
if current_state != null and exit:
|
||||||
current_state.exit()
|
current_state.exit()
|
||||||
|
|
@ -82,6 +86,8 @@ func switch(to: StringName, exit: bool = true):
|
||||||
|
|
||||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||||
switched_to.emit(current_state)
|
switched_to.emit(current_state)
|
||||||
|
if is_multiplayer_authority():
|
||||||
|
switch.rpc(to,exit)
|
||||||
|
|
||||||
func return_to_previous(exit: bool = true):
|
func return_to_previous(exit: bool = true):
|
||||||
if last_slot != "":
|
if last_slot != "":
|
||||||
|
|
@ -173,3 +179,9 @@ func use_begin() -> void:
|
||||||
|
|
||||||
func use_end() -> void:
|
func use_end() -> void:
|
||||||
current_state.use_end.rpc()
|
current_state.use_end.rpc()
|
||||||
|
|
||||||
|
func alternate_state() -> void:
|
||||||
|
current_state.alternate_state()
|
||||||
|
|
||||||
|
func switch_mode() -> void:
|
||||||
|
current_state.switch_mode()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue