Added comms array

This commit is contained in:
akshay 2022-08-17 00:04:04 -04:00
parent eeb34f9372
commit 3a72e066ea
6 changed files with 169 additions and 4 deletions

44
scenes/comm_station.tscn Normal file
View File

@ -0,0 +1,44 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://scenes/item_dump.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/comm_station/comm_station.gd" type="Script" id=2]
[ext_resource path="res://scenes/coin_machine.tscn" type="PackedScene" id=3]
[ext_resource path="res://item_types/ore.tres" type="Resource" id=4]
[ext_resource path="res://item_types/repair_kit.tres" type="Resource" id=5]
[sub_resource type="PrismMesh" id=2]
[sub_resource type="CylinderShape" id=3]
[node name="comm_station" type="Spatial"]
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 2 )
[node name="status_text" type="Label3D" parent="MeshInstance"]
unique_name_in_owner = true
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 1.63295, -0.727839 )
text = "Status: Broken"
[node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
shape = SubResource( 3 )
[node name="item_dump" parent="." instance=ExtResource( 1 )]
unique_name_in_owner = true
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.87031, 0, 0 )
collision_layer = 8
collision_mask = 4
item_type_0 = ExtResource( 5 )
item_count_0 = 1
item_type_1 = ExtResource( 4 )
item_count_1 = 1
[node name="coin_machine" parent="." instance=ExtResource( 3 )]
unique_name_in_owner = true
[connection signal="item_dump_completed" from="item_dump" to="." method="_on_item_dump_item_dump_completed"]
[connection signal="item_dumped" from="item_dump" to="." method="_on_item_dump_item_dumped"]
[connection signal="coin_requirement_met" from="coin_machine" to="." method="_on_coin_machine_coin_requirement_met"]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=25 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/moonbase_whitebox/Moonbase_Whitebox.tscn" type="PackedScene" id=2]
@ -15,6 +15,9 @@
[ext_resource path="res://scenes/hydroponics_station.tscn" type="PackedScene" id=13]
[ext_resource path="res://scenes/oven.tscn" type="PackedScene" id=14]
[ext_resource path="res://scenes/game_manager.tscn" type="PackedScene" id=15]
[ext_resource path="res://scenes/cheat_menu.tscn" type="PackedScene" id=16]
[ext_resource path="res://scenes/item_holder.tscn" type="PackedScene" id=17]
[ext_resource path="res://scenes/comm_station.tscn" type="PackedScene" id=18]
[sub_resource type="CylinderShape" id=8]
height = 5.22615
@ -73,7 +76,6 @@ ssao_enabled = true
[node name="Player" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5.27448 )
hunger_tick_time = 10.0
[node name="cameras" type="Spatial" parent="."]
script = ExtResource( 10 )
@ -226,9 +228,26 @@ transform = Transform( 3, 0, 0, 0, 3, 0, 0, 0, 3, 1.88, 3, -1.043 )
modulate = Color( 0, 0, 0, 1 )
text = "VNDG MACHINE"
[node name="Crafting_Room" type="Spatial" parent="."]
[node name="Storage_Room" type="Spatial" parent="."]
transform = Transform( 0.0379867, 0, -0.999278, 0, 1, 0, 0.999278, 0, 0.0379867, 8.64656, 0, 0.323352 )
[node name="Room_Label" type="Label3D" parent="Storage_Room"]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 4.309, 0 )
modulate = Color( 0, 0, 0, 1 )
text = "Storage"
[node name="item_holder" parent="Storage_Room" instance=ExtResource( 17 )]
transform = Transform( 0.0379867, 0, 0.999278, 0, 1, 0, -0.999278, 0, 0.0379867, -0.0128546, 0, -8.17408 )
[node name="item_holder2" parent="Storage_Room" instance=ExtResource( 17 )]
transform = Transform( 0.0379867, 0, 0.999278, 0, 1, 0, -0.999278, 0, 0.0379867, -2.64011, 0, -8.27395 )
[node name="item_holder3" parent="Storage_Room" instance=ExtResource( 17 )]
transform = Transform( 0.0379867, 0, 0.999278, 0, 1, 0, -0.999278, 0, 0.0379867, 2.23318, 0, -8.0887 )
[node name="Crafting_Room" type="Spatial" parent="."]
transform = Transform( -0.668793, 0, -0.743448, 0, 1, 0, 0.743448, 0, -0.668793, 6.10625, 0, 6.11932 )
[node name="Room_Label" type="Label3D" parent="Crafting_Room"]
transform = Transform( 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 4.309, 0 )
modulate = Color( 0, 0, 0, 1 )
@ -275,8 +294,23 @@ transform = Transform( 1, 0, 0, 0, 1, 5.82077e-11, 0, 0, 1, 1.96066, -2.56114e-0
[node name="hydroponics_station3" parent="Hydroponics_Room" instance=ExtResource( 13 )]
transform = Transform( 1, 0, 0, 0, 1, 5.82077e-11, 0, 0, 1, -1.9892, -3.0268e-09, -7.67101 )
[node name="Communications" type="Spatial" parent="."]
transform = Transform( -0.0426527, 0.000404372, 0.999089, -0.000747618, 1, -0.000436656, -0.999089, -0.000765564, -0.0426524, -8.66408, 0.00565405, 0.343818 )
[node name="Room_Label" type="Label3D" parent="Communications"]
transform = Transform( 4, 0, 0, 0, 4, 2.32831e-10, 0, 0, 4, 0, 4.309, 0 )
modulate = Color( 0, 0, 0, 1 )
text = "Communications"
[node name="comm_station" parent="Communications" instance=ExtResource( 18 )]
transform = Transform( 1, 3.49246e-10, -2.23517e-08, -3.49246e-10, 1, 1.60071e-10, 2.23517e-08, 1.78261e-10, 1, 0.664039, 5.58794e-09, -7.58252 )
[node name="game_manager" parent="." instance=ExtResource( 15 )]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="cheat_menu" parent="CanvasLayer" instance=ExtResource( 16 )]
[connection signal="player_entered" from="cameras/camera_room_center" to="cameras" method="_on_camera_room_player_entered"]
[connection signal="player_exited" from="cameras/camera_room_center" to="cameras" method="_on_camera_room_player_exited"]
[connection signal="area_entered" from="cameras/camera_room_center/hitbox" to="cameras/camera_room_center" method="_on_hitbox_area_entered"]

