visibility rework
This commit is contained in:
parent
6b939d241c
commit
9d0e09220d
37 changed files with 212 additions and 75 deletions
5
scripts/multiplayer/dynamic_objects_container.gd
Normal file
5
scripts/multiplayer/dynamic_objects_container.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Session.dynamic_objects_container = self
|
||||
1
scripts/multiplayer/dynamic_objects_container.gd.uid
Normal file
1
scripts/multiplayer/dynamic_objects_container.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://be7l33prlm8gh
|
||||
|
|
@ -5,3 +5,5 @@ enum TEAMS {
|
|||
ATTACK,
|
||||
SPECTATE
|
||||
}
|
||||
|
||||
var dynamic_objects_container: Node3D
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func spawn_spectator(id: int) -> void:
|
|||
deferred_setup.bind(inst,Session.TEAMS.SPECTATE).call_deferred()
|
||||
|
||||
func deferred_setup(what: Node3D, new_team: Session.TEAMS):
|
||||
get_tree().current_scene.add_child(what)
|
||||
get_parent().add_child(what)
|
||||
var distance = randf_range(0,spawn_radius)
|
||||
var angle = randf_range(0,TAU)
|
||||
var new_position = global_position + Vector3.RIGHT.rotated(Vector3.UP,angle) * distance
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ extends CharacterBody3D
|
|||
class_name Player
|
||||
|
||||
@export var team: Session.TEAMS
|
||||
@export var weapon_models: Dictionary[StringName,Node3D]
|
||||
|
||||
signal spawned
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
extends WeaponState
|
||||
|
||||
const active_bomb: PackedScene = preload("res://scenes/weapons/active_bomb.tscn")
|
||||
|
||||
func enter():
|
||||
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||
|
|
@ -10,8 +11,13 @@ func exit():
|
|||
|
||||
func on_animation_finished(animation: StringName):
|
||||
if animation == machine.animation_prefix + "plant":
|
||||
var bomb = active_bomb.instantiate()
|
||||
Session.dynamic_objects_container.add_child(bomb,true)
|
||||
bomb.global_position = machine.player_camera.get_parent().global_position
|
||||
|
||||
return_to_previous.emit()
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_released("plr_bomb"):
|
||||
|
||||
return_to_previous.emit()
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ extends SubStateMachine
|
|||
class_name WeaponSubStateMachine
|
||||
|
||||
@export var animation_prefix: StringName
|
||||
@export var visibility_mesh: Node3D
|
||||
@export var model: PackedScene
|
||||
@export var visibility_target: StringName
|
||||
|
||||
@export var max_ammo: int
|
||||
@onready var ammo: int = max_ammo
|
||||
@onready var remaining_ammo: int = max_ammo * 3
|
||||
|
||||
@export var can_be_previous: bool = true
|
||||
|
||||
|
|
@ -15,6 +17,7 @@ signal request_return
|
|||
var system: WeaponSystem
|
||||
var animation_player: AnimationPlayer
|
||||
var player_camera: PlayerCamera
|
||||
var player: Player
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
|
|
@ -26,11 +29,11 @@ func _ready() -> void:
|
|||
|
||||
func enter() -> void:
|
||||
super()
|
||||
visibility_mesh.visible = true
|
||||
player.weapon_models[visibility_target].show()
|
||||
|
||||
func exit() -> void:
|
||||
super()
|
||||
visibility_mesh.visible = false
|
||||
player.weapon_models[visibility_target].hide()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func use_begin() -> void:
|
||||
|
|
|
|||
|
|
@ -7,14 +7,15 @@ class_name WeaponSystem
|
|||
|
||||
@export var animation_player: AnimationPlayer
|
||||
@export var camera: PlayerCamera
|
||||
@export var player: Player
|
||||
|
||||
var current_state: WeaponSubStateMachine
|
||||
var last_slot: StringName
|
||||
|
||||
var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
||||
"primary": null,
|
||||
"secondary": default_pistol,
|
||||
"knife": default_knife,
|
||||
"secondary": null,
|
||||
"knife": null,
|
||||
"bomb": null,
|
||||
"ability_first": null,
|
||||
"ability_second": null,
|
||||
|
|
@ -25,34 +26,31 @@ var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
|||
signal switched_to(state: WeaponSubStateMachine)
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
if child is WeaponSubStateMachine:
|
||||
child.system = self
|
||||
child.animation_player = animation_player
|
||||
child.player_camera = camera
|
||||
child.request_return.connect(return_to_previous)
|
||||
else:
|
||||
push_warning("Child of weapon system is not ability or weapon")
|
||||
|
||||
current_state = default_pistol
|
||||
slots["knife"] = default_knife
|
||||
slots["secondary"] = default_pistol
|
||||
add(default_knife,"knife")
|
||||
add(default_pistol,"secondary")
|
||||
current_state.enter()
|
||||
|
||||
func can_add(slot: StringName) -> bool:
|
||||
return slots.has(slot)
|
||||
return slots.has(slot) and slots[slot] == null
|
||||
|
||||
@rpc("call_local","reliable")
|
||||
func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
||||
if can_add(slot) == false:
|
||||
return
|
||||
print('leech')
|
||||
|
||||
add_child(state)
|
||||
if state.get_parent() == null:
|
||||
add_child(state)
|
||||
if state.get_parent() != self:
|
||||
state.reparent(self)
|
||||
|
||||
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)
|
||||
|
||||
func switch(to: StringName):
|
||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue