Skip to content

Commit

Permalink
store controller actual (on ReadInput) input as variable (HumanContro…
Browse files Browse the repository at this point in the history
…llerLogic.CurrentInput). update docs. Check for HumanControllerLogic instead of ControllerLogic in AddController
  • Loading branch information
RevenantX committed Nov 19, 2024
1 parent a5e9a89 commit 3cb50a6
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 24 deletions.
5 changes: 5 additions & 0 deletions LiteEntitySystem/HumanControllerLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public ServerResponse(ushort requestId, bool success)
private static RemoteCall<ServerResponse> _serverResponseRpc;
private ushort _requestId;
private readonly Dictionary<ushort,Action<bool>> _awaitingRequests;

/// <summary>
/// Input that created by ReadInput before all entity updates
/// </summary>
public TInput CurrentInput { get; internal set; }

/// <summary>
/// Get player that uses this controller
Expand Down
3 changes: 2 additions & 1 deletion LiteEntitySystem/InputProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions LiteEntitySystem/LiteEntitySystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Title>LiteEntitySystem</Title>
<Description>Pure C# HighLevel API for multiplayer games using .NET Standard 2.1</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
4 changes: 2 additions & 2 deletions LiteEntitySystem/ServerEntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public HumanControllerLogic GetPlayerController(NetPlayer player)
/// <param name="initMethod">Method that will be called after entity construction</param>
/// <typeparam name="T">Entity type</typeparam>
/// <returns>Created entity or null in case of limit</returns>
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 =>
Add<T>(ent =>
{
ent.InternalOwnerId.Value = owner.Id;
Expand All @@ -229,7 +229,7 @@ public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T
/// <param name="initMethod">Method that will be called after entity construction</param>
/// <typeparam name="T">Entity type</typeparam>
/// <returns>Created entity or null in case of limit</returns>
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 =>
Add<T>(ent =>
{
ent.InternalOwnerId.Value = owner.Id;
Expand Down
26 changes: 26 additions & 0 deletions docs/api/LiteEntitySystem.HumanControllerLogic-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,32 @@ <h3 id="properties">Properties
</h3>


<a id="LiteEntitySystem_HumanControllerLogic_1_CurrentInput_" data-uid="LiteEntitySystem.HumanControllerLogic`1.CurrentInput*"></a>
<h4 id="LiteEntitySystem_HumanControllerLogic_1_CurrentInput" data-uid="LiteEntitySystem.HumanControllerLogic`1.CurrentInput">CurrentInput</h4>
<div class="markdown level1 summary"><p>Input that created by ReadInput before all entity updates</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TInput CurrentInput { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">TInput</span></td>
<td></td>
</tr>
</tbody>
</table>


<a id="LiteEntitySystem_HumanControllerLogic_1_IsBot_" data-uid="LiteEntitySystem.HumanControllerLogic`1.IsBot*"></a>
<h4 id="LiteEntitySystem_HumanControllerLogic_1_IsBot" data-uid="LiteEntitySystem.HumanControllerLogic`1.IsBot">IsBot</h4>
<div class="markdown level1 summary"><p>Is controller - AI controller</p>
Expand Down
3 changes: 3 additions & 0 deletions docs/api/LiteEntitySystem.HumanControllerLogic-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ <h5>Inherited Members</h5>
<div>
<a class="xref" href="LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_StringSizeLimit">HumanControllerLogic&lt;TInput&gt;.StringSizeLimit</a>
</div>
<div>
<a class="xref" href="LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_CurrentInput">HumanControllerLogic&lt;TInput&gt;.CurrentInput</a>
</div>
<div>
<a class="xref" href="LiteEntitySystem.HumanControllerLogic-1.html#LiteEntitySystem_HumanControllerLogic_1_GetAssignedPlayer">HumanControllerLogic&lt;TInput&gt;.GetAssignedPlayer()</a>
</div>
Expand Down
10 changes: 5 additions & 5 deletions docs/api/LiteEntitySystem.ServerEntityManager.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h4 id="LiteEntitySystem_ServerEntityManager_AddController__1_LiteEntitySystem_N
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public T AddController&lt;T&gt;(NetPlayer owner, PawnLogic entityToControl, Action&lt;T&gt; initMethod = null) where T : ControllerLogic</code></pre>
<pre><code class="lang-csharp hljs">public T AddController&lt;T&gt;(NetPlayer owner, PawnLogic entityToControl, Action&lt;T&gt; initMethod = null) where T : HumanControllerLogic</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
Expand Down Expand Up @@ -504,7 +504,7 @@ <h4 id="LiteEntitySystem_ServerEntityManager_AddController__1_LiteEntitySystem_N
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public T AddController&lt;T&gt;(NetPlayer owner, Action&lt;T&gt; initMethod = null) where T : ControllerLogic</code></pre>
<pre><code class="lang-csharp hljs">public T AddController&lt;T&gt;(NetPlayer owner, Action&lt;T&gt; initMethod = null) where T : HumanControllerLogic</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
Expand Down Expand Up @@ -737,14 +737,14 @@ <h5 class="returns">Returns</h5>
</table>


<a id="LiteEntitySystem_ServerEntityManager_AddSignleton_" data-uid="LiteEntitySystem.ServerEntityManager.AddSignleton*"></a>
<h4 id="LiteEntitySystem_ServerEntityManager_AddSignleton__1_System_Action___0__" data-uid="LiteEntitySystem.ServerEntityManager.AddSignleton``1(System.Action{``0})">AddSignleton&lt;T&gt;(Action&lt;T&gt;)</h4>
<a id="LiteEntitySystem_ServerEntityManager_AddSingleton_" data-uid="LiteEntitySystem.ServerEntityManager.AddSingleton*"></a>
<h4 id="LiteEntitySystem_ServerEntityManager_AddSingleton__1_System_Action___0__" data-uid="LiteEntitySystem.ServerEntityManager.AddSingleton``1(System.Action{``0})">AddSingleton&lt;T&gt;(Action&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Add new entity</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public T AddSignleton&lt;T&gt;(Action&lt;T&gt; initMethod = null) where T : SingletonEntityLogic</code></pre>
<pre><code class="lang-csharp hljs">public T AddSingleton&lt;T&gt;(Action&lt;T&gt; initMethod = null) where T : SingletonEntityLogic</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
Expand Down
49 changes: 33 additions & 16 deletions docs/xrefmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5004,6 +5004,23 @@ references:
fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).New
nameWithType: HumanControllerLogic<TInput>.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<TInput>.CurrentInput
fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).CurrentInput
nameWithType: HumanControllerLogic<TInput>.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<TInput>.CurrentInput
fullName.vb: LiteEntitySystem.HumanControllerLogic(Of TInput).CurrentInput
nameWithType: HumanControllerLogic<TInput>.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__
Expand Down Expand Up @@ -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<T>(Action<T>)
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<T>(System.Action<T>)
fullName.vb: LiteEntitySystem.ServerEntityManager.AddSignleton(Of T)(System.Action(Of T))
nameWithType: ServerEntityManager.AddSignleton<T>(Action<T>)
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<T>(Action<T>)
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<T>(System.Action<T>)
fullName.vb: LiteEntitySystem.ServerEntityManager.AddSingleton(Of T)(System.Action(Of T))
nameWithType: ServerEntityManager.AddSingleton<T>(Action<T>)
nameWithType.vb: ServerEntityManager.AddSingleton(Of T)(Action(Of T))
- uid: LiteEntitySystem.ServerEntityManager.Create*
name: Create
href: api/LiteEntitySystem.ServerEntityManager.html#LiteEntitySystem_ServerEntityManager_Create_
Expand Down

0 comments on commit 3cb50a6

Please sign in to comment.