Added serving of the customers, npc exits, main menu, settings, saving and loading.
This commit is contained in:
parent
3d1e6caa29
commit
2b6d1faadb
19 changed files with 360 additions and 39 deletions
|
@ -1,7 +1,10 @@
|
|||
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||
## Copyright (c) 2024 interstellardevelopment.org
|
||||
|
||||
class_name Bullet
|
||||
extends CharacterBody3D
|
||||
|
||||
const SPEED: int = 20
|
||||
const SPEED: int = 40
|
||||
|
||||
func _ready() -> void:
|
||||
if ($Timer as Timer).timeout.connect(_on_timeout):
|
||||
|
|
|
@ -15,6 +15,7 @@ var carrying: bool = false
|
|||
# 1 - wait
|
||||
# 2 - get carryable object
|
||||
# 3 - chase a player
|
||||
# 4 - leave the building
|
||||
var phase: int = 0
|
||||
|
||||
@onready var timer: Timer = $Timer
|
||||
|
@ -24,23 +25,29 @@ var skip: bool = false
|
|||
@onready var navigation_agent: NavigationAgent3D = $NavigationAgent3D
|
||||
|
||||
func _ready() -> void:
|
||||
if ($Area3D as Area3D).body_entered.connect(_on_body_entered):
|
||||
pass
|
||||
if Networking.isManager:
|
||||
if timer.timeout.connect(_timer_done):
|
||||
pass
|
||||
find_objective()
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
if body is Player and target is Objective:
|
||||
(body as Player).serve_chance(target as Objective, self)
|
||||
|
||||
func _timer_done() -> void:
|
||||
if angry_meter > 0:
|
||||
if angry_meter > 0 and target is Objective:
|
||||
angry_meter -= 1
|
||||
if target is Objective:
|
||||
Networking.npc_text_sync_call("%s %ds left" % [(target as Objective).displayed, angry_meter], self)
|
||||
Networking.npc_text_sync_call("I want a %s! (%ds left)" % [(target as Objective).subtype, angry_meter], target as Objective, self)
|
||||
else:
|
||||
Networking.npc_text_sync_call("", self)
|
||||
(target as Objective).occupied = false
|
||||
Networking.npc_text_sync_call("", target as Objective, self)
|
||||
timer.stop()
|
||||
phase = 2
|
||||
|
||||
func set_text(text: String) -> void:
|
||||
func set_text_and_target(text: String, new_target: Objective) -> void:
|
||||
target = new_target
|
||||
($Label3D as Label3D).text = text
|
||||
|
||||
# determines the closest resting place and navigates to it.
|
||||
|
@ -93,14 +100,22 @@ func set_down(node: Carryable) -> void:
|
|||
find_player(99999999999)
|
||||
phase = 0
|
||||
|
||||
func served() -> void:
|
||||
set_text_and_target("", null)
|
||||
phase = 4
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if Networking.isManager and phase != 1:
|
||||
if phase == 3:
|
||||
find_player(position.distance_to(target.position))
|
||||
elif phase == 2 and target is Objective:
|
||||
elif phase == 2 and target == null:
|
||||
find_carryable()
|
||||
elif phase == 0 and target is Player:
|
||||
find_objective()
|
||||
elif phase == 4 and target == null:
|
||||
target = get_tree().root.get_node("/root/"+Game.mapname+"/NPCExit")
|
||||
navigation_agent.set_target_position(target.position)
|
||||
timer.stop()
|
||||
|
||||
if navigation_agent.is_navigation_finished():
|
||||
if phase == 0:
|
||||
|
@ -112,6 +127,8 @@ func _physics_process(_delta: float) -> void:
|
|||
angry_meter = (target as Objective).time + 1
|
||||
_timer_done()
|
||||
timer.start()
|
||||
if phase == 4:
|
||||
Networking.npc_free_sync_call(self)
|
||||
return
|
||||
|
||||
var current_agent_position: Vector3 = global_position
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
class_name Player
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
const SPEED: float = 5.0
|
||||
const JUMP_VELOCITY: float = 4.5
|
||||
|
||||
|
@ -12,7 +11,7 @@ var activated: bool = false
|
|||
var freecam: bool = false
|
||||
var incapacitated: bool = false
|
||||
var interaction: String
|
||||
var revival_target: Player
|
||||
var target: Node3D
|
||||
var carrying_gun: bool = false
|
||||
|
||||
@onready var camera: Camera3D = $Camera3D
|
||||
|
@ -56,10 +55,10 @@ func _physics_process(delta: float) -> void:
|
|||
($CollisionShape3D as CollisionShape3D).disabled = !($CollisionShape3D as CollisionShape3D).disabled
|
||||
|
||||
if Input.is_action_just_pressed("interact") and interaction != null:
|
||||
if interaction == "revive" and revival_target != null:
|
||||
Networking.revive_sync_call(revival_target)
|
||||
if interaction == "revive" and target != null:
|
||||
Networking.revive_sync_call(target as Player)
|
||||
($InteractDialog as Label).text = ""
|
||||
revival_target = null
|
||||
target = null
|
||||
if interaction == "gun":
|
||||
var guncase: Guncase = get_node("/root/%s/Guncase" % Game.mapname)
|
||||
if !guncase.held:
|
||||
|
@ -70,7 +69,11 @@ func _physics_process(delta: float) -> void:
|
|||
carrying_gun = false
|
||||
($InteractDialog as Label).text = ""
|
||||
Networking.guncase_sync_call(false, self)
|
||||
|
||||
if interaction == "serve":
|
||||
Networking.npc_served_sync_call(target as NPC)
|
||||
($InteractDialog as Label).text = ""
|
||||
target = null
|
||||
|
||||
if Input.is_action_just_pressed("shoot") and carrying_gun:
|
||||
Networking.bullet_sync_call(position + (transform.basis * Vector3(0, 0, -1)).normalized(), rotation)
|
||||
|
||||
|
@ -78,15 +81,10 @@ func _physics_process(delta: float) -> void:
|
|||
var direction: Vector3 = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
||||
#TODO: Hacky solution -> Also can be exploited to revive everyone in the game constantly.
|
||||
if revival_target != null and position.distance_to(revival_target.position) > 3:
|
||||
if target != null and position.distance_to(target.position) > 3:
|
||||
($InteractDialog as Label).text = ""
|
||||
interaction = ""
|
||||
revival_target = null
|
||||
|
||||
if interaction == "gun":
|
||||
if position.distance_to((get_node("/root/%s/Guncase" % Game.mapname) as Guncase).position) > 3:
|
||||
($InteractDialog as Label).text = ""
|
||||
interaction = ""
|
||||
target = null
|
||||
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
|
@ -126,9 +124,9 @@ func incapacitate() -> void:
|
|||
|
||||
func revive_chance(body: Player) -> void:
|
||||
if activated:
|
||||
revival_target = body
|
||||
target = body
|
||||
interaction = "revive"
|
||||
($InteractDialog as Label).text = "Press E to revive %s." % revival_target.name
|
||||
($InteractDialog as Label).text = "Press E to revive %s." % target.name
|
||||
|
||||
func revive() -> void:
|
||||
rotation.x = 0
|
||||
|
@ -137,6 +135,7 @@ func revive() -> void:
|
|||
func gun_chance() -> void:
|
||||
if activated:
|
||||
interaction = "gun"
|
||||
target = get_node("/root/%s/Guncase" % Game.mapname) as Guncase
|
||||
if carrying_gun:
|
||||
($InteractDialog as Label).text = "Press E to set down gun."
|
||||
else:
|
||||
|
@ -147,3 +146,9 @@ func show_gun() -> void:
|
|||
|
||||
func hide_gun() -> void:
|
||||
($Gun as MeshInstance3D).hide()
|
||||
|
||||
func serve_chance(objective: Objective, npc: NPC) -> void:
|
||||
if activated:
|
||||
interaction = "serve"
|
||||
target = npc
|
||||
($InteractDialog as Label).text = "Press E to serve the guest a %s." % objective.subtype
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue