More better sync
This commit is contained in:
@@ -267,7 +267,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
data.Append((byte)pelletCollectedCount, ref index);
|
data.Append(pelletCollectedCount, ref index);
|
||||||
data.Append(syncedPelletsCollected, ref index);
|
data.Append(syncedPelletsCollected, ref index);
|
||||||
|
|
||||||
data.Append(frozen, ref index);
|
data.Append(frozen, ref index);
|
||||||
|
|||||||
@@ -824,7 +824,6 @@ namespace Marro.PacManUdon
|
|||||||
data.Append(isScared, ref index);
|
data.Append(isScared, ref index);
|
||||||
data.Append(whiteScared, ref index);
|
data.Append(whiteScared, ref index);
|
||||||
data.Append(scattering, ref index);
|
data.Append(scattering, ref index);
|
||||||
data.AppendAsByte((int)frozenState, ref index);
|
|
||||||
|
|
||||||
data.Append(offGrid, ref index);
|
data.Append(offGrid, ref index);
|
||||||
data.AppendAsByte(housePelletCounter, ref index);
|
data.AppendAsByte(housePelletCounter, ref index);
|
||||||
@@ -832,6 +831,8 @@ namespace Marro.PacManUdon
|
|||||||
data.AppendAsByte(housePelletCounterLimit, ref index);
|
data.AppendAsByte(housePelletCounterLimit, ref index);
|
||||||
|
|
||||||
base.CollectSyncedData(data, ref index, eventType);
|
base.CollectSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
data.AppendAsByte((int)frozenState, ref index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||||
@@ -852,7 +853,6 @@ namespace Marro.PacManUdon
|
|||||||
isScared = data.ReadBool(ref index);
|
isScared = data.ReadBool(ref index);
|
||||||
whiteScared = data.ReadBool(ref index);
|
whiteScared = data.ReadBool(ref index);
|
||||||
scattering = data.ReadBool(ref index);
|
scattering = data.ReadBool(ref index);
|
||||||
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
|
|
||||||
|
|
||||||
offGrid = data.ReadBool(ref index);
|
offGrid = data.ReadBool(ref index);
|
||||||
housePelletCounter = data.ReadByte(ref index);
|
housePelletCounter = data.ReadByte(ref index);
|
||||||
@@ -861,7 +861,13 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
UpdateSpeed();
|
UpdateSpeed();
|
||||||
|
|
||||||
return base.WriteSyncedData(data, ref index, eventType);
|
frozenState = PacManGhostFrozenState.NotFrozen; // Ensure UpdateAnimator runs fully
|
||||||
|
|
||||||
|
var success = base.WriteSyncedData(data, ref index, eventType);
|
||||||
|
|
||||||
|
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,13 +239,6 @@ namespace Marro.PacManUdon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
animator.speed = frozen ? 0 : 1;
|
|
||||||
|
|
||||||
if (frozen)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction.Equals(Direction.Zero))
|
if (direction.Equals(Direction.Zero))
|
||||||
{
|
{
|
||||||
SetAnimatorState((int)PacManAnimatorState.Stopped);
|
SetAnimatorState((int)PacManAnimatorState.Stopped);
|
||||||
@@ -253,8 +246,12 @@ namespace Marro.PacManUdon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetAnimatorState((int)PacManAnimatorState.Moving);
|
SetAnimatorState((int)PacManAnimatorState.Moving);
|
||||||
SetAnimatorDirection((int)targetDirection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
animator.speed = frozen ? 0 : 1;
|
||||||
|
|
||||||
|
SetAnimatorDirection((int)targetDirection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAnimatorDirection(int value) =>
|
private void SetAnimatorDirection(int value) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user