Tokenize ruleset keys. Remove MotionName.
This commit is contained in:
34
Assets/Cryville/Common/Identifier.cs
Normal file
34
Assets/Cryville/Common/Identifier.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common {
|
||||
public struct Identifier : IEquatable<Identifier> {
|
||||
public int Key { get; private set; }
|
||||
public object Name { get { return IdentifierManager.SharedInstance.Retrieve(Key); } }
|
||||
public Identifier(int key) {
|
||||
Key = key;
|
||||
}
|
||||
public Identifier(object name) {
|
||||
Key = IdentifierManager.SharedInstance.Request(name);
|
||||
}
|
||||
public override bool Equals(object obj) {
|
||||
if (obj == null && Key == 0) return true;
|
||||
if (obj == null || !(obj is Identifier)) return false;
|
||||
return Equals((Identifier)obj);
|
||||
}
|
||||
public bool Equals(Identifier other) {
|
||||
return Key == other.Key;
|
||||
}
|
||||
public override int GetHashCode() {
|
||||
return Key;
|
||||
}
|
||||
public override string ToString() {
|
||||
return Name.ToString();
|
||||
}
|
||||
public static implicit operator Identifier(string identifier) {
|
||||
return new Identifier(identifier);
|
||||
}
|
||||
public static implicit operator string(Identifier identifier) {
|
||||
return identifier.ToString();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Identifier.cs.meta
Normal file
11
Assets/Cryville/Common/Identifier.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b0f66eb5ae446e44a34dc61dac132b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -15,6 +15,13 @@ namespace Cryville.Common {
|
||||
|
||||
object _syncRoot = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="IdentifierManager" /> class.
|
||||
/// </summary>
|
||||
public IdentifierManager() {
|
||||
Request(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests an integer ID for an identifier.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user