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