Add rover game and such
This commit is contained in:
1 parent
e80cd37534
commit
373838d3e7
37 files changed
+1558
-35
No files matched your search
@@ -5,6 +5,7 @@ signal starved_to_death
|
||||
const StateDefault = preload("res://scripts/player/state/default.gd")
|
||||
const StateInteracting = preload("res://scripts/player/state/interacting.gd")
|
||||
const StateSleeping = preload("res://scripts/player/state/sleeping.gd")
|
||||
const StatePlayingRoverGame = preload("res://scripts/player/state/playing_rover_game.gd")
|
||||
|
||||
const SPEED = 10.0
|
||||
const MAX_HEALTH = 4
|
||||
@@ -133,3 +134,8 @@ func _on_blink_timer_timeout():
|
||||
func sleep(made_it_to_bed: bool, hop_position: Spatial):
|
||||
state.on_sleep(made_it_to_bed, hop_position)
|
||||
|
||||
func start_playing_rover_game():
|
||||
state.on_start_playing_rover_game()
|
||||
|
||||
func stop_playing_rover_game():
|
||||
state.on_stop_playing_rover_game()
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Reference
|
||||
|
||||
const INTERFACES = [preload("res://scripts/player/state/state_interface.tres")]
|
||||
const NAME = "default"
|
||||
const EPSILON = 0.0001
|
||||
|
||||
@@ -7,9 +8,6 @@ var ctx = null
|
||||
var anim_tree: AnimationTree
|
||||
var move_playback
|
||||
|
||||
func _init():
|
||||
pass
|
||||
|
||||
func enter_from(state):
|
||||
anim_tree = ctx.get_node("model_transform/DungMan/AnimationTree")
|
||||
move_playback = anim_tree["parameters/Move/playback"]
|
||||
@@ -34,3 +32,10 @@ func unhandled_input(event):
|
||||
|
||||
func on_sleep(made_it_to_bed: bool, hop_position: Spatial):
|
||||
ctx.change_state(ctx.StateSleeping.new(made_it_to_bed, hop_position))
|
||||
|
||||
func on_start_playing_rover_game():
|
||||
ctx.change_state(ctx.StatePlayingRoverGame.new())
|
||||
|
||||
func on_stop_playing_rover_game():
|
||||
assert(false, "invalid state")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Reference
|
||||
|
||||
const INTERFACES = [preload("res://scripts/player/state/state_interface.tres")]
|
||||
const NAME = "interacting"
|
||||
|
||||
var ctx: KinematicBody = null
|
||||
@@ -17,7 +18,8 @@ func enter_from(state):
|
||||
timer.connect("timeout", self, "_on_timeout", [], CONNECT_ONESHOT)
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
if timer.is_connected("timeout", self, "_on_timeout"):
|
||||
timer.disconnect("timeout", self, "_on_timeout")
|
||||
|
||||
func physics_process(delta):
|
||||
pass
|
||||
@@ -50,5 +52,10 @@ func try_trigger_interact(area) -> bool:
|
||||
return true
|
||||
|
||||
func on_sleep(made_it_to_bed: bool, hop_position: Spatial):
|
||||
timer.disconnect("timeout", self, "_on_timeout")
|
||||
ctx.change_state(ctx.StateSleeping.new(made_it_to_bed, hop_position))
|
||||
|
||||
func on_start_playing_rover_game():
|
||||
ctx.change_state(ctx.StatePlayingRoverGame.new())
|
||||
|
||||
func on_stop_playing_rover_game():
|
||||
assert(false, "invalid state")
|
||||
@@ -0,0 +1,29 @@
|
||||
extends Reference
|
||||
|
||||
const INTERFACES = [preload("res://scripts/player/state/state_interface.tres")]
|
||||
const NAME = "playing_rover_game"
|
||||
|
||||
var ctx: KinematicBody = null
|
||||
|
||||
func enter_from(state):
|
||||
var anim_tree: AnimationTree = ctx.get_node("model_transform/DungMan/AnimationTree")
|
||||
var move_playback: AnimationNodeStateMachinePlayback = anim_tree["parameters/Move/playback"]
|
||||
move_playback.travel("idle")
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
|
||||
func physics_process(delta):
|
||||
pass
|
||||
|
||||
func unhandled_input(event: InputEvent):
|
||||
pass
|
||||
|
||||
func on_sleep(made_it_to_bed: bool, hop_position: Spatial):
|
||||
ctx.change_state(ctx.StateSleeping.new(made_it_to_bed, hop_position))
|
||||
|
||||
func on_start_playing_rover_game():
|
||||
assert(false, "invalid state")
|
||||
|
||||
func on_stop_playing_rover_game():
|
||||
ctx.change_state(ctx.StateDefault.new())
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Reference
|
||||
|
||||
const INTERFACES = [preload("res://scripts/player/state/state_interface.tres")]
|
||||
const NAME = "sleeping"
|
||||
|
||||
var ctx: KinematicBody = null
|
||||
@@ -16,6 +17,7 @@ func _init(p_made_it_to_bed: bool, p_hop_position: Spatial = null):
|
||||
made_it_to_bed = p_made_it_to_bed
|
||||
|
||||
func enter_from(state):
|
||||
ctx.get_tree().call_group("on_player_sleep_listener", "on_player_sleep")
|
||||
hop_position = hop_position if hop_position else ctx.get_tree().get_nodes_in_group("bed_hop_position")[0]
|
||||
model_transform = ctx.get_node("model_transform")
|
||||
anim_player = ctx.get_node("model_transform/node_animations")
|
||||
@@ -97,3 +99,9 @@ func unhandled_input(event: InputEvent):
|
||||
|
||||
func on_sleep(made_it_to_bed: bool, hop_position: Spatial):
|
||||
assert(false, "shouldn't be able to sleep while sleeping")
|
||||
|
||||
func on_start_playing_rover_game():
|
||||
assert(false, "invalid state")
|
||||
|
||||
func on_stop_playing_rover_game():
|
||||
pass
|
||||
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/Interface.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
method_names = [ "enter_from", "exit_to", "physics_process", "unhandled_input", "on_sleep", "on_start_playing_rover_game", "on_stop_playing_rover_game" ]
|
||||
Reference in new issue
Block a user