39 lines
852 B
C#
39 lines
852 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RopeBuilder
|
|
{
|
|
List<Point> points = new();
|
|
List<Stick> sticks = new();
|
|
|
|
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;
|
|
}
|
|
|
|
public RopeBuilder ConnectPointsWithDesiredLength(int idxA, int idxB, float desiredLength)
|
|
{
|
|
sticks.Add(new Stick(points[idxA], points[idxB], desiredLength));
|
|
return this;
|
|
}
|
|
|
|
public Rope Build()
|
|
{
|
|
return new Rope(points: points, sticks: sticks);
|
|
}
|
|
}
|