Include enemy posisions in gamestate
This commit is contained in:
parent
dc4309fba9
commit
9887ee0266
|
@ -1,10 +1,12 @@
|
|||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public struct GameState : INetworkSerializable
|
||||
{
|
||||
public int tick;
|
||||
public NetworkRope nrope;
|
||||
public Vector2[] enemyPositions;
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
|
@ -20,6 +22,7 @@ public struct GameState : INetworkSerializable
|
|||
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
|
||||
{
|
||||
serializer.SerializeValue(ref tick);
|
||||
serializer.SerializeValue(ref enemyPositions);
|
||||
nrope.NetworkSerialize(serializer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using Utilities;
|
||||
using UnityUtils;
|
||||
|
||||
public class RopeSimulator : NetworkBehaviour
|
||||
|
@ -315,7 +314,8 @@ public class RopeSimulator : NetworkBehaviour
|
|||
{
|
||||
GameState localState = new() {
|
||||
tick = currentTick,
|
||||
nrope = Rope.ToNetworkRope(this.rope)
|
||||
nrope = Rope.ToNetworkRope(this.rope),
|
||||
enemyPositions = GameObject.FindObjectsByType<EnemyPathFinding>(FindObjectsSortMode.None).Select(e => new Vector2(e.transform.position.x, e.transform.position.y)).ToArray()
|
||||
};
|
||||
|
||||
return localState;
|
||||
|
|
Loading…
Reference in New Issue