This repository has been archived by the owner on Oct 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from proepkes/develop
Composite key pes GameEntity: OwnerId + ID
- Loading branch information
Showing
38 changed files
with
584 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
using Entitas; | ||
using Entitas.CodeGeneration.Attributes; | ||
using Entitas; | ||
|
||
namespace Lockstep.Core.Components.Game | ||
{ | ||
[Game] | ||
public sealed class IdComponent : IComponent | ||
{ | ||
[PrimaryEntityIndex] | ||
{ | ||
public uint value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Entitas; | ||
using Entitas.CodeGeneration.Attributes; | ||
|
||
namespace Lockstep.Core.Components.Game | ||
{ | ||
[Game] | ||
public sealed class LocalIdComponent : IComponent | ||
{ | ||
[PrimaryEntityIndex] | ||
public uint value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Entitas; | ||
|
||
namespace Lockstep.Core.Components.Game | ||
{ | ||
[Game] | ||
public class TickComponent : IComponent | ||
{ | ||
public uint value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Entitas; | ||
|
||
namespace Lockstep.Core.Components.Input | ||
{ | ||
[Input] | ||
public class PlayerId : IComponent | ||
{ | ||
public byte value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Engine/Core/DefaultServices/DefaultPlayerEntityIdProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Lockstep.Core.Interfaces; | ||
|
||
namespace Lockstep.Core.DefaultServices | ||
{ | ||
/// <summary> | ||
/// Every player has its own id-counter | ||
/// </summary> | ||
public class DefaultPlayerEntityIdProvider : IPlayerEntityIdProvider | ||
{ | ||
private readonly Dictionary<byte, uint> _idMap = new Dictionary<byte, uint>(); | ||
|
||
public uint Get(byte key) | ||
{ | ||
return _idMap[key]; | ||
} | ||
|
||
public uint GetNext(byte key) | ||
{ | ||
if (!_idMap.ContainsKey(key)) | ||
{ | ||
_idMap.Add(key, 0); | ||
} | ||
|
||
var nextId = _idMap[key]; | ||
_idMap[key] += 1; | ||
return nextId; | ||
} | ||
|
||
public void SetNext(byte key, uint value) | ||
{ | ||
_idMap[key] = value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.