basic selection
still WIP
This commit is contained in:
parent
be0ee4408b
commit
c1e6d8e85e
2 changed files with 33 additions and 0 deletions
32
core/scripts/entity.gd
Normal file
32
core/scripts/entity.gd
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
extends Node3D
|
||||||
|
class_name Entity
|
||||||
|
|
||||||
|
|
||||||
|
## Base entity class for everything interactive.
|
||||||
|
##
|
||||||
|
## Should be the parent of every units, buildings,
|
||||||
|
## npc, loot, and everything that the player can interact with in 3D
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
add_to_group('selectable')
|
||||||
|
|
||||||
|
|
||||||
|
## Check if the entity is contained in the [Rect2] [param selection_box] of the player.
|
||||||
|
## Need the [Camera3D] of the player to work
|
||||||
|
func is_in_selection(selection_box:Rect2,player_cam:Camera3D):
|
||||||
|
var p = player_cam.unproject_position(global_position)
|
||||||
|
if min(selection_box.size.x,selection_box.size.y) <0:
|
||||||
|
breakpoint
|
||||||
|
|
||||||
|
return selection_box.has_point(p)
|
||||||
|
|
||||||
|
|
||||||
|
func select():
|
||||||
|
add_to_group('selected-by-'+str(get_tree().get_multiplayer().get_unique_id()))
|
||||||
|
print(self.name," selected")
|
||||||
|
|
||||||
|
|
||||||
|
func deselect():
|
||||||
|
remove_from_group('selected-by-'+str(get_tree().get_multiplayer().get_unique_id()))
|
||||||
|
print(self.name," unselected")
|
1
core/scripts/entity.gd.uid
Normal file
1
core/scripts/entity.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://b8p60y4eo8w2n
|
Loading…
Reference in a new issue