43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using CryptonymThunder.Code.Resources;
|
|
using GameCore.ECS;
|
|
using GameCore.ECS.Interfaces;
|
|
using GameCore.Interaction;
|
|
using Godot;
|
|
|
|
namespace CryptonymThunder.Code.Presenters;
|
|
|
|
[GlobalClass]
|
|
public partial class DoorPresenter : CharacterBody3D, IEntityPresenter, IPresenterComponent
|
|
{
|
|
[Export] private DoorBehaviorResource _behavior;
|
|
|
|
private DoorComponent _doorComponent;
|
|
|
|
public Entity CoreEntity { get; set; }
|
|
|
|
public void Initialize(Entity coreEntity, World world)
|
|
{
|
|
CoreEntity = coreEntity;
|
|
_doorComponent = world.GetComponent<DoorComponent>(CoreEntity);
|
|
|
|
if (_behavior == null)
|
|
{
|
|
world.Logger.Error($"DoorPresenter '{Name}' is missing a DoorBehaviorResource!");
|
|
return;
|
|
}
|
|
|
|
_behavior.Initialize(this, world);
|
|
|
|
SyncToPresentation(0f);
|
|
}
|
|
|
|
public void SyncToPresentation(float delta)
|
|
{
|
|
if (_doorComponent == null || _behavior == null) return;
|
|
_behavior.UpdateProgress(_doorComponent.OpenProgress, delta);
|
|
}
|
|
|
|
public void SyncToCore(float delta)
|
|
{
|
|
}
|
|
} |