initial shit
This commit is contained in:
33
Objects/Scripts/I3PositionSwitch.gd
Normal file
33
Objects/Scripts/I3PositionSwitch.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends Node3D
|
||||
|
||||
signal incremented
|
||||
signal decremented
|
||||
signal switchUpdated
|
||||
|
||||
@export var State = 0
|
||||
@export var isLoopingUpdate : bool = false
|
||||
|
||||
func _interact_press(is_alt_click: bool = false) -> void:
|
||||
if is_alt_click:
|
||||
if State != 0:
|
||||
State -= 1
|
||||
$Sound.play()
|
||||
emit_signal("decremented")
|
||||
emit_signal("switchUpdated")
|
||||
else:
|
||||
if State != 2:
|
||||
State += 1
|
||||
$Sound.play()
|
||||
emit_signal("incremented")
|
||||
emit_signal("switchUpdated")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if State == 0:
|
||||
$StaticBody3D.rotation_degrees = Vector3(0, 45, 0)
|
||||
elif State == 1:
|
||||
$StaticBody3D.rotation_degrees = Vector3(0, 0, 0)
|
||||
elif State == 2:
|
||||
$StaticBody3D.rotation_degrees = Vector3(0, -45, 0)
|
||||
|
||||
if isLoopingUpdate:
|
||||
emit_signal("switchUpdated")
|
||||
1
Objects/Scripts/I3PositionSwitch.gd.uid
Normal file
1
Objects/Scripts/I3PositionSwitch.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://mbjs5s2p30dh
|
||||
59
Objects/Scripts/IButton.gd
Normal file
59
Objects/Scripts/IButton.gd
Normal file
@@ -0,0 +1,59 @@
|
||||
extends Node
|
||||
|
||||
signal buttonPressed
|
||||
signal buttonReleased
|
||||
signal buttonUpdated
|
||||
|
||||
@export var isBeingPressed = false
|
||||
@export var text : String
|
||||
@export var isLoopingUpdate : bool = false
|
||||
@export var color : Color
|
||||
|
||||
# FIX: Do not instantly assign an empty .new() if it might have been loaded
|
||||
var material : StandardMaterial3D
|
||||
|
||||
func _ready() -> void:
|
||||
# Reconstruct or override the material instance cleanly on load
|
||||
material = StandardMaterial3D.new()
|
||||
material.albedo_color = color
|
||||
|
||||
ButtonAnimation.loop_mode = Animation.LOOP_NONE
|
||||
$StaticBody3D/Label3D.text = text
|
||||
$StaticBody3D/MeshInstance3D.material_override = material
|
||||
|
||||
# Keep animation visually synced with the saved press state
|
||||
if isBeingPressed:
|
||||
$AnimationPlayer.play("interact")
|
||||
$AnimationPlayer.advance(ButtonAnimation.length)
|
||||
else:
|
||||
$AnimationPlayer.play_backwards("interact")
|
||||
|
||||
@onready var ButtonAnimation = $AnimationPlayer.get_animation("interact")
|
||||
|
||||
func _press():
|
||||
if not isBeingPressed:
|
||||
emit_signal("buttonPressed")
|
||||
isBeingPressed = true
|
||||
$AnimationPlayer.play("interact")
|
||||
$Sound.pitch_scale = 1.5
|
||||
$Sound.play()
|
||||
emit_signal("buttonUpdated")
|
||||
|
||||
func _release():
|
||||
if isBeingPressed:
|
||||
emit_signal("buttonReleased")
|
||||
isBeingPressed = false
|
||||
$AnimationPlayer.play_backwards("interact")
|
||||
$Sound.pitch_scale = 1.3
|
||||
$Sound.play()
|
||||
emit_signal("buttonUpdated")
|
||||
|
||||
func _interact_press(is_alt_click: bool = false) -> void:
|
||||
_press()
|
||||
|
||||
func _interact_release() -> void:
|
||||
_release()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if isLoopingUpdate:
|
||||
emit_signal("buttonUpdated")
|
||||
1
Objects/Scripts/IButton.gd.uid
Normal file
1
Objects/Scripts/IButton.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://lc16dii2q86w
|
||||
26
Objects/Scripts/ILed.gd
Normal file
26
Objects/Scripts/ILed.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends Node3D
|
||||
|
||||
var LampMaterial = StandardMaterial3D.new();
|
||||
@export var isLampOn = false;
|
||||
@export_category("Lamp Config")
|
||||
@export var onColor : Color;
|
||||
@export var glowMultiplier : int;
|
||||
|
||||
func _ready() -> void:
|
||||
$Light.material_override = LampMaterial;
|
||||
|
||||
func startGlowing():
|
||||
LampMaterial.emission_enabled = true;
|
||||
LampMaterial.emission = onColor;
|
||||
LampMaterial.emission_energy_multiplier = glowMultiplier
|
||||
|
||||
func stopGlowing():
|
||||
LampMaterial.emission_energy_multiplier = 0.0;
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if isLampOn:
|
||||
LampMaterial.albedo_color = onColor;
|
||||
startGlowing();
|
||||
else:
|
||||
LampMaterial.albedo_color = Color(0.069, 0.069, 0.069, 1.0);
|
||||
stopGlowing();
|
||||
1
Objects/Scripts/ILed.gd.uid
Normal file
1
Objects/Scripts/ILed.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b4i12wekeb7ex
|
||||
45
Objects/Scripts/ISwitch.gd
Normal file
45
Objects/Scripts/ISwitch.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
extends Node
|
||||
|
||||
signal turnedOn
|
||||
signal turnedOff
|
||||
signal switchUpdated
|
||||
|
||||
@export var isOn = false
|
||||
@export var isLoopingUpdate : bool = false
|
||||
@onready var ButtonAnimation = $AnimationPlayer.get_animation("interact")
|
||||
|
||||
func _ready() -> void:
|
||||
ButtonAnimation.loop_mode = Animation.LOOP_NONE
|
||||
# FIX: Look at the saved state before forcing the animation closed!
|
||||
if isOn:
|
||||
$AnimationPlayer.play("interact")
|
||||
# Advance to the end immediately so it doesn't play the visual transition on load
|
||||
$AnimationPlayer.advance(ButtonAnimation.length)
|
||||
else:
|
||||
$AnimationPlayer.play_backwards("interact")
|
||||
|
||||
func _press():
|
||||
if not isOn:
|
||||
isOn = true
|
||||
$AnimationPlayer.play("interact")
|
||||
$Sound.play()
|
||||
emit_signal("turnedOn")
|
||||
emit_signal("switchUpdated")
|
||||
|
||||
func _release():
|
||||
if isOn:
|
||||
isOn = false
|
||||
$AnimationPlayer.play_backwards("interact")
|
||||
$Sound.play()
|
||||
emit_signal("turnedOff")
|
||||
emit_signal("switchUpdated")
|
||||
|
||||
func _interact_press(is_alt_click: bool = false) -> void:
|
||||
if isOn:
|
||||
_release()
|
||||
else:
|
||||
_press()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if isLoopingUpdate:
|
||||
emit_signal("switchUpdated")
|
||||
1
Objects/Scripts/ISwitch.gd.uid
Normal file
1
Objects/Scripts/ISwitch.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bnusj72egf6sw
|
||||
10
Objects/Scripts/SGauge.gd
Normal file
10
Objects/Scripts/SGauge.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends Node3D
|
||||
|
||||
@export var Value : int
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# 1. Remap the value
|
||||
var degree_value: float = remap(Value, 1.0, 100.0, 360.0 - 20, 25)
|
||||
|
||||
# 2. Assign a fresh Vector3 to rotation_degrees
|
||||
$Node3D2.rotation_degrees = Vector3(0.0, degree_value, 0.0)
|
||||
1
Objects/Scripts/SGauge.gd.uid
Normal file
1
Objects/Scripts/SGauge.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://1n13rixvaeqm
|
||||
8
Objects/Scripts/SLabel.gd
Normal file
8
Objects/Scripts/SLabel.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Node3D
|
||||
|
||||
@export var Text : String;
|
||||
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Label3D.text = Text;
|
||||
1
Objects/Scripts/SLabel.gd.uid
Normal file
1
Objects/Scripts/SLabel.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1p6pro5cdj8d
|
||||
9
Objects/Scripts/SUpdate.gd
Normal file
9
Objects/Scripts/SUpdate.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
extends Node3D
|
||||
|
||||
signal castUpdate
|
||||
|
||||
@export var isActive:bool = false;
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if isActive:
|
||||
emit_signal("castUpdate")
|
||||
1
Objects/Scripts/SUpdate.gd.uid
Normal file
1
Objects/Scripts/SUpdate.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://7liu0n270lj0
|
||||
Reference in New Issue
Block a user