WutheringWaves/GameServer/Models/ModelManager.cs
2024-02-10 19:04:03 +03:00

20 lines
747 B
C#

using GameServer.Controllers.Attributes;
using GameServer.Systems.Event;
namespace GameServer.Models;
internal class ModelManager
{
private PlayerModel? _playerModel;
private CreatureModel? _creatureModel;
[GameEvent(GameEventType.Login)]
public void OnLogin()
{
_playerModel = PlayerModel.CreateDefaultPlayer();
_creatureModel = new CreatureModel(_playerModel.Id);
}
public PlayerModel Player => _playerModel ?? throw new InvalidOperationException($"Trying to access {nameof(PlayerModel)} instance before initialization!");
public CreatureModel Creature => _creatureModel ?? throw new InvalidOperationException($"Trying to access {nameof(CreatureModel)} instance before initialization!");
}