33 lines
1.1 KiB
GDScript
33 lines
1.1 KiB
GDScript
extends Node2D
|
|
|
|
|
|
onready var SimpleEntity = preload("res://entities/SimpleEntity.tscn")
|
|
onready var WanderingEntity = preload("res://entities/WanderingEntity.tscn")
|
|
onready var player_movable_target_label = $UI/PlayerMovableTarget
|
|
onready var player = $PlayerEntity
|
|
onready var entities = $Entities
|
|
|
|
signal world_location_clicked
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass
|
|
|
|
|
|
func _process(delta):
|
|
player_movable_target_label.text = str(player.movable_component.target)
|
|
|
|
|
|
func _on_AddEntityButton_pressed():
|
|
var entity_instance = SimpleEntity.instance()
|
|
var viewport_rect = get_viewport_rect()
|
|
entity_instance.transform.origin = Vector2(randf() * viewport_rect.size[0], randf() * viewport_rect.size[1])
|
|
entities.add_child(entity_instance)
|
|
|
|
func _on_AddWanderingEntity_pressed():
|
|
var entity_instance = WanderingEntity.instance()
|
|
var viewport_rect = get_viewport_rect()
|
|
entity_instance.transform.origin = Vector2(randf() * viewport_rect.size[0], randf() * viewport_rect.size[1])
|
|
entities.add_child(entity_instance)
|
|
entity_instance.set_target(Vector2(randf() * viewport_rect.size[0], randf() * viewport_rect.size[1]))
|