Skip to content

Commit

Permalink
helper methods, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Jan 6, 2024
1 parent 607d561 commit 0c24e29
Show file tree
Hide file tree
Showing 116 changed files with 1,724 additions and 1,303 deletions.
22 changes: 22 additions & 0 deletions LiteEntitySystem/ClientEntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ public ClientEntityManager(
_statesPool.Enqueue(new ServerStateData());
}
}

/// <summary>
/// Simplified constructor
/// </summary>
/// <param name="typesMap">EntityTypesMap with registered entity types</param>
/// <param name="netPeer">Local AbstractPeer</param>
/// <param name="headerByte">Header byte that will be used for packets (to distinguish entity system packets)</param>
/// <param name="framesPerSecond">Fixed framerate of game logic</param>
/// <typeparam name="TInput">Main input packet type</typeparam>
public static ClientEntityManager Create<TInput>(
EntityTypesMap typesMap,
AbstractNetPeer netPeer,
byte headerByte,
byte framesPerSecond) where TInput : unmanaged
{
return new ClientEntityManager(
typesMap,
new InputProcessor<TInput>(),
netPeer,
headerByte,
framesPerSecond);
}

internal override void RemoveEntity(InternalEntity e)
{
Expand Down
41 changes: 41 additions & 0 deletions LiteEntitySystem/ServerEntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ public ServerEntityManager(
_packetBuffer[0] = packetHeader;
SendRate = sendRate;
}

/// <summary>
/// Simplified constructor
/// </summary>
/// <param name="typesMap">EntityTypesMap with registered entity types</param>
/// <param name="packetHeader">Header byte that will be used for packets (to distinguish entity system packets)</param>
/// <param name="framesPerSecond">Fixed framerate of game logic</param>
/// <param name="sendRate">Send rate of server (depends on fps)</param>
/// <typeparam name="TInput">Main input packet type</typeparam>
public static ServerEntityManager Create<TInput>(
EntityTypesMap typesMap,
byte packetHeader,
byte framesPerSecond,
ServerSendRate sendRate) where TInput : unmanaged
{
return new ServerEntityManager(
typesMap,
new InputProcessor<TInput>(),
packetHeader,
framesPerSecond,
sendRate);
}

/// <summary>
/// Create and add new player
Expand Down Expand Up @@ -184,6 +206,25 @@ public T AddController<T>(NetPlayer owner, Action<T> initMethod = null) where T
return result;
}

/// <summary>
/// Add new player controller entity and start controlling entityToControl
/// </summary>
/// <param name="owner">Player that owns this controller</param>
/// <param name="entityToControl">pawn that will be controlled</param>
/// <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
{
var result = Add<T>(ent =>
{
ent.InternalOwnerId = owner.Id;
ent.StartControl(entityToControl);
initMethod?.Invoke(ent);
});
return result;
}

/// <summary>
/// Add new AI controller entity
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.AiControllerLogic-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.AiControllerLogic.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.BindOnChange.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ <h5 class="parameters">Parameters</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.BindRpc.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ <h5 class="parameters">Parameters</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
80 changes: 79 additions & 1 deletion docs/api/LiteEntitySystem.ClientEntityManager.html
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,84 @@ <h3 id="methods">Methods
</h3>


<a id="LiteEntitySystem_ClientEntityManager_Create_" data-uid="LiteEntitySystem.ClientEntityManager.Create*"></a>
<h4 id="LiteEntitySystem_ClientEntityManager_Create__1_LiteEntitySystem_EntityTypesMap_LiteEntitySystem_Transport_AbstractNetPeer_System_Byte_System_Byte_" data-uid="LiteEntitySystem.ClientEntityManager.Create``1(LiteEntitySystem.EntityTypesMap,LiteEntitySystem.Transport.AbstractNetPeer,System.Byte,System.Byte)">Create&lt;TInput&gt;(EntityTypesMap, AbstractNetPeer, byte, byte)</h4>
<div class="markdown level1 summary"><p>Simplified constructor</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static ClientEntityManager Create&lt;TInput&gt;(EntityTypesMap typesMap, AbstractNetPeer netPeer, byte headerByte, byte framesPerSecond) where TInput : unmanaged</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="LiteEntitySystem.EntityTypesMap.html">EntityTypesMap</a></td>
<td><span class="parametername">typesMap</span></td>
<td><p>EntityTypesMap with registered entity types</p>
</td>
</tr>
<tr>
<td><a class="xref" href="LiteEntitySystem.Transport.AbstractNetPeer.html">AbstractNetPeer</a></td>
<td><span class="parametername">netPeer</span></td>
<td><p>Local AbstractPeer</p>
</td>
</tr>
<tr>
<td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a></td>
<td><span class="parametername">headerByte</span></td>
<td><p>Header byte that will be used for packets (to distinguish entity system packets)</p>
</td>
</tr>
<tr>
<td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a></td>
<td><span class="parametername">framesPerSecond</span></td>
<td><p>Fixed framerate of game logic</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="LiteEntitySystem.ClientEntityManager.html">ClientEntityManager</a></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">TInput</span></td>
<td><p>Main input packet type</p>
</td>
</tr>
</tbody>
</table>


<a id="LiteEntitySystem_ClientEntityManager_Deserialize_" data-uid="LiteEntitySystem.ClientEntityManager.Deserialize*"></a>
<h4 id="LiteEntitySystem_ClientEntityManager_Deserialize_System_ReadOnlySpan_System_Byte__" data-uid="LiteEntitySystem.ClientEntityManager.Deserialize(System.ReadOnlySpan{System.Byte})">Deserialize(ReadOnlySpan&lt;byte&gt;)</h4>
<div class="markdown level1 summary"></div>
Expand Down Expand Up @@ -675,7 +753,7 @@ <h5 class="overrides">Overrides</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ <h5 class="overrides">Overrides</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.ControllerLogic.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.DeserializeResult.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h3 id="extensionmethods">Extension Methods</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/LiteEntitySystem.EntityFilter-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h5 class="returns">Returns</h5>
</thead>
<tbody>
<tr>
<td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.sortedset-1">SortedSet</a>&lt;T&gt;.<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.sortedset{-0}.enumerator">Enumerator</a></td>
<td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.sortedset-1">SortedSet</a>&lt;T&gt;.<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.sortedset-1.enumerator">Enumerator</a></td>
<td></td>
</tr>
</tbody>
Expand Down Expand Up @@ -322,7 +322,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.EntityFilter.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h5 id="LiteEntitySystem_EntityFilter_syntax">Syntax</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.EntityList-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ <h5 class="overrides">Overrides</h5>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/LiteEntitySystem.EntityLogic.html
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ <h3 id="implements">Implements</h3>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<h5>In this article</h5>
<div></div>
</nav>
</div>
Expand Down
Loading

0 comments on commit 0c24e29

Please sign in to comment.