Interlocking doors
This commit is contained in:
parent
ff4767f473
commit
2e8ed847c9
4 changed files with 98 additions and 23 deletions
|
@ -2,17 +2,24 @@ extends StaticBody2D
|
||||||
|
|
||||||
class_name GameObjectDoor
|
class_name GameObjectDoor
|
||||||
|
|
||||||
|
export(NodePath) var interlockTargetPath
|
||||||
|
var interlockTarget: GameObjectDoor = null
|
||||||
|
|
||||||
onready var activationRange = $ActivationRange as ActivationRange
|
onready var activationRange = $ActivationRange as ActivationRange
|
||||||
|
|
||||||
signal changed(open)
|
signal changed(open)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
if interlockTargetPath != null:
|
||||||
|
interlockTarget = get_node_or_null(interlockTargetPath)
|
||||||
if not Engine.editor_hint:
|
if not Engine.editor_hint:
|
||||||
activationRange.visible = true
|
activationRange.visible = true
|
||||||
|
|
||||||
func set_open(open: bool):
|
func set_open(open: bool):
|
||||||
if open:
|
if open:
|
||||||
$Sprite.play("open")
|
$Sprite.play("open")
|
||||||
|
if interlockTarget != null:
|
||||||
|
interlockTarget.set_open(false)
|
||||||
else:
|
else:
|
||||||
$Sprite.play("close")
|
$Sprite.play("close")
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ func refresh_sprite():
|
||||||
rot = PI
|
rot = PI
|
||||||
Direction.LEFT:
|
Direction.LEFT:
|
||||||
$light.region_rect.position = Vector2(96, lit_offset)
|
$light.region_rect.position = Vector2(96, lit_offset)
|
||||||
rot = PI/2
|
rot = -PI/2
|
||||||
Direction.RIGHT:
|
Direction.RIGHT:
|
||||||
$light.region_rect.position = Vector2(64, lit_offset)
|
$light.region_rect.position = Vector2(64, lit_offset)
|
||||||
rot = -PI/2
|
rot = PI/2
|
||||||
$Light2D.rotation = rot
|
$Light2D.rotation = rot
|
||||||
$ActivationRange.rotation = rot
|
$ActivationRange.rotation = rot
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ region_rect = Rect2( 32, 0, 32, 32 )
|
||||||
|
|
||||||
[node name="Light2D" type="Light2D" parent="."]
|
[node name="Light2D" type="Light2D" parent="."]
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
offset = Vector2( 0, -10 )
|
|
||||||
texture_scale = 3.5
|
texture_scale = 3.5
|
||||||
energy = 1.2
|
energy = 1.2
|
||||||
mode = 2
|
mode = 2
|
||||||
|
|
File diff suppressed because one or more lines are too long
Reference in a new issue