-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
model: NpcId and PlayerId renamed to InstanceId. core: fixed Npc sycn…
…ing, added InitNpcSegment, refactored player and npc syncers
- Loading branch information
Showing
16 changed files
with
144 additions
and
50 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
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
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
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,49 @@ | ||
using System; | ||
using CScape.Core.Game.Entities; | ||
using CScape.Models.Extensions; | ||
using CScape.Models.Game.Entity; | ||
using JetBrains.Annotations; | ||
|
||
namespace CScape.Core.Network.Entity.Segment | ||
{ | ||
public sealed class InitNpcSegment : IUpdateSegment | ||
{ | ||
private readonly bool _needsUpdate; | ||
private readonly int _npcInstanceId; | ||
private readonly int _yDelta; | ||
private readonly int _xDelta; | ||
private readonly int _definitionId; | ||
|
||
public InitNpcSegment( | ||
[NotNull] INpcComponent npc, | ||
[NotNull] IEntity observerEntity, | ||
bool needsUpdate) | ||
{ | ||
if (npc == null) throw new ArgumentNullException(nameof(npc)); | ||
if (observerEntity == null) throw new ArgumentNullException(nameof(observerEntity)); | ||
|
||
var observerTransform = observerEntity.GetTransform(); | ||
var npcTransform = npc.Parent.GetTransform(); | ||
|
||
_yDelta = npcTransform.Y - observerTransform.Y; | ||
_xDelta = npcTransform.X - observerTransform.X; | ||
|
||
_npcInstanceId = npc.InstanceId; | ||
_needsUpdate = needsUpdate; | ||
_definitionId = npc.DefinitionId; | ||
} | ||
|
||
public void Write(OutBlob stream) | ||
{ | ||
stream.WriteBits(14, _npcInstanceId); | ||
|
||
stream.WriteBits(5, _yDelta); | ||
stream.WriteBits(5, _xDelta); | ||
|
||
stream.WriteBits(1, 1); // setpos?? flag // todo : setpos flag | ||
stream.WriteBits(12, _definitionId); | ||
stream.WriteBits(1, _needsUpdate ? 1 : 0); | ||
|
||
} | ||
} | ||
} |
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
Oops, something went wrong.