Add initial resource and presenter classes for game entities and effects

This commit is contained in:
2025-10-13 12:11:50 +02:00
commit ad3e631d8c
75 changed files with 1423 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
using CryptonymThunder.Code.Extensions;
using GameCore.ECS;
using GameCore.ECS.Interfaces;
using GameCore.Input;
using GameCore.Movement;
using Godot;
namespace CryptonymThunder.Code.Presenters;
[GlobalClass]
public partial class CameraPresenterComponent : Node3D, IPresenterComponent
{
private Entity _coreEntity;
private World _world;
private Camera3D _camera;
private RotationComponent _rotationComponent;
private bool _cursorLocked = true;
public void Initialize(Entity coreEntity, World world)
{
_coreEntity = coreEntity;
_world = world;
_rotationComponent = _world.GetComponent<RotationComponent>(_coreEntity);
_camera = GetNode<Camera3D>("Camera3D");
if (_cursorLocked) Input.MouseMode = Input.MouseModeEnum.Captured;
}
public void SyncToPresentation(float delta)
{
if (_rotationComponent == null || _camera == null) return;
var coreRotation = _rotationComponent.Rotation;
_camera.Rotation = new Vector3(coreRotation.X, 0f, 0f);
}
public void SyncToCore(float delta)
{
}
public override void _Input(InputEvent @event)
{
if (Input.IsActionJustPressed("ui_cancel"))
{
if (_cursorLocked)
{
Input.MouseMode = Input.MouseModeEnum.Visible;
_cursorLocked = false;
}
else
{
Input.MouseMode = Input.MouseModeEnum.Captured;
_cursorLocked = true;
}
}
}
}