first version of EU AI Act game
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
extends Grabbable_Object
|
||||
class_name Battery
|
||||
|
||||
@export var stored_power: int = 50
|
||||
@export var battery_label: String
|
||||
var connected_station: Node3D = null
|
||||
var original_transform: Transform3D
|
||||
var grabbed_parent
|
||||
var lamp_color
|
||||
@onready var battery_lamp_0: CSGSphere3D = $Battery/Battery_lamp_0
|
||||
@export var image_path: String = "res://assets/Images/EU_AI_Act_logo_main.png"
|
||||
|
||||
func _ready() -> void:
|
||||
lamp_color = battery_lamp_0.material.albedo_color
|
||||
$Sprite3D.texture = load(image_path)
|
||||
|
||||
func insert_into_station(station: Node3D):
|
||||
if connected_station:
|
||||
return
|
||||
connected_station = station
|
||||
grabbed_parent = get_parent()
|
||||
original_transform = global_transform
|
||||
|
||||
# put battery inot box
|
||||
grabbed_parent.remove_child(self)
|
||||
station.add_child(self)
|
||||
self.visible = false
|
||||
self.freeze = true
|
||||
|
||||
if station.has_method("insert_battery"):
|
||||
station.insert_battery(self)
|
||||
|
||||
func remove_from_station():
|
||||
if not connected_station:
|
||||
return null
|
||||
|
||||
var station = connected_station
|
||||
connected_station = null
|
||||
|
||||
|
||||
# get battery back out
|
||||
if original_parent:
|
||||
station.remove_child(self)
|
||||
grabbed_parent.add_child(self)
|
||||
global_transform = original_transform
|
||||
|
||||
self.visible = true
|
||||
self.freeze = false
|
||||
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user