View File

@ -557,7 +557,7 @@ mesh = SubResource( 1 )
skin = SubResource( 2 )
[node name="head_bone" type="BoneAttachment" parent="DungMan/Armature/Skeleton" index="1"]
transform = Transform( 1, -2.21836e-16, 1.04101e-17, -1.71852e-19, 0.0461024, 0.998937, -2.22081e-16, -0.998937, 0.0461024, -3.32115e-16, -0.0357828, -1.49896 )
transform = Transform( 1, -2.21202e-16, -1.47006e-17, 1.22694e-18, -0.0607882, 0.998151, -2.21687e-16, -0.998151, -0.0607882, -3.31341e-16, -0.0494913, -1.50713 )
bone_name = "Item"
[node name="ItemSpawn" type="Spatial" parent="DungMan/Armature/Skeleton/head_bone"]

View File

@ -0,0 +1,37 @@
extends Spatial
const StateIdle = preload("res://scripts/comm_station/state/idle.gd")
const StateBlocked = preload("res://scripts/comm_station/state/blocked.gd")
var state = null
signal comms_established
onready var coin_machine = $"%coin_machine"
onready var item_dump = $"%item_dump"
onready var status_text = $"%status_text"
func _ready():
state = StateBlocked.new()
state.ctx = self
state.enter_from(null)
print("comms_station: NULL -> ", state.NAME)
func change_state(new_state):
print("comms_station: ", state.NAME, " -> ", new_state.NAME)
new_state.ctx = self
state.exit_to(new_state)
new_state.enter_from(state)
state = new_state
func _on_coin_machine_coin_requirement_met(player):
state.on_coin_machine_coin_requirement_met(player)
func _on_item_dump_item_dump_completed():
state.on_item_dump_item_dump_completed()
func _on_item_dump_item_dumped():
state.on_item_dump_item_dumped()
func emit_signal_comms_established():
emit_signal("comms_established")

View File

@ -0,0 +1,25 @@
extends Reference
const NAME = "blocked"
var ctx = null
func _init():
pass
func enter_from(state):
ctx.coin_machine.enabled = false
ctx.item_dump.enabled = true
ctx.status_text.text = "Offline. Needs Repair"
func exit_to(state):
pass
func on_coin_machine_coin_requirement_met(player):
assert(false, "coin machine should be disabled in blocked state")
func on_item_dump_item_dump_completed():
ctx.change_state(ctx.StateIdle.new())
func on_item_dump_item_dumped():
print("item dumped")

View File

@ -0,0 +1,25 @@
extends Reference
const NAME = "idle"
var ctx = null
func _init():
pass
func enter_from(state):
ctx.coin_machine.enabled = true
ctx.item_dump.enabled = false
ctx.status_text.text = "Online"
func exit_to(state):
pass
func on_coin_machine_coin_requirement_met(player):
ctx.emit_signal_comms_established()
func on_item_dump_item_dump_completed():
assert(false, "item dump should be disabled in idle state")
func _on_item_dump_item_dumped():
assert(false, "item dump should be disabled in idle state")