mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Initial commit
This commit is contained in:
commit
3c7cc0c973
8391 changed files with 704313 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
public interface ISelectable<T>
|
||||
{
|
||||
bool Select(ISelector<T> selector);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: af7c69fdafb90db42be665ce2428476b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
public interface ISelection<T>
|
||||
{
|
||||
int Count { get; }
|
||||
T activeElement { get; set; }
|
||||
T[] elements { get; set; }
|
||||
void Clear();
|
||||
void BeginSelection();
|
||||
void EndSelection(bool select);
|
||||
bool Select(T element, bool select);
|
||||
bool Contains(T element);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fef25bfe400c1dc4ea71788dc419233c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
public interface ISelector<T>
|
||||
{
|
||||
bool Select(T element);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ed850d38afdc6249bc0d68517fdd655
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
[Serializable]
|
||||
internal class IndexedSelection : SerializableSelection<int>
|
||||
{
|
||||
protected override int GetInvalidElement() { return -1; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2730041e9cc62f34e88271bda57ed4b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
public class PointRectSelector : RectSelector<Vector3>
|
||||
{
|
||||
protected override bool Select(Vector3 element)
|
||||
{
|
||||
return guiRect.Contains(HandleUtility.WorldToGUIPoint(element), true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bd49dfc036db0943a9ebe4981dad845
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,143 @@
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Path
|
||||
{
|
||||
[Serializable]
|
||||
internal abstract class SerializableSelection<T> : ISelection<T>, ISerializationCallbackReceiver
|
||||
{
|
||||
internal readonly static int kInvalidID = -1;
|
||||
|
||||
[SerializeField]
|
||||
private T[] m_Keys = new T[0];
|
||||
|
||||
private HashSet<T> m_Selection = new HashSet<T>();
|
||||
private HashSet<T> m_TemporalSelection = new HashSet<T>();
|
||||
private bool m_SelectionInProgress = false;
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return m_Selection.Count + m_TemporalSelection.Count; }
|
||||
}
|
||||
|
||||
public T activeElement
|
||||
{
|
||||
get { return First(); }
|
||||
set
|
||||
{
|
||||
Clear();
|
||||
Select(value, true);
|
||||
}
|
||||
}
|
||||
|
||||
public T[] elements
|
||||
{
|
||||
get
|
||||
{
|
||||
var set = m_Selection;
|
||||
|
||||
if (m_SelectionInProgress)
|
||||
{
|
||||
var union = new HashSet<T>(m_Selection);
|
||||
union.UnionWith(m_TemporalSelection);
|
||||
set = union;
|
||||
}
|
||||
|
||||
return new List<T>(set).ToArray();
|
||||
}
|
||||
set
|
||||
{
|
||||
Clear();
|
||||
foreach(var element in value)
|
||||
Select(element, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract T GetInvalidElement();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
GetSelection().Clear();
|
||||
}
|
||||
|
||||
public void BeginSelection()
|
||||
{
|
||||
m_SelectionInProgress = true;
|
||||
Clear();
|
||||
}
|
||||
|
||||
public void EndSelection(bool select)
|
||||
{
|
||||
m_SelectionInProgress = false;
|
||||
|
||||
if (select)
|
||||
m_Selection.UnionWith(m_TemporalSelection);
|
||||
else
|
||||
m_Selection.ExceptWith(m_TemporalSelection);
|
||||
|
||||
m_TemporalSelection.Clear();
|
||||
}
|
||||
|
||||
public bool Select(T element, bool select)
|
||||
{
|
||||
var changed = false;
|
||||
|
||||
if(EqualityComparer<T>.Default.Equals(element, GetInvalidElement()))
|
||||
return changed;
|
||||
|
||||
if (select)
|
||||
changed = GetSelection().Add(element);
|
||||
else if (Contains(element))
|
||||
changed = GetSelection().Remove(element);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public bool Contains(T element)
|
||||
{
|
||||
return m_Selection.Contains(element) || m_TemporalSelection.Contains(element);
|
||||
}
|
||||
|
||||
private HashSet<T> GetSelection()
|
||||
{
|
||||
if (m_SelectionInProgress)
|
||||
return m_TemporalSelection;
|
||||
|
||||
return m_Selection;
|
||||
}
|
||||
|
||||
private T First()
|
||||
{
|
||||
T element = First(m_Selection);
|
||||
|
||||
if(EqualityComparer<T>.Default.Equals(element, GetInvalidElement()))
|
||||
element = First(m_TemporalSelection);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private T First(HashSet<T> set)
|
||||
{
|
||||
if(set.Count == 0)
|
||||
return GetInvalidElement();
|
||||
|
||||
using (var enumerator = set.GetEnumerator())
|
||||
{
|
||||
Debug.Assert(enumerator.MoveNext());
|
||||
return enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
m_Keys = new List<T>(m_Selection).ToArray();
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
elements = m_Keys;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c56d5585e26d15248804809e7a014452
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue