70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class ToolNewVector
|
|
{
|
|
[HideInInspector]
|
|
public Vector3 cursorPos;
|
|
[HideInInspector]
|
|
public List<Vector3> vector = new List<Vector3>();
|
|
|
|
public void Reset()
|
|
{
|
|
// for resetting the tool (when swapping around, initializing, etc)
|
|
vector.Clear();
|
|
}
|
|
|
|
public void Frame(Input input, Pixelgon pixelgon)
|
|
{
|
|
Vector3 rawCursorPos = cursorPos = input.dragCursor;
|
|
|
|
List<List<Vector3>> lists = new List<List<Vector3>> {
|
|
pixelgon.vectors, vector.GetRange(0, Mathf.Max(vector.Count - 1, 0))
|
|
};
|
|
|
|
// wow this class is so much cleaner lool
|
|
cursorPos = StaticMethods.Snap(lists, rawCursorPos);
|
|
|
|
if (input.mainCon.trigger.down)
|
|
{
|
|
vector.Add(cursorPos);
|
|
vector.Add(cursorPos); // -> vector
|
|
}
|
|
|
|
if (vector.Count > 0)
|
|
{
|
|
if (input.mainCon.trigger.held)
|
|
{
|
|
if (input.mainCon.one.down)
|
|
{
|
|
vector.Add(cursorPos);
|
|
}
|
|
|
|
vector[vector.Count - 1] = cursorPos;
|
|
|
|
if (input.mainCon.two.down)
|
|
{
|
|
if (vector.Count > 2)
|
|
{
|
|
vector.RemoveAt(vector.Count - 1);
|
|
}
|
|
else
|
|
{
|
|
vector.Clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (input.mainCon.trigger.up)
|
|
{
|
|
vector.Insert(0, Vector3.zero);
|
|
vector.Add(Vector3.zero);
|
|
pixelgon.vectors.AddRange(vector);
|
|
vector.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|