84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
using System;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
public struct MapTargetNetworkState : INetworkSerializable,
|
|
IEquatable<MapTargetNetworkState>
|
|
{
|
|
public int TargetId;
|
|
public int ConfigIndex;
|
|
public Vector2 Coordinates;
|
|
public int Health;
|
|
public float AttackTimeRemaining;
|
|
|
|
public MapTargetNetworkState(
|
|
int targetId,
|
|
int configIndex,
|
|
Vector2 coordinates,
|
|
int health,
|
|
float attackTimeRemaining)
|
|
{
|
|
TargetId = targetId;
|
|
ConfigIndex = configIndex;
|
|
Coordinates = coordinates;
|
|
Health = health;
|
|
AttackTimeRemaining = attackTimeRemaining;
|
|
}
|
|
|
|
public void NetworkSerialize<T>(BufferSerializer<T> serializer)
|
|
where T : IReaderWriter
|
|
{
|
|
serializer.SerializeValue(ref TargetId);
|
|
serializer.SerializeValue(ref ConfigIndex);
|
|
serializer.SerializeValue(ref Coordinates);
|
|
serializer.SerializeValue(ref Health);
|
|
serializer.SerializeValue(ref AttackTimeRemaining);
|
|
}
|
|
|
|
public bool Equals(MapTargetNetworkState other) =>
|
|
TargetId == other.TargetId &&
|
|
ConfigIndex == other.ConfigIndex &&
|
|
Coordinates == other.Coordinates &&
|
|
Health == other.Health &&
|
|
AttackTimeRemaining.Equals(other.AttackTimeRemaining);
|
|
}
|
|
|
|
public struct MapShotResultState : INetworkSerializable,
|
|
IEquatable<MapShotResultState>
|
|
{
|
|
public uint Sequence;
|
|
public bool Hit;
|
|
public int TargetId;
|
|
public Vector2 Coordinates;
|
|
public float Distance;
|
|
|
|
public MapShotResultState(
|
|
uint sequence,
|
|
bool hit,
|
|
int targetId,
|
|
Vector2 coordinates,
|
|
float distance)
|
|
{
|
|
Sequence = sequence;
|
|
Hit = hit;
|
|
TargetId = targetId;
|
|
Coordinates = coordinates;
|
|
Distance = distance;
|
|
}
|
|
|
|
public void NetworkSerialize<T>(BufferSerializer<T> serializer)
|
|
where T : IReaderWriter
|
|
{
|
|
serializer.SerializeValue(ref Sequence);
|
|
serializer.SerializeValue(ref Hit);
|
|
serializer.SerializeValue(ref TargetId);
|
|
serializer.SerializeValue(ref Coordinates);
|
|
serializer.SerializeValue(ref Distance);
|
|
}
|
|
|
|
public bool Equals(MapShotResultState other) =>
|
|
Sequence == other.Sequence && Hit == other.Hit &&
|
|
TargetId == other.TargetId && Coordinates == other.Coordinates &&
|
|
Distance.Equals(other.Distance);
|
|
}
|