fgm24/Assets/Scripts/Rope/Stick.cs

35 lines
851 B
C#
Raw Normal View History

2024-02-02 21:03:44 +01:00
using UnityEngine;
2024-03-04 17:40:23 +01:00
using Unity.Netcode;
2024-02-02 21:03:44 +01:00
[System.Serializable]
2024-03-04 17:40:23 +01:00
public class Stick : INetworkSerializable
2024-02-02 21:03:44 +01:00
{
public Point A, B;
2024-02-03 00:15:07 +01:00
public float desiredLength;
2024-02-02 21:03:44 +01:00
public bool dead;
2024-03-04 17:40:23 +01:00
public Stick() { }
2024-02-02 21:03:44 +01:00
public Stick(Point pointA, Point pointB)
{
this.A = pointA;
this.B = pointB;
2024-02-03 00:15:07 +01:00
desiredLength = Vector2.Distance(pointA.position, pointB.position);
}
2024-03-04 17:40:23 +01:00
public Stick(Point pointA, Point pointB, float desiredLenght)
2024-02-03 00:15:07 +01:00
{
this.A = pointA;
this.B = pointB;
this.desiredLength = desiredLenght;
2024-02-02 21:03:44 +01:00
}
2024-03-04 17:40:23 +01:00
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
A.NetworkSerialize(serializer);
B.NetworkSerialize(serializer);
serializer.SerializeValue(ref desiredLength);
serializer.SerializeValue(ref dead);
}
}