mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Added game manager net object and logic classes
This commit is contained in:
1 parent
e0b85c959b
commit
d4ac24ae17
26 files changed
+419
No files matched your search
@@ -0,0 +1,6 @@
|
||||
namespace Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
|
||||
public interface IInnerGameManager
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
|
||||
internal interface IInnerHideAndSeekManager
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
|
||||
public interface IInnerNormalGameManager
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Impostor.Api.Net;
|
||||
using Impostor.Api.Net.Custom;
|
||||
using Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
using Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
using Impostor.Server.Net.State;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager;
|
||||
|
||||
internal abstract class InnerGameManager : InnerNetObject, IInnerGameManager
|
||||
{
|
||||
private readonly ILogger<InnerGameManager> _logger;
|
||||
|
||||
public InnerGameManager(ICustomMessageManager<ICustomRpc> customMessageManager, Game game, ILogger<InnerGameManager> logger) : base(customMessageManager, game)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
Components.Add(this);
|
||||
}
|
||||
|
||||
protected readonly List<GameLogicComponent> LogicComponents = new();
|
||||
|
||||
public LogicGameFlow LogicFlow { get; protected init; } = null!;
|
||||
|
||||
public LogicMinigame LogicMinigame { get; protected init; } = null!;
|
||||
|
||||
public LogicRoleSelection LogicRoleSelection { get; protected init; } = null!;
|
||||
|
||||
public LogicUsables LogicUsables { get; protected init; } = null!;
|
||||
|
||||
public LogicOptions LogicOptions { get; protected init; } = null!;
|
||||
|
||||
protected T AddGameLogic<T>(T logic)
|
||||
where T : GameLogicComponent
|
||||
{
|
||||
LogicComponents.Add(logic);
|
||||
return logic;
|
||||
}
|
||||
|
||||
public override ValueTask<bool> SerializeAsync(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override ValueTask DeserializeAsync(IClientPlayer sender, IClientPlayer? target, IMessageReader reader, bool initialState)
|
||||
{
|
||||
while (reader.Position < reader.Length)
|
||||
{
|
||||
var innerReader = reader.ReadMessage();
|
||||
var tag = (int)innerReader.Tag;
|
||||
if (tag < 0 || tag > this.LogicComponents.Count)
|
||||
{
|
||||
_logger.LogError("Out of bounds in DeserializeAsync of InnerGameManager");
|
||||
continue;
|
||||
}
|
||||
|
||||
this.LogicComponents[tag].Deserialize(innerReader, initialState);
|
||||
}
|
||||
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Impostor.Api.Net.Custom;
|
||||
using Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
using Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
using Impostor.Server.Net.State;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager;
|
||||
|
||||
internal class InnerHideAndSeekManager : InnerGameManager, IInnerHideAndSeekManager
|
||||
{
|
||||
public InnerHideAndSeekManager(ICustomMessageManager<ICustomRpc> customMessageManager, Game game, ILogger<InnerGameManager> logger) : base(customMessageManager, game, logger)
|
||||
{
|
||||
LogicMusic = AddGameLogic(new LogicHnSMusic(this));
|
||||
LogicMinigame = AddGameLogic(new LogicMinigameHnS(this));
|
||||
LogicFlowHnS = new LogicGameFlowHnS(this);
|
||||
LogicFlow = AddGameLogic(LogicFlowHnS);
|
||||
LogicUsables = AddGameLogic(new LogicUsablesHnS());
|
||||
LogicRoleSelection = AddGameLogic(new LogicRoleSelectionHnS(this));
|
||||
LogicOptionsHnS = new LogicOptionsHnS(this, game);
|
||||
LogicOptions = AddGameLogic(this.LogicOptionsHnS);
|
||||
LogicDangerLevel = AddGameLogic(new LogicHnSDangerLevel(this));
|
||||
LogicPing = AddGameLogic(new LogicPingsHnS(this));
|
||||
LogicDeathPopup = AddGameLogic(new LogicHnSDeathPopup(this));
|
||||
}
|
||||
|
||||
public LogicHnSMusic LogicMusic { get; private set; }
|
||||
|
||||
public LogicGameFlowHnS LogicFlowHnS { get; private set; }
|
||||
|
||||
public LogicOptionsHnS LogicOptionsHnS { get; private set; }
|
||||
|
||||
public LogicHnSDangerLevel LogicDangerLevel { get; private set; }
|
||||
|
||||
public LogicPingsHnS LogicPing { get; private set; }
|
||||
|
||||
public LogicHnSDeathPopup LogicDeathPopup { get; private set; }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Impostor.Api.Net.Custom;
|
||||
using Impostor.Api.Net.Inner.Objects.GameManager;
|
||||
using Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
using Impostor.Server.Net.Inner.Objects.GameManager.Logic.Normal;
|
||||
using Impostor.Server.Net.State;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager;
|
||||
|
||||
internal class InnerNormalGameManager : InnerGameManager, IInnerNormalGameManager
|
||||
{
|
||||
public InnerNormalGameManager(ICustomMessageManager<ICustomRpc> customMessageManager, Game game, ILogger<InnerGameManager> logger) : base(customMessageManager, game, logger)
|
||||
{
|
||||
LogicFlow = AddGameLogic(new LogicGameFlowNormal(this));
|
||||
LogicMinigame = AddGameLogic(new LogicMinigame(this));
|
||||
LogicRoleSelection = AddGameLogic(new LogicRoleSelectionNormal(this));
|
||||
LogicUsables = AddGameLogic(new LogicUsablesBasic(this));
|
||||
LogicOptions = AddGameLogic(new LogicOptionsNormal(this, game));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Impostor.Api.Net.Inner;
|
||||
using Impostor.Api.Net.Inner.Objects;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal abstract class GameLogicComponent
|
||||
{
|
||||
public virtual void OnPlayerDisconnect(IInnerPlayerControl pc)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void HandleRPC(RpcCalls callId, IMessageReader reader)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract bool Serialize(IMessageWriter writer, bool initialState);
|
||||
|
||||
public abstract void Deserialize(IMessageReader reader, bool initialState);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicGameFlowHnS : LogicGameFlow
|
||||
{
|
||||
private float currentFinalHideTime;
|
||||
private float currentHideTime;
|
||||
|
||||
public LogicGameFlowHnS(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
var num = reader.ReadSingle();
|
||||
|
||||
currentFinalHideTime = reader.ReadSingle();
|
||||
currentHideTime = num;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicHnSDangerLevel : GameLogicComponent
|
||||
{
|
||||
public LogicHnSDangerLevel(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicHnSDeathPopup : GameLogicComponent
|
||||
{
|
||||
public LogicHnSDeathPopup(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicHnSMusic : GameLogicComponent
|
||||
{
|
||||
public LogicHnSMusic(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicMinigameHnS : LogicMinigame
|
||||
{
|
||||
public LogicMinigameHnS(InnerHideAndSeekManager gameManager) : base(gameManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using Impostor.Server.Net.State;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicOptionsHnS : LogicOptions
|
||||
{
|
||||
public LogicOptionsHnS(InnerHideAndSeekManager gameManager, Game game) : base(game)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicPingsHnS : GameLogicComponent
|
||||
{
|
||||
public LogicPingsHnS(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicRoleSelectionHnS : LogicRoleSelection
|
||||
{
|
||||
public LogicRoleSelectionHnS(InnerHideAndSeekManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.HideAndSeek;
|
||||
|
||||
internal class LogicUsablesHnS : LogicUsables
|
||||
{
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal abstract class LogicGameFlow : GameLogicComponent
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal class LogicMinigame : GameLogicComponent
|
||||
{
|
||||
public LogicMinigame(InnerGameManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Impostor.Api.Innersloth.GameOptions;
|
||||
using Impostor.Server.Net.State;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal abstract class LogicOptions : GameLogicComponent
|
||||
{
|
||||
private readonly Game _game;
|
||||
|
||||
protected LogicOptions(Game game)
|
||||
{
|
||||
_game = game;
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
GameOptionsFactory.Serialize(writer, _game.Options);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
var options = GameOptionsFactory.Deserialize(reader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal abstract class LogicRoleSelection : GameLogicComponent
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
|
||||
|
||||
internal abstract class LogicUsables : GameLogicComponent
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.Normal;
|
||||
|
||||
internal class LogicGameFlowNormal : LogicGameFlow
|
||||
{
|
||||
public LogicGameFlowNormal(InnerNormalGameManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Impostor.Server.Net.State;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.Normal;
|
||||
|
||||
internal class LogicOptionsNormal : LogicOptions
|
||||
{
|
||||
public LogicOptionsNormal(InnerNormalGameManager gameManager, Game game) : base(game)
|
||||
{
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.Normal;
|
||||
|
||||
internal class LogicRoleSelectionNormal : LogicRoleSelection
|
||||
{
|
||||
public LogicRoleSelectionNormal(InnerNormalGameManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic.Normal;
|
||||
|
||||
internal class LogicUsablesBasic : LogicUsables
|
||||
{
|
||||
public LogicUsablesBasic(InnerNormalGameManager gameManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Serialize(IMessageWriter writer, bool initialState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Deserialize(IMessageReader reader, bool initialState)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Impostor.Server.Events.Player;
|
||||
using Impostor.Server.Net.Inner;
|
||||
using Impostor.Server.Net.Inner.Objects;
|
||||
using Impostor.Server.Net.Inner.Objects.Components;
|
||||
using Impostor.Server.Net.Inner.Objects.GameManager;
|
||||
using Impostor.Server.Net.Inner.Objects.ShipStatus;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -40,6 +41,8 @@ namespace Impostor.Server.Net.State
|
||||
typeof(InnerPolusShipStatus),
|
||||
typeof(InnerSkeldShipStatus), // April fools skeld
|
||||
typeof(InnerAirshipStatus),
|
||||
typeof(InnerHideAndSeekManager),
|
||||
typeof(InnerNormalGameManager),
|
||||
};
|
||||
|
||||
private readonly List<InnerNetObject> _allObjects = new List<InnerNetObject>();
|
||||
|
||||
Reference in new issue
Block a user