fgm24/Assets/Scripts/Rope/RopeBuilder.cs

46 lines
1017 B
C#
Raw Normal View History

2024-02-02 21:03:44 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RopeBuilder
{
List<Point> points = new();
List<Stick> sticks = new();
2024-02-03 16:58:14 +01:00
public RopeBuilder() { }
public RopeBuilder(List<Point> points, List<Stick> sticks)
{
this.points = points;
this.sticks = sticks;
}
2024-02-02 21:03:44 +01:00
public RopeBuilder AddPoint(Point point)
{
points.Add(point);
return this;
}
public RopeBuilder ConnectPoints(Point A, Point B)
{
sticks.Add(new Stick(A, B));
return this;
}
public RopeBuilder ConnectPoints(int idxA, int idxB)
{
sticks.Add(new Stick(points[idxA], points[idxB]));
return this;
}
2024-02-03 00:15:07 +01:00
public RopeBuilder ConnectPointsWithDesiredLength(int idxA, int idxB, float desiredLength)
{
sticks.Add(new Stick(points[idxA], points[idxB], desiredLength));
return this;
}
2024-02-02 21:03:44 +01:00
public Rope Build()
{
return new Rope(points: points, sticks: sticks);
}
}