Make Vesna entity save current position
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Babushka.scripts.CSharp.Common.Services;
|
||||
using Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
@@ -8,6 +9,14 @@ public partial class PlayerMovement : CharacterBody2D
|
||||
[Export] private float _speed = 1000f;
|
||||
[Export] private Timer _stepTimer;
|
||||
|
||||
private PositionalEntity _entity;
|
||||
|
||||
public void Initialize(PositionalEntity entity)
|
||||
{
|
||||
_entity = entity;
|
||||
GlobalPosition = entity.position;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
bool anyActionPressed = false;
|
||||
@@ -76,6 +85,7 @@ public partial class PlayerMovement : CharacterBody2D
|
||||
|
||||
Velocity = currentVelocity;
|
||||
MoveAndSlide();
|
||||
_entity.position = GlobalPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ public class VesnaEntity : PositionalEntity
|
||||
public override void InstantiateEntityNode(Node2D parent)
|
||||
{
|
||||
var node = (VesnaBehaviour2D) EntityManager.Instance.NodeCreator.InstantiateNode(OWN_TYPE_NAME);
|
||||
node.player2d.GlobalPosition = position;
|
||||
node.player2d.Initialize(this);
|
||||
parent.AddChild(node);
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public partial class EntityManager : Node
|
||||
{
|
||||
TrashEntity.OWN_TYPE_NAME => new TrashEntity(),
|
||||
LoadedScenesEntity.OWN_TYPE_NAME => new LoadedScenesEntity(),
|
||||
VesnaEntity.OWN_TYPE_NAME => new VesnaEntity(),
|
||||
_ => throw new Exception($"Trying to load unknown entity type: {type}")
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user