rework core hierarchy

This commit is contained in:
Lucas 2024-07-29 15:24:09 +02:00
parent 05f607aafe
commit a91cb2c306
5 changed files with 32 additions and 18 deletions

View file

@ -29,28 +29,18 @@ func _process(_delta):
#endregion
pointcast()
cursor_look()
if (grabbedSticker):
if (grabbedSticker != null):
grabbedSticker.position = grabbedStickerOffset+get_global_mouse_position()
func isSticker(selectedObject:Node):
var _isSticker:bool = false
var _tags = getTags(selectedObject)
var _tags = Global.getTags(selectedObject)
if (_tags.size() > 0):
if (_tags.find("sticker") != -1):
_isSticker = true
return _isSticker
func getTags(selectedObject:Node):
var _tags: Array
if (selectedObject.has_meta("tags")):
_tags = selectedObject.get_meta("tags")
return _tags
else:
printerr("no tags inside %",selectedObject)
return _tags
func pointcast():
resetCast()
@ -117,7 +107,7 @@ func _input(rawInputEvent:InputEvent):
$GrabTimer.start()
if (rawInputEvent.is_action_released("select")):
$GrabTimer.stop()
if (grabbedSticker):
if (grabbedSticker != null):
grab_end()
func grab_start():
@ -148,11 +138,11 @@ func cursor_look():
if (grabbedSticker ):
currentCursorState = CURSOR_STATE.GRABBED
elif (hoveredSticker):
if (!($GrabTimer.is_stopped())):
if ($GrabTimer and !($GrabTimer.is_stopped())):
currentCursorState = CURSOR_STATE.GRABBED
else:
currentCursorState = CURSOR_STATE.GRAB
elif (!($GrabTimer.is_stopped())):
elif ($GrabTimer and !($GrabTimer.is_stopped())):
currentCursorState = CURSOR_STATE.CLICK
else:
currentCursorState = CURSOR_STATE.DEFAULT

View file

@ -12,7 +12,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(_delta):
pass

21
core/global.gd Normal file
View file

@ -0,0 +1,21 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func getTags(selectedObject:Node):
var _tags: Array
if (selectedObject.has_meta("tags")):
_tags = selectedObject.get_meta("tags")
return _tags
else:
printerr("no tags inside %",selectedObject)
return _tags

View file

@ -48,6 +48,6 @@ func get_input():
$AnimationTree.set("parameters/WalkRun/blend_position",max(abs(velocity.x),abs(velocity.y)))
#endregion
func _physics_process(delta):
func _physics_process(_delta):
get_input()
move_and_slide()

View file

@ -12,12 +12,15 @@ config_version=5
config/name="StickerClone"
config/version="0.1"
run/main_scene="res://maps/mapManager.tscn"
run/main_scene="res://maps/mainMenu.tscn"
config/features=PackedStringArray("4.2", "Mobile")
[autoload]
DebugDraw="*res://core/debugDraw.tscn"
Global="*res://core/global.gd"
MapManager="*res://maps/mapManager.tscn"
Cursor="*res://core/Cursor.tscn"
[editor_plugins]