Add initial resource and presenter classes for game entities and effects
This commit is contained in:
25
Code/Autoloads/PresenterRegistry.cs
Normal file
25
Code/Autoloads/PresenterRegistry.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using GameCore.ECS;
|
||||
using Godot;
|
||||
|
||||
namespace CryptonymThunder.Code.Autoloads;
|
||||
|
||||
public partial class PresenterRegistry : Node
|
||||
{
|
||||
private readonly Dictionary<ulong, Entity> _instanceIdToEntity = new();
|
||||
|
||||
public void RegisterPresenter(Node presenterNode, Entity entity)
|
||||
{
|
||||
_instanceIdToEntity[presenterNode.GetInstanceId()] = entity;
|
||||
}
|
||||
|
||||
public void UnregisterPresenter(Node presenterNode)
|
||||
{
|
||||
_instanceIdToEntity.Remove(presenterNode.GetInstanceId());
|
||||
}
|
||||
|
||||
public bool TryGetEntity(ulong instanceId, out Entity entity)
|
||||
{
|
||||
return _instanceIdToEntity.TryGetValue(instanceId, out entity);
|
||||
}
|
||||
}
|
||||
1
Code/Autoloads/PresenterRegistry.cs.uid
Normal file
1
Code/Autoloads/PresenterRegistry.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://5twln2ckxjj8
|
||||
Reference in New Issue
Block a user