Camera system YAY!!!
This commit is contained in:
@@ -1,12 +1,82 @@
|
|||||||
{
|
{
|
||||||
"HANGAR": 1,
|
"1": {
|
||||||
"KITCHEN": 2,
|
"location": 2,
|
||||||
"REC_ROOM": 3,
|
"name": "HANGAR",
|
||||||
"RESTROOM": 4,
|
"disabled": false,
|
||||||
"SUPPLY_ROOM": 5,
|
"renders": {
|
||||||
"MAINTENANCE_ROOM": 6,
|
|
||||||
"STORAGE_A": 7,
|
}
|
||||||
"STORAGE_B": 8,
|
},
|
||||||
"EAST_HALLWAY": 9,
|
"2": {
|
||||||
"WEST_HALLWAY": 10
|
"location": 3,
|
||||||
|
"name": "KITCHEN",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"location": 3,
|
||||||
|
"name": "REC_ROOM",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"location": 4,
|
||||||
|
"name": "RESTROOM",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
"location": 5,
|
||||||
|
"name": "SUPPLY_ROOM",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"7": {
|
||||||
|
"location": 6,
|
||||||
|
"name": "MAINTENANCE_ROOM",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"8": {
|
||||||
|
"location": 7,
|
||||||
|
"name": "STORAGE_A",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"9": {
|
||||||
|
"location": 8,
|
||||||
|
"name": "STORAGE_B",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"11": {
|
||||||
|
"location": 9,
|
||||||
|
"name": "EAST_HALLWAY",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"12": {
|
||||||
|
"location": 10,
|
||||||
|
"name": "WEST_HALLWAY",
|
||||||
|
"disabled": false,
|
||||||
|
"renders": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://cqd214exw72db"]
|
[gd_scene load_steps=6 format=3 uid="uid://cqd214exw72db"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://bcxvg2kigp6u1" path="res://Themes/UI/Terminal/tTerminalPrompt.tres" id="2_afen0"]
|
[ext_resource type="Theme" uid="uid://bcxvg2kigp6u1" path="res://Themes/UI/Terminal/tTerminalPrompt.tres" id="2_afen0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c6m1tx7klorqr" path="res://Renders/Camera/PowerStation/powerstation_1.png" id="2_f87w0"]
|
[ext_resource type="Texture2D" uid="uid://c6m1tx7klorqr" path="res://Renders/Camera/PowerStation/powerstation_1.png" id="2_f87w0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cv2cadqcahubl" path="res://map.png" id="4_afen0"]
|
[ext_resource type="Texture2D" uid="uid://cv2cadqcahubl" path="res://map.png" id="4_afen0"]
|
||||||
|
[ext_resource type="Script" uid="uid://be6xuapep782t" path="res://Scripts/Gameplay/Camera/cCameraViewer.gd" id="4_w4v7x"]
|
||||||
[ext_resource type="Script" uid="uid://dmp22gu6t0fw2" path="res://Scripts/Gameplay/CommandLine/cCommandLine.gd" id="13_tqcie"]
|
[ext_resource type="Script" uid="uid://dmp22gu6t0fw2" path="res://Scripts/Gameplay/CommandLine/cCommandLine.gd" id="13_tqcie"]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Node2D" type="Node2D"]
|
||||||
@@ -60,6 +61,7 @@ offset_right = 4392.0
|
|||||||
offset_bottom = 2904.0
|
offset_bottom = 2904.0
|
||||||
scale = Vector2(0.185, 0.185)
|
scale = Vector2(0.185, 0.185)
|
||||||
texture = ExtResource("2_f87w0")
|
texture = ExtResource("2_f87w0")
|
||||||
|
script = ExtResource("4_w4v7x")
|
||||||
|
|
||||||
[node name="B_Shock" type="Button" parent="."]
|
[node name="B_Shock" type="Button" parent="."]
|
||||||
offset_left = 16.0
|
offset_left = 16.0
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
class_name npcConstruct
|
class_name npcConstruct
|
||||||
extends cCharacter
|
extends cCharacter
|
||||||
|
|
||||||
|
var defaultRoom = 0
|
||||||
|
|
||||||
signal location_changed(ai, old_location, new_location)
|
signal location_changed(ai, old_location, new_location)
|
||||||
signal state_changed(ai, old_state, new_state)
|
signal state_changed(ai, old_state, new_state)
|
||||||
|
|
||||||
@@ -15,6 +17,8 @@ func advance_state() -> void:
|
|||||||
func _ready():
|
func _ready():
|
||||||
super._ready()
|
super._ready()
|
||||||
print("Construct Ready")
|
print("Construct Ready")
|
||||||
|
|
||||||
|
|
||||||
Global.game.night.hour_changed.connect(_on_hour_changed)
|
Global.game.night.hour_changed.connect(_on_hour_changed)
|
||||||
|
|
||||||
func _on_hour_changed(hour: int):
|
func _on_hour_changed(hour: int):
|
||||||
|
|||||||
49
Scripts/Gameplay/Camera/cCamera.gd
Normal file
49
Scripts/Gameplay/Camera/cCamera.gd
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
class_name cCamera
|
||||||
|
|
||||||
|
var cam: Dictionary
|
||||||
|
var camID: String
|
||||||
|
|
||||||
|
var camGraph = Global.loadJSON("res://Data/cameras.json")
|
||||||
|
|
||||||
|
var name: String
|
||||||
|
var disabled: bool
|
||||||
|
var rendersChart: Dictionary
|
||||||
|
var renders: Dictionary
|
||||||
|
var locationID: String
|
||||||
|
var location: cLocation
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _init(id: String) -> void:
|
||||||
|
camID = id
|
||||||
|
cam = camGraph[camID]
|
||||||
|
|
||||||
|
print("Setting up camera " + camID)
|
||||||
|
name = cam.get("name")
|
||||||
|
disabled = cam.get("disabled")
|
||||||
|
rendersChart = cam.get("renders")
|
||||||
|
locationID = str( int( cam.get("location") ) )
|
||||||
|
location = cLocation.new(locationID)
|
||||||
|
|
||||||
|
print(name)
|
||||||
|
print(disabled)
|
||||||
|
print(rendersChart)
|
||||||
|
print(location)
|
||||||
|
|
||||||
|
_loadRenders()
|
||||||
|
|
||||||
|
func _loadRenders():
|
||||||
|
renders = {}
|
||||||
|
for key in rendersChart:
|
||||||
|
var renderPath = rendersChart[key]
|
||||||
|
|
||||||
|
if renderPath == null or not FileAccess.file_exists(renderPath):
|
||||||
|
push_error("Missing render: " + str(renderPath))
|
||||||
|
continue
|
||||||
|
|
||||||
|
renders[key] = load(renderPath)
|
||||||
|
|
||||||
|
func getFeed() -> Texture2D:
|
||||||
|
var hash = location.makeHash()
|
||||||
|
if not renders.has(hash): return null
|
||||||
|
|
||||||
|
return renders[hash]
|
||||||
1
Scripts/Gameplay/Camera/cCamera.gd.uid
Normal file
1
Scripts/Gameplay/Camera/cCamera.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bsxrimscxvjck
|
||||||
53
Scripts/Gameplay/Camera/cCameraViewer.gd
Normal file
53
Scripts/Gameplay/Camera/cCameraViewer.gd
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
class_name cCameraViewer
|
||||||
|
extends TextureRect
|
||||||
|
|
||||||
|
var defaultTexture: Texture2D
|
||||||
|
|
||||||
|
var activeCamera: cCamera = null
|
||||||
|
var activeCameraID: int = -1
|
||||||
|
var activeTexture: Texture2D = null
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
clearCamera()
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if activeCamera == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
var newTexture = getCameraRender()
|
||||||
|
if newTexture != activeTexture:
|
||||||
|
activeTexture = newTexture
|
||||||
|
renderCamera()
|
||||||
|
|
||||||
|
func setCamera(id: int) -> void:
|
||||||
|
clearCamera()
|
||||||
|
|
||||||
|
activeCameraID = id
|
||||||
|
activeCamera = Global.game.camera
|
||||||
|
|
||||||
|
renderCamera()
|
||||||
|
|
||||||
|
func renderCamera() -> void:
|
||||||
|
if activeTexture == null:
|
||||||
|
self.texture = defaultTexture
|
||||||
|
else:
|
||||||
|
self.texture = activeTexture
|
||||||
|
|
||||||
|
func clearCamera() -> void:
|
||||||
|
activeCamera = null
|
||||||
|
activeCameraID = -1
|
||||||
|
activeTexture = defaultTexture
|
||||||
|
renderCamera()
|
||||||
|
|
||||||
|
|
||||||
|
func getCameraRender() -> Texture2D:
|
||||||
|
if activeCamera == null:
|
||||||
|
return defaultTexture
|
||||||
|
|
||||||
|
var feed = activeCamera.getFeed()
|
||||||
|
|
||||||
|
if feed == null:
|
||||||
|
return defaultTexture
|
||||||
|
|
||||||
|
return feed
|
||||||
1
Scripts/Gameplay/Camera/cCameraViewer.gd.uid
Normal file
1
Scripts/Gameplay/Camera/cCameraViewer.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://be6xuapep782t
|
||||||
@@ -21,7 +21,8 @@ func main(args: Array, context: Node) -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
var cam_name = Global.cameraHelper.getName(cam_id)
|
var cam_name = Global.cameraHelper.getName(cam_id)
|
||||||
|
|
||||||
|
var newCam = cCamera.new(str(cam_id))
|
||||||
|
newCam._init(str(cam_id))
|
||||||
|
|
||||||
context._print("Camera set to %s" % cam_name.capitalize())
|
context._print("Camera set to %s" % cam_name.capitalize())
|
||||||
|
|
||||||
print(Global.cameraHelper.id_to_name)
|
|
||||||
print(Global.cameraHelper.name_to_id)
|
|
||||||
|
|||||||
65
Scripts/Gameplay/Location/cLocation.gd
Normal file
65
Scripts/Gameplay/Location/cLocation.gd
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
class_name cLocation
|
||||||
|
|
||||||
|
var locationGraph = Global.locations
|
||||||
|
|
||||||
|
var location: Dictionary
|
||||||
|
var locationID: String
|
||||||
|
|
||||||
|
var name: String
|
||||||
|
var connections: Array
|
||||||
|
|
||||||
|
var enemyTemplate = {
|
||||||
|
"present": false,
|
||||||
|
"state": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var construct = enemyTemplate.duplicate()
|
||||||
|
var yoshida = enemyTemplate.duplicate()
|
||||||
|
var akers = enemyTemplate.duplicate()
|
||||||
|
var flesher = enemyTemplate.duplicate()
|
||||||
|
|
||||||
|
func _init(id: String):
|
||||||
|
# Set immediate values
|
||||||
|
locationID = id
|
||||||
|
print(locationGraph)
|
||||||
|
print(id)
|
||||||
|
location = locationGraph.get(id)
|
||||||
|
|
||||||
|
# Set Fields
|
||||||
|
name = location.get("name")
|
||||||
|
connections = location.get("connections")
|
||||||
|
|
||||||
|
func isPresent(character: String) -> bool:
|
||||||
|
match character:
|
||||||
|
"construct":
|
||||||
|
return construct.get("present")
|
||||||
|
"yoshida":
|
||||||
|
return yoshida.get("present")
|
||||||
|
"akers":
|
||||||
|
return akers.get("present")
|
||||||
|
"flesher":
|
||||||
|
return flesher.get("present")
|
||||||
|
return false
|
||||||
|
|
||||||
|
func getState(character: String) -> int:
|
||||||
|
match character:
|
||||||
|
"construct":
|
||||||
|
return construct.get("state")
|
||||||
|
"yoshida":
|
||||||
|
return yoshida.get("state")
|
||||||
|
"akers":
|
||||||
|
return akers.get("state")
|
||||||
|
"flesher":
|
||||||
|
return flesher.get("state")
|
||||||
|
return -1
|
||||||
|
|
||||||
|
func makeHash() -> String:
|
||||||
|
var hash = ""
|
||||||
|
var characters = ["construct", "yoshida", "akers", "flesher"]
|
||||||
|
|
||||||
|
for c in characters:
|
||||||
|
if isPresent(c):
|
||||||
|
hash += c[0]
|
||||||
|
hash += str( getState(c) )
|
||||||
|
|
||||||
|
return hash
|
||||||
1
Scripts/Gameplay/Location/cLocation.gd.uid
Normal file
1
Scripts/Gameplay/Location/cLocation.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cor2nfptbpmby
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
class_name hCamera
|
class_name hCamera
|
||||||
|
|
||||||
|
var cameras: Dictionary = {}
|
||||||
var name_to_id: Dictionary = {}
|
var name_to_id: Dictionary = {}
|
||||||
var id_to_name: Dictionary = {}
|
var id_to_name: Dictionary = {}
|
||||||
|
|
||||||
@@ -9,13 +10,15 @@ func setup(cameras_dict: Dictionary) -> void:
|
|||||||
push_error("Cameras dictionary is null!")
|
push_error("Cameras dictionary is null!")
|
||||||
return
|
return
|
||||||
|
|
||||||
name_to_id = cameras_dict.duplicate()
|
cameras = cameras_dict
|
||||||
id_to_name.clear()
|
|
||||||
for name in name_to_id.keys():
|
id_to_name = cameras_dict.duplicate()
|
||||||
id_to_name[int(name_to_id[name])] = name # ensure keys are ints
|
name_to_id.clear()
|
||||||
|
|
||||||
func getID(cameraName: String) -> int:
|
func getID(cameraName: String) -> int:
|
||||||
|
return 0
|
||||||
return name_to_id.get(cameraName.to_upper(), -1)
|
return name_to_id.get(cameraName.to_upper(), -1)
|
||||||
|
|
||||||
func getName(cam_id: int) -> String:
|
func getName(cam_id: int) -> String:
|
||||||
|
return "DISABLED"
|
||||||
return id_to_name.get(cam_id, "UNKNOWN")
|
return id_to_name.get(cam_id, "UNKNOWN")
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
class_name cRoom
|
|
||||||
extends Resource
|
|
||||||
|
|
||||||
var id: int
|
|
||||||
var name: String
|
|
||||||
var connections: Array = []
|
|
||||||
var enemies: Array = []
|
|
||||||
|
|
||||||
func add_enemy(enemy):
|
|
||||||
if enemy not in enemies:
|
|
||||||
enemies.append(enemy)
|
|
||||||
|
|
||||||
func remove_enemy(enemy):
|
|
||||||
enemies.erase(enemy)
|
|
||||||
|
|
||||||
func _process(_delta):
|
|
||||||
pass
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://bh0j1ffo2peo0
|
|
||||||
@@ -1,23 +1,20 @@
|
|||||||
class_name cGame
|
class_name cGame
|
||||||
|
|
||||||
var night: cNight
|
var night: cNight
|
||||||
var rooms: Dictionary = {}
|
|
||||||
var enemies: Dictionary = {}
|
var enemies: Dictionary = {}
|
||||||
var locations: Dictionary = {}
|
var locations: Dictionary = {}
|
||||||
|
var cameras: Array = []
|
||||||
|
|
||||||
var nightStarted = false
|
var nightStarted = false
|
||||||
var nightCompleted = false
|
var nightCompleted = false
|
||||||
|
|
||||||
func build_rooms():
|
func make_cameras():
|
||||||
for id_str in locations.keys():
|
var camera
|
||||||
var data = locations[id_str]
|
for key in Global.cameras:
|
||||||
|
print(key)
|
||||||
|
camera = cCamera.new(key)
|
||||||
|
cameras.append(camera)
|
||||||
|
|
||||||
var room = cRoom.new()
|
|
||||||
room.id = int(id_str)
|
|
||||||
room.name = data.name
|
|
||||||
room.connections = data.connections
|
|
||||||
|
|
||||||
rooms[room.id] = room
|
|
||||||
|
|
||||||
func make_enemies():
|
func make_enemies():
|
||||||
var eConstruct = npcConstruct.new()
|
var eConstruct = npcConstruct.new()
|
||||||
@@ -31,11 +28,10 @@ func make_enemies():
|
|||||||
"yoshida": eYoshida
|
"yoshida": eYoshida
|
||||||
}
|
}
|
||||||
|
|
||||||
func _setup() -> Array:
|
func _setup():
|
||||||
print("Setting up Game")
|
print("Setting up Game")
|
||||||
night = cNight.new()
|
night = cNight.new()
|
||||||
locations = Global.locations
|
locations = Global.locations
|
||||||
build_rooms()
|
|
||||||
|
make_cameras()
|
||||||
make_enemies()
|
make_enemies()
|
||||||
print([rooms, enemies])
|
|
||||||
return [rooms, enemies]
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var stars = 0
|
|||||||
var cameras
|
var cameras
|
||||||
var locations
|
var locations
|
||||||
var cameraHelper
|
var cameraHelper
|
||||||
var game
|
var game: cGame
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
cameras = loadJSON("res://Data/cameras.json")
|
cameras = loadJSON("res://Data/cameras.json")
|
||||||
@@ -15,12 +15,12 @@ func _ready() -> void:
|
|||||||
cameraHelper = hCamera.new()
|
cameraHelper = hCamera.new()
|
||||||
cameraHelper.setup(cameras)
|
cameraHelper.setup(cameras)
|
||||||
|
|
||||||
game = cGame.new()
|
|
||||||
|
|
||||||
begin_game()
|
begin_game()
|
||||||
|
|
||||||
func begin_game():
|
func begin_game():
|
||||||
|
game = cGame.new()
|
||||||
game._setup()
|
game._setup()
|
||||||
|
|
||||||
game.nightStarted = true
|
game.nightStarted = true
|
||||||
|
|
||||||
func loadJSON(path: String) -> Dictionary:
|
func loadJSON(path: String) -> Dictionary:
|
||||||
|
|||||||
Reference in New Issue
Block a user