You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/GameEntity/Entities/TrashEntity.cs

34 lines
1022 B

using Babushka.scripts.CSharp.GameEntity.EntityNodes;
using Babushka.scripts.CSharp.GameEntity.Management;
using Godot;
namespace Babushka.scripts.CSharp.GameEntity.Entities;
public class TrashEntity : PositionalEntity
{
public override string EntityType => OWN_TYPE_NAME;
public const string OWN_TYPE_NAME = "TrashEntity";
private EntityNodeCreator _creator;
private TrashEntityNode? _entityNode;
public TrashEntity()
{
}
public override void InstantiateEntityNode(Node2D parent)
{
if (_creator == null) _creator = EntityManager.Instance.NodeCreator;
var entityNode = _creator.InstantiateNode(EntityType);
parent.AddChild(entityNode);
entityNode.GlobalPosition = position;
var trashEntityNode = (TrashEntityNode)entityNode;
trashEntityNode.Initialize(this);
_entityNode = trashEntityNode;
}
public override void RemoveEntityNode()
{
if(_entityNode.IsValid())
_entityNode!.QueueFree();
}
}