81 lines
1.4 KiB
C#
81 lines
1.4 KiB
C#
using Obi;
|
|
using ShiningGames.UFS2;
|
|
using UnityEngine;
|
|
|
|
public class TestReel : MonoBehaviour
|
|
{
|
|
private ObiRopeCursor cursor;
|
|
|
|
private ObiRope rope;
|
|
|
|
[SerializeField]
|
|
private TestAtachment currentAttachment;
|
|
|
|
[SerializeField]
|
|
private float reelSpeed = 1f;
|
|
|
|
[SerializeField]
|
|
private float minLegth;
|
|
|
|
[SerializeField]
|
|
private float maxLegth;
|
|
|
|
[SerializeField]
|
|
private float currentLineLength;
|
|
|
|
[SerializeField]
|
|
private bool isBreakOpen;
|
|
|
|
private void Start()
|
|
{
|
|
cursor = GetComponentInChildren<ObiRopeCursor>();
|
|
rope = cursor.GetComponent<ObiRope>();
|
|
currentLineLength = Mathf.Clamp(rope.restLength, minLegth, maxLegth);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKey(KeyCode.Z))
|
|
{
|
|
SetLength(0f - reelSpeed);
|
|
}
|
|
if (Input.GetKey(KeyCode.X))
|
|
{
|
|
SetLength(reelSpeed);
|
|
}
|
|
}
|
|
|
|
public void BreakOpen(bool value)
|
|
{
|
|
isBreakOpen = value;
|
|
}
|
|
|
|
private void SetOpenBreak()
|
|
{
|
|
isBreakOpen = true;
|
|
}
|
|
|
|
public void UnwindLine(float amount)
|
|
{
|
|
SetLength(amount);
|
|
}
|
|
|
|
public void ReelLine()
|
|
{
|
|
SetLength(0f - reelSpeed);
|
|
}
|
|
|
|
private void SetLength(float modifier)
|
|
{
|
|
float num = (currentLineLength = Mathf.Clamp(currentLineLength + modifier * Time.deltaTime, minLegth, maxLegth));
|
|
cursor.ChangeLength(num);
|
|
currentAttachment.SetJointLength(num);
|
|
currentAttachment.AddForce(base.transform.forward * 0.01f);
|
|
}
|
|
|
|
public void CastLength(float mod)
|
|
{
|
|
SetLength(mod);
|
|
}
|
|
}
|