Move "computer" related state to the OldComputer singleton.
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
1 parent
5ef5874d11
commit
f8eb3cb378
2 files changed
+31
-30
No files matched your search
+28
-1
@@ -1,7 +1,34 @@
|
|||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
|
var disks_wanted = [1, 2, 3, 4]
|
||||||
|
var disks_loaded = []
|
||||||
|
|
||||||
|
var starting_integrity = 2
|
||||||
|
var total_integrity = starting_integrity + len(disks_wanted)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$ConsoleText.text = $ConsoleText.text % %Pharaoh.get_memory_integrity()
|
$ConsoleText.text = $ConsoleText.text % get_memory_integrity()
|
||||||
|
|
||||||
|
func load_disk(disk_num: int) -> bool:
|
||||||
|
if !disk_num or (disk_num in disks_loaded):
|
||||||
|
return false
|
||||||
|
|
||||||
|
disks_loaded.push_back(disk_num)
|
||||||
|
disks_wanted.remove_at(disks_wanted.find(disk_num))
|
||||||
|
|
||||||
|
print("Loaded up disk ", disk_num)
|
||||||
|
printline(
|
||||||
|
">> Loaded data disk %d (of %d). Memory integrity now at %d%%" %
|
||||||
|
[disk_num, len(disks_wanted) + len(disks_loaded), get_memory_integrity()]
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
func get_next_disk_num() -> int:
|
||||||
|
return disks_wanted.front()
|
||||||
|
|
||||||
|
func get_memory_integrity():
|
||||||
|
return 100.0 / total_integrity * (starting_integrity + len(disks_loaded))
|
||||||
|
|
||||||
func open() -> void:
|
func open() -> void:
|
||||||
visible = true
|
visible = true
|
||||||
|
|||||||
+3
-29
@@ -1,29 +1,12 @@
|
|||||||
extends Interactable
|
extends Interactable
|
||||||
|
|
||||||
var disks_wanted = [1, 2, 3, 4]
|
|
||||||
var disks_loaded = []
|
|
||||||
|
|
||||||
var starting_integrity = 2
|
|
||||||
var total_integrity = starting_integrity + len(disks_wanted)
|
|
||||||
|
|
||||||
func load_disk(disk_num: int) -> bool:
|
|
||||||
if !disk_num or (disk_num in disks_loaded):
|
|
||||||
return false
|
|
||||||
|
|
||||||
disks_loaded.push_back(disk_num)
|
|
||||||
disks_wanted.remove_at(disks_wanted.find(disk_num))
|
|
||||||
return true
|
|
||||||
|
|
||||||
func get_memory_integrity():
|
|
||||||
return 100.0 / total_integrity * (starting_integrity + len(disks_loaded))
|
|
||||||
|
|
||||||
func _on_interacted() -> void:
|
func _on_interacted() -> void:
|
||||||
#%OldComputer.open()
|
#%OldComputer.open()
|
||||||
|
|
||||||
|
|
||||||
%Player2D.spawn_point = global_position
|
%Player2D.spawn_point = global_position
|
||||||
|
|
||||||
var wanted_disk = disks_wanted.front()
|
var wanted_disk = %OldComputer.get_next_disk_num()
|
||||||
if %Player2D.complete_objective("sarc"):
|
if %Player2D.complete_objective("sarc"):
|
||||||
%OldComputer.open()
|
%OldComputer.open()
|
||||||
%Player2D.give_objective(
|
%Player2D.give_objective(
|
||||||
@@ -32,20 +15,11 @@ func _on_interacted() -> void:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not %Player2D.take_disk(wanted_disk):
|
if not (%Player2D.take_disk(wanted_disk) and %OldComputer.load_disk(wanted_disk)):
|
||||||
return
|
|
||||||
|
|
||||||
if not load_disk(wanted_disk):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
%Player2D.complete_objective("disk%d" % wanted_disk)
|
%Player2D.complete_objective("disk%d" % wanted_disk)
|
||||||
print("Loaded up disk ", wanted_disk)
|
wanted_disk = %OldComputer.get_next_disk_num()
|
||||||
%OldComputer.printline(
|
|
||||||
">> Loaded data disk %d (of %d). Memory integrity now at %d%%" %
|
|
||||||
[wanted_disk, len(disks_wanted) + len(disks_loaded), get_memory_integrity()]
|
|
||||||
)
|
|
||||||
|
|
||||||
wanted_disk = disks_wanted.front()
|
|
||||||
if (not wanted_disk) or %Player2D.has_disk(wanted_disk):
|
if (not wanted_disk) or %Player2D.has_disk(wanted_disk):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user