fgm24/Assets/Scripts/Rope/Stick.cs

35 lines
851 B
C#

using UnityEngine;
using Unity.Netcode;
[System.Serializable]
public class Stick : INetworkSerializable
{
public Point A, B;
public float desiredLength;
public bool dead;
public Stick() { }
public Stick(Point pointA, Point pointB)
{
this.A = pointA;
this.B = pointB;
desiredLength = Vector2.Distance(pointA.position, pointB.position);
}
public Stick(Point pointA, Point pointB, float desiredLenght)
{
this.A = pointA;
this.B = pointB;
this.desiredLength = desiredLenght;
}
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
A.NetworkSerialize(serializer);
B.NetworkSerialize(serializer);
serializer.SerializeValue(ref desiredLength);
serializer.SerializeValue(ref dead);
}
}