62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System;
|
|
|
|
using RobocraftX.Common.Input;
|
|
using RobocraftX.Players;
|
|
using Svelto.ECS;
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
namespace GamecraftModdingAPI.Input
|
|
{
|
|
public class FakeInputEngine : IApiEngine
|
|
{
|
|
public string Name { get; } = "GamecraftModdingAPIFakeInputEngine";
|
|
|
|
public EntitiesDB entitiesDB { set; private get; }
|
|
|
|
public bool IsReady = false;
|
|
|
|
public void Dispose()
|
|
{
|
|
IsReady = false;
|
|
}
|
|
|
|
public void Ready()
|
|
{
|
|
IsReady = true;
|
|
}
|
|
|
|
public bool SendCustomInput(InputEntityStruct input, uint playerID, bool remote = false)
|
|
{
|
|
EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
|
|
if (entitiesDB.Exists<InputEntityStruct>(egid))
|
|
{
|
|
ref InputEntityStruct ies = ref entitiesDB.QueryEntity<InputEntityStruct>(egid);
|
|
ies = input;
|
|
return true;
|
|
}
|
|
else return false;
|
|
}
|
|
|
|
public InputEntityStruct GetInput(uint playerID, bool remote = false)
|
|
{
|
|
EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
|
|
if (entitiesDB.Exists<InputEntityStruct>(egid))
|
|
{
|
|
return entitiesDB.QueryEntity<InputEntityStruct>(egid);
|
|
}
|
|
else return default(InputEntityStruct);
|
|
}
|
|
|
|
public ref InputEntityStruct GetInputRef(uint playerID, bool remote = false)
|
|
{
|
|
EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
|
|
return ref entitiesDB.QueryEntity<InputEntityStruct>(egid);
|
|
}
|
|
|
|
public uint GetLocalPlayerID()
|
|
{
|
|
return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
|
|
}
|
|
}
|
|
}
|