From 3cb50a691881a6b74e36582ae0cd4a7a85e75503 Mon Sep 17 00:00:00 2001 From: RevenantX Date: Tue, 19 Nov 2024 19:01:52 +0200 Subject: [PATCH] store controller actual (on ReadInput) input as variable (HumanControllerLogic.CurrentInput). update docs. Check for HumanControllerLogic instead of ControllerLogic in AddController --- LiteEntitySystem/HumanControllerLogic.cs | 5 ++ LiteEntitySystem/InputProcessor.cs | 3 +- LiteEntitySystem/LiteEntitySystem.csproj | 1 + LiteEntitySystem/ServerEntityManager.cs | 4 +- ...teEntitySystem.HumanControllerLogic-1.html | 26 ++++++++++ ...teEntitySystem.HumanControllerLogic-2.html | 3 ++ .../LiteEntitySystem.ServerEntityManager.html | 10 ++-- docs/xrefmap.yml | 49 +++++++++++++------ 8 files changed, 77 insertions(+), 24 deletions(-) diff --git a/LiteEntitySystem/HumanControllerLogic.cs b/LiteEntitySystem/HumanControllerLogic.cs index 9e49895..e60b46b 100644 --- a/LiteEntitySystem/HumanControllerLogic.cs +++ b/LiteEntitySystem/HumanControllerLogic.cs @@ -182,6 +182,11 @@ public ServerResponse(ushort requestId, bool success) private static RemoteCall _serverResponseRpc; private ushort _requestId; private readonly Dictionary> _awaitingRequests; + + /// + /// Input that created by ReadInput before all entity updates + /// + public TInput CurrentInput { get; internal set; } /// /// Get player that uses this controller diff --git a/LiteEntitySystem/InputProcessor.cs b/LiteEntitySystem/InputProcessor.cs index 39ca6c9..509131c 100644 --- a/LiteEntitySystem/InputProcessor.cs +++ b/LiteEntitySystem/InputProcessor.cs @@ -95,6 +95,7 @@ public override void ReadInput(EntityManager manager, byte ownerId, ReadOnlySpan { if(controller.InternalOwnerId.Value != ownerId) continue; + controller.CurrentInput = *(TInput*)rawData; controller.ReadInput(*(TInput*)rawData); return; } @@ -114,7 +115,7 @@ public override void GenerateAndWriteInput(EntityManager manager, byte ownerId, return; } //if no controller just put zeroes for simplicity - *(TInput*)(rawData + offset) = default(TInput); + *(TInput*)(rawData + offset) = default; } } diff --git a/LiteEntitySystem/LiteEntitySystem.csproj b/LiteEntitySystem/LiteEntitySystem.csproj index 1fc22b1..ebadc7a 100644 --- a/LiteEntitySystem/LiteEntitySystem.csproj +++ b/LiteEntitySystem/LiteEntitySystem.csproj @@ -13,6 +13,7 @@ LiteEntitySystem Pure C# HighLevel API for multiplayer games using .NET Standard 2.1 README.md + 1.0.1 diff --git a/LiteEntitySystem/ServerEntityManager.cs b/LiteEntitySystem/ServerEntityManager.cs index 0d86033..831e32f 100644 --- a/LiteEntitySystem/ServerEntityManager.cs +++ b/LiteEntitySystem/ServerEntityManager.cs @@ -214,7 +214,7 @@ public HumanControllerLogic GetPlayerController(NetPlayer player) /// Method that will be called after entity construction /// Entity type /// Created entity or null in case of limit - public T AddController(NetPlayer owner, Action initMethod = null) where T : ControllerLogic => + public T AddController(NetPlayer owner, Action initMethod = null) where T : HumanControllerLogic => Add(ent => { ent.InternalOwnerId.Value = owner.Id; @@ -229,7 +229,7 @@ public T AddController(NetPlayer owner, Action initMethod = null) where T /// Method that will be called after entity construction /// Entity type /// Created entity or null in case of limit - public T AddController(NetPlayer owner, PawnLogic entityToControl, Action initMethod = null) where T : ControllerLogic => + public T AddController(NetPlayer owner, PawnLogic entityToControl, Action initMethod = null) where T : HumanControllerLogic => Add(ent => { ent.InternalOwnerId.Value = owner.Id; diff --git a/docs/api/LiteEntitySystem.HumanControllerLogic-1.html b/docs/api/LiteEntitySystem.HumanControllerLogic-1.html index a1699b4..aa717ae 100644 --- a/docs/api/LiteEntitySystem.HumanControllerLogic-1.html +++ b/docs/api/LiteEntitySystem.HumanControllerLogic-1.html @@ -286,6 +286,32 @@

Properties

+ +

CurrentInput

+

Input that created by ReadInput before all entity updates

+
+
+
Declaration
+
+
public TInput CurrentInput { get; }
+
+
Property Value
+ + + + + + + + + + + + + +
TypeDescription
TInput
+ +

IsBot

Is controller - AI controller

diff --git a/docs/api/LiteEntitySystem.HumanControllerLogic-2.html b/docs/api/LiteEntitySystem.HumanControllerLogic-2.html index 3eddaa7..95b3f7d 100644 --- a/docs/api/LiteEntitySystem.HumanControllerLogic-2.html +++ b/docs/api/LiteEntitySystem.HumanControllerLogic-2.html @@ -102,6 +102,9 @@
Inherited Members
+ diff --git a/docs/api/LiteEntitySystem.ServerEntityManager.html b/docs/api/LiteEntitySystem.ServerEntityManager.html index 49b4517..08e518d 100644 --- a/docs/api/LiteEntitySystem.ServerEntityManager.html +++ b/docs/api/LiteEntitySystem.ServerEntityManager.html @@ -431,7 +431,7 @@

Declaration
-
public T AddController<T>(NetPlayer owner, PawnLogic entityToControl, Action<T> initMethod = null) where T : ControllerLogic
+
public T AddController<T>(NetPlayer owner, PawnLogic entityToControl, Action<T> initMethod = null) where T : HumanControllerLogic
Parameters
@@ -504,7 +504,7 @@

Declaration
-
public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T : ControllerLogic
+
public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T : HumanControllerLogic
Parameters
@@ -737,14 +737,14 @@
Returns
- -

AddSignleton<T>(Action<T>)

+ +

AddSingleton<T>(Action<T>)

Add new entity

Declaration
-
public T AddSignleton<T>(Action<T> initMethod = null) where T : SingletonEntityLogic
+
public T AddSingleton<T>(Action<T> initMethod = null) where T : SingletonEntityLogic
Parameters
diff --git a/docs/xrefmap.yml b/docs/xrefmap.yml index 8914371..68b2d80 100644 --- a/docs/xrefmap.yml +++ b/docs/xrefmap.yml @@ -5004,6 +5004,23 @@ references: fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).New nameWithType: HumanControllerLogic.HumanControllerLogic nameWithType.vb: HumanControllerLogic(Of TInput).New +- uid: LiteEntitySystem.HumanControllerLogic`1.CurrentInput + name: CurrentInput + href: api/LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_CurrentInput + commentId: P:LiteEntitySystem.HumanControllerLogic`1.CurrentInput + fullName: LiteEntitySystem.HumanControllerLogic.CurrentInput + fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).CurrentInput + nameWithType: HumanControllerLogic.CurrentInput + nameWithType.vb: HumanControllerLogic(Of TInput).CurrentInput +- uid: LiteEntitySystem.HumanControllerLogic`1.CurrentInput* + name: CurrentInput + href: api/LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_CurrentInput_ + commentId: Overload:LiteEntitySystem.HumanControllerLogic`1.CurrentInput + isSpec: "True" + fullName: LiteEntitySystem.HumanControllerLogic.CurrentInput + fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).CurrentInput + nameWithType: HumanControllerLogic.CurrentInput + nameWithType.vb: HumanControllerLogic(Of TInput).CurrentInput - uid: LiteEntitySystem.HumanControllerLogic`1.GenerateInput(`0@) name: GenerateInput(out TInput) href: api/LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_GenerateInput__0__ @@ -6926,22 +6943,22 @@ references: isSpec: "True" fullName: LiteEntitySystem.ServerEntityManager.AddPlayer nameWithType: ServerEntityManager.AddPlayer -- uid: LiteEntitySystem.ServerEntityManager.AddSignleton* - name: AddSignleton - href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_AddSignleton_ - commentId: Overload:LiteEntitySystem.ServerEntityManager.AddSignleton - isSpec: "True" - fullName: LiteEntitySystem.ServerEntityManager.AddSignleton - nameWithType: ServerEntityManager.AddSignleton -- uid: LiteEntitySystem.ServerEntityManager.AddSignleton``1(System.Action{``0}) - name: AddSignleton(Action) - href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_AddSignleton__1_System_Action___0__ - commentId: M:LiteEntitySystem.ServerEntityManager.AddSignleton``1(System.Action{``0}) - name.vb: AddSignleton(Of T)(Action(Of T)) - fullName: LiteEntitySystem.ServerEntityManager.AddSignleton(System.Action) - fullName.vb: LiteEntitySystem.ServerEntityManager.AddSignleton(Of T)(System.Action(Of T)) - nameWithType: ServerEntityManager.AddSignleton(Action) - nameWithType.vb: ServerEntityManager.AddSignleton(Of T)(Action(Of T)) +- uid: LiteEntitySystem.ServerEntityManager.AddSingleton* + name: AddSingleton + href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_AddSingleton_ + commentId: Overload:LiteEntitySystem.ServerEntityManager.AddSingleton + isSpec: "True" + fullName: LiteEntitySystem.ServerEntityManager.AddSingleton + nameWithType: ServerEntityManager.AddSingleton +- uid: LiteEntitySystem.ServerEntityManager.AddSingleton``1(System.Action{``0}) + name: AddSingleton(Action) + href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_AddSingleton__1_System_Action___0__ + commentId: M:LiteEntitySystem.ServerEntityManager.AddSingleton``1(System.Action{``0}) + name.vb: AddSingleton(Of T)(Action(Of T)) + fullName: LiteEntitySystem.ServerEntityManager.AddSingleton(System.Action) + fullName.vb: LiteEntitySystem.ServerEntityManager.AddSingleton(Of T)(System.Action(Of T)) + nameWithType: ServerEntityManager.AddSingleton(Action) + nameWithType.vb: ServerEntityManager.AddSingleton(Of T)(Action(Of T)) - uid: LiteEntitySystem.ServerEntityManager.Create* name: Create href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_Create_