wip:FX if released mode accessible
This commit is contained in:
parent
c91284051c
commit
57d6b3f607
1 changed files with 9 additions and 2 deletions
|
@ -36,7 +36,7 @@ class_name Sticker extends Area2D
|
||||||
var meta:PackedStringArray = ["sticker"]
|
var meta:PackedStringArray = ["sticker"]
|
||||||
var detected_solids:Array
|
var detected_solids:Array
|
||||||
var detected_zones:Array
|
var detected_zones:Array
|
||||||
|
var Grabbed:bool = false
|
||||||
|
|
||||||
#region Functions
|
#region Functions
|
||||||
func _get_configuration_warnings():
|
func _get_configuration_warnings():
|
||||||
|
@ -84,6 +84,8 @@ func _on_body_entered(body:Node2D):
|
||||||
func _on_body_exited(body:Node2D):
|
func _on_body_exited(body:Node2D):
|
||||||
print("body exited",body)
|
print("body exited",body)
|
||||||
detected_solids.erase(body)
|
detected_solids.erase(body)
|
||||||
|
if(Sticker_mode and Grabbed and detected_solids.size() == 0):
|
||||||
|
print("Can be released in object mode")
|
||||||
func _on_area_entered(area:Area2D):
|
func _on_area_entered(area:Area2D):
|
||||||
print("area entered",area)
|
print("area entered",area)
|
||||||
#TODO:Filter by type
|
#TODO:Filter by type
|
||||||
|
@ -94,18 +96,21 @@ func _on_area_exited(area:Area2D):
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
## When the sticker is released
|
## When the sticker is released
|
||||||
func on_released(_CastResult:Array=[]):
|
func on_released(_CastResult:Array=[]):
|
||||||
print(self," released")
|
print(self," released")
|
||||||
|
Grabbed = false
|
||||||
#Need a traceresult to know if it should stay in the stickerstate or be released in the world
|
#Need a traceresult to know if it should stay in the stickerstate or be released in the world
|
||||||
if(detected_solids.size()==0):
|
if(detected_solids.size()==0):
|
||||||
get_parent().top_level = false
|
get_parent().top_level = false
|
||||||
disable_ChildNodes_collisions(false)
|
disable_ChildNodes_collisions(false)
|
||||||
update_ChildNodes_visibilty(true)
|
update_ChildNodes_visibilty(true)
|
||||||
Sticker_mode = false
|
Sticker_mode = false
|
||||||
on_unhover() #security
|
on_unhover() #security,but i don't like it
|
||||||
get_parent().reparent(MapManager.current_scene.get_child(0))
|
get_parent().reparent(MapManager.current_scene.get_child(0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func on_click():
|
func on_click():
|
||||||
|
@ -139,10 +144,12 @@ func on_unhover():
|
||||||
|
|
||||||
func on_grab(_offset:Vector2=Vector2(0.0,0.0)):
|
func on_grab(_offset:Vector2=Vector2(0.0,0.0)):
|
||||||
Sticker_mode = true
|
Sticker_mode = true
|
||||||
|
|
||||||
get_parent().top_level = true
|
get_parent().top_level = true
|
||||||
get_parent().reparent(MapManager)
|
get_parent().reparent(MapManager)
|
||||||
update_ChildNodes_visibilty(false)
|
update_ChildNodes_visibilty(false)
|
||||||
disable_ChildNodes_collisions(true)
|
disable_ChildNodes_collisions(true)
|
||||||
|
Grabbed = true
|
||||||
|
|
||||||
func update_ChildNodes_visibilty(_visible:bool=true):
|
func update_ChildNodes_visibilty(_visible:bool=true):
|
||||||
for _childNode in get_parent().get_children():
|
for _childNode in get_parent().get_children():
|
||||||
|
|
Loading…
Reference in a new issue