|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
-
- using RobocraftX.Common;
- using RobocraftX.Common.Input;
- using RobocraftX.Players;
- using Svelto.ECS;
-
- using GamecraftModdingAPI.Utility;
- using GamecraftModdingAPI.Engines;
-
- namespace GamecraftModdingAPI.Input
- {
- public class FakeInputEngine : IApiEngine
- {
- public string Name { get; } = "GamecraftModdingAPIFakeInputEngine";
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public bool isRemovable => false;
-
- public bool IsReady = false;
-
- public void Dispose()
- {
- IsReady = false;
- }
-
- public void Ready()
- {
- IsReady = true;
- }
-
- public bool SendCustomInput(LocalInputEntityStruct input)
- {
- EGID egid = CommonExclusiveGroups.GameStateEGID;
- if (entitiesDB.Exists<LocalInputEntityStruct>(egid))
- {
- ref LocalInputEntityStruct ies = ref entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
- ies = input;
- return true;
- }
- else return false;
- }
-
- public bool SendCustomPlayerInput(LocalPlayerInputEntityStruct input, uint playerID, bool remote = false)
- {
- EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
- if (entitiesDB.Exists<LocalPlayerInputEntityStruct>(egid))
- {
- ref LocalPlayerInputEntityStruct ies = ref entitiesDB.QueryEntity<LocalPlayerInputEntityStruct>(egid);
- ies = input;
- return true;
- }
- else return false;
- }
-
- public LocalInputEntityStruct GetInput()
- {
- EGID egid = CommonExclusiveGroups.GameStateEGID;
- if (entitiesDB.Exists<LocalInputEntityStruct>(egid))
- {
- return entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
- }
- else return default(LocalInputEntityStruct);
- }
-
- public LocalPlayerInputEntityStruct GetPlayerInput(uint playerID, bool remote = false)
- {
- EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
- if (entitiesDB.Exists<LocalPlayerInputEntityStruct>(egid))
- {
- return entitiesDB.QueryEntity<LocalPlayerInputEntityStruct>(egid);
- }
- else return default;
- }
-
- public ref LocalInputEntityStruct GetInputRef()
- {
- EGID egid = CommonExclusiveGroups.GameStateEGID;
- return ref entitiesDB.QueryEntity<LocalInputEntityStruct>(egid);
- }
-
- public ref LocalPlayerInputEntityStruct GetPlayerInputRef(uint playerID, bool remote = false)
- {
- EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers);
- return ref entitiesDB.QueryEntity<LocalPlayerInputEntityStruct>(egid);
- }
-
- public uint GetLocalPlayerID()
- {
- return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB);
- }
- }
- }
|