去掉obi,使用自写绳索

This commit is contained in:
2026-02-23 20:51:03 +08:00
parent cb636f862d
commit 91e2309eeb
2011 changed files with 2593 additions and 190578 deletions

View File

@@ -1,52 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
namespace Obi
{
[CreateAssetMenu(fileName = "rope section", menuName = "Obi/Rope Section", order = 142)]
public class ObiRopeSection : ScriptableObject
{
[HideInInspector] public List<Vector2> vertices;
public int snapX = 0;
public int snapY = 0;
public int Segments{
get{return vertices.Count-1;}
}
public void OnEnable(){
if (vertices == null){
vertices = new List<Vector2>();
CirclePreset(8);
}
}
public void CirclePreset(int segments){
vertices.Clear();
for (int j = 0; j <= segments; ++j){
float angle = 2 * Mathf.PI / segments * j;
vertices.Add(Mathf.Cos(angle)*Vector2.right + Mathf.Sin(angle)*Vector2.up);
}
}
/**
* Snaps a float value to the nearest multiple of snapInterval.
*/
public static int SnapTo(float val, int snapInterval, int threshold){
int intVal = (int) val;
if (snapInterval <= 0)
return intVal;
int under = Mathf.FloorToInt(val / snapInterval) * snapInterval;
int over = under + snapInterval;
if (intVal - under < threshold) return under;
if (over - intVal < threshold) return over;
return intVal;
}
}
}