Compare commits
342 Commits
0.5.0-rc2
...
dev-extens
| Author | SHA1 | Date | |
|---|---|---|---|
| 054b17811d | |||
| 94d5f7f82e | |||
| 0e4445e52b | |||
| ed2c216cf4 | |||
| 609645c108 | |||
| d280d27a0a | |||
| 5b727065f3 | |||
| 7aa2577059 | |||
| c1b7e9ab55 | |||
| 99384397ed | |||
| a2391aeb22 | |||
| 2207c80951 | |||
| bf578d7cb9 | |||
| 0bc57c368f | |||
| b64f85aaa2 | |||
| 93fa2f2d7e | |||
| d72216de8b | |||
| df5133a91a | |||
| 88b959a118 | |||
| 310bf91fbd | |||
| 699f47f98d | |||
| 24e881b138 | |||
| 2eef1b5c4e | |||
| c18ceb50d4 | |||
| 27ca1a7292 | |||
| dc59176eac | |||
| aec7470ff8 | |||
| 983cba6843 | |||
| 871782e73f | |||
| 9aaa96fe10 | |||
| 22190a29c1 | |||
| 613ca467d0 | |||
| 536a3066b2 | |||
| 43488cd002 | |||
| a11ccbd39c | |||
| 76df4929a7 | |||
| 505b826627 | |||
| 26a8675922 | |||
| b89e1f983e | |||
| 717e77b47e | |||
| 2f10c79dee | |||
| 55f7790f89 | |||
| ae5f4a8c16 | |||
| 1851bd3c54 | |||
| 6d74685cb7 | |||
| 03fd7f6d01 | |||
| 28c878f3e5 | |||
| 7736eba14d | |||
| 2e54b38d2b | |||
| da60dc0903 | |||
| 215f72b3b5 | |||
| a93c081dd8 | |||
| 456782930a | |||
| ba3cbbd64c | |||
| dfc3e9ca06 | |||
| f567a2b78e | |||
| c7e7bd8a77 | |||
| 67720fd0e1 | |||
| 1a30149942 | |||
| a755cc13bd | |||
| 9a51cf1b56 | |||
| 256c656e9c | |||
| 2ac7f05316 | |||
| 28d46dbabe | |||
| 18b3e0bc84 | |||
| 23f2e7c1f2 | |||
| 998713b41f | |||
| 3561354231 | |||
| 0cccb170c1 | |||
| d2480b8a6f | |||
| 6837d3f7ee | |||
| 3ecf3b4bfc | |||
| 1da8647ff1 | |||
| 2f19e8daad | |||
| 07f62c7aeb | |||
| 39db8dfa45 | |||
| f04cd370f1 | |||
| 5c4acd54ce | |||
| 82dbc5c479 | |||
| 1f1663d714 | |||
| a3c5392caa | |||
| 6c983cc2cb | |||
| 3bf3fdac3d | |||
| f2f3dba098 | |||
| 3728360dd2 | |||
| 887837bb3d | |||
| 99b4c2dfc1 | |||
| e59769158a | |||
| ba3238614b | |||
| a115999aab | |||
| 393947db9f | |||
| e9b2a7f894 | |||
| 9c73455761 | |||
| 59c2210359 | |||
| 4fab20953a | |||
| ee7b0f5081 | |||
| 33ee7a9a87 | |||
| 900bd7b77a | |||
| 6bd32c9aef | |||
| 13893b2853 | |||
| 23789c15eb | |||
| a1f7418d32 | |||
| 274a823d02 | |||
| ba6239068a | |||
| ff8c925f32 | |||
| 2a6a33e60c | |||
| 8910b1f4a0 | |||
| 36dddea4d9 | |||
| 6a648c2dcd | |||
| 2d4087dc89 | |||
| f91aacd78e | |||
| 9c08cbf0d2 | |||
| 88d35e4eaf | |||
| 675ce68073 | |||
| db0165d145 | |||
| 7015426300 | |||
| 0d4cc5e208 | |||
| e7ce0985fb | |||
| eb6dafbd60 | |||
| b6e238780e | |||
| c7ea6f1d4b | |||
| 4a5b2a6889 | |||
| b84d645aee | |||
| 67b44db1ae | |||
| ee4399109a | |||
| 87ef534f59 | |||
| 87362b47c5 | |||
| f60ba1088d | |||
| abb7ad6f24 | |||
| 880b475c07 | |||
| 4707c40e6a | |||
| 7f87c23da2 | |||
| 6df10837fe | |||
| 42cb54de1d | |||
| 9fd685b8b3 | |||
| b364005741 | |||
| 7d938de409 | |||
| bb4ecfcd8c | |||
| ff410529b0 | |||
| fdc55a8e3b | |||
| fc8512ff63 | |||
| 1b1ed42a1b | |||
| b437925f92 | |||
| c04e50e959 | |||
| 314cdb9935 | |||
| 77c91d015a | |||
| 291a018c13 | |||
| 18ff4b8e16 | |||
| 7714c277fd | |||
| d6c2ac6be6 | |||
| 682fe38d40 | |||
| 3e525842cb | |||
| 3dd25b51a8 | |||
| 041c1e374e | |||
| 16b1d323dc | |||
| c4d5e5f480 | |||
| 187f07d2c9 | |||
| 4e9d7e5b87 | |||
| 7df5b15e2e | |||
| 4863aa0ae7 | |||
| eb53c3465b | |||
| f683d61298 | |||
| fbd03c8037 | |||
| da68c8b877 | |||
| c0744a3464 | |||
| 3ca3746cec | |||
| 5e76ddf2cd | |||
| dca1ba304e | |||
| 8dd32afb74 | |||
| 313824b4bb | |||
| b166c0f5ef | |||
| 300e44bd4b | |||
| ab6f983392 | |||
| 596c6395e4 | |||
| 404a36f9b8 | |||
| 1711fbadf7 | |||
| 84b7a6d183 | |||
| 6d0fd0f9ec | |||
| b407ba88c4 | |||
| bd256ba1a6 | |||
| 623c53f79a | |||
| 969fdc8069 | |||
| cbc874dd72 | |||
| 450bd52095 | |||
| 5727fcf177 | |||
| 8ab0c2698b | |||
| 6c7b52d93c | |||
| 91f55cd9a3 | |||
| a1ce459a0e | |||
| 9700992c3a | |||
| f9a1ea72fe | |||
| 507b656eab | |||
| c16776aee9 | |||
| e109e0bd24 | |||
| 776a615464 | |||
| 5514b6cf37 | |||
| 8932d1b8d0 | |||
| 10988847b3 | |||
| c4b139c7a4 | |||
| 130896df1f | |||
| 5d5c519a1d | |||
| 3d1a11f78b | |||
| cc985844cd | |||
| feffbaa5a6 | |||
| d0f0c8ce6d | |||
| 3fdc236b1d | |||
| 46870e163a | |||
| 601f64cc61 | |||
| c015b60dc3 | |||
| 5e01b654bd | |||
| 2304257201 | |||
| 02794d88b9 | |||
| 9f73c8ffad | |||
| c1c354959d | |||
| 94428d9e18 | |||
| 5198ecec1f | |||
| 6779b88055 | |||
| c5dab3a232 | |||
| a7608bcd7e | |||
| be64bc76b5 | |||
| 39bc34fd42 | |||
| 4185303bd2 | |||
| 3280693e8f | |||
| 29432feabc | |||
| 86559c681e | |||
| 79f11b9c33 | |||
| 5b9149cb34 | |||
| 9d6bdd968f | |||
| bc4fec33ef | |||
| 09e917dbe8 | |||
| 1003a0e199 | |||
| e3a805b855 | |||
| 4222176979 | |||
| 43c87fba70 | |||
| d0a23aaf30 | |||
| a09a5686d7 | |||
| 609bb317d0 | |||
| 898fb7d557 | |||
| c39f258a19 | |||
| 4fdd4e1935 | |||
| 7662011d60 | |||
| c24372b308 | |||
| 5e4c53113a | |||
| 4f93995bbd | |||
| 5b14466059 | |||
| 1d3aa85446 | |||
| 6efe70d751 | |||
| 555c88855c | |||
| 105aacc133 | |||
| ea9000f2b0 | |||
| 4e851d9b73 | |||
| 0a1e512f41 | |||
| a7baef2c9d | |||
| 723ec937ad | |||
| 7c77ba83f8 | |||
| 6da4b96b24 | |||
| e8f8593555 | |||
| 2b5bc5dd08 | |||
| cf6186aa16 | |||
| 4d7773a2ac | |||
| e8f74399f2 | |||
| ca72f7adb5 | |||
| 5e19a8b886 | |||
| a416f772d4 | |||
| 989a6b5554 | |||
| 732af15d9b | |||
| 8cdab36cd6 | |||
| 44180c7e0f | |||
| e589e37640 | |||
| 94107de97d | |||
| 13c55dc23e | |||
| 617eddc030 | |||
| 7475b19547 | |||
| 0049ace91a | |||
| 356f4df9a9 | |||
| ff5928b556 | |||
| 1f0ac2a2e9 | |||
| 95628f07d1 | |||
| 3bead4f1b3 | |||
| ec9b23f797 | |||
| 8175ca7e82 | |||
| 451ebbe91a | |||
| da2313ab57 | |||
| c5571e7d17 | |||
| 959157255f | |||
| 06d8012675 | |||
| 571320630b | |||
| 207dee9932 | |||
| d7b0ca77e9 | |||
| e55642cdeb | |||
| 595fd74662 | |||
| 3f7becf580 | |||
| 5d17555744 | |||
| e6d94f248c | |||
| b0c70bc62e | |||
| 8eb0b11027 | |||
| 7f2cfe94c1 | |||
| e4524bda0b | |||
| 226fb15eb1 | |||
| 645c4af2f2 | |||
| 6e0f41c7fd | |||
| b9001ed9b2 | |||
| 04abf59521 | |||
| 251f92532d | |||
| f5df56687b | |||
| b582da90e5 | |||
| 815f48fe06 | |||
| 1470fa87dd | |||
| 4b4356aaab | |||
| a8658856ca | |||
| 1477e907e6 | |||
| f559cea826 | |||
| d363042036 | |||
| 69e4ecd0a9 | |||
| 35d2e06625 | |||
| 358e654f51 | |||
| d16548e570 | |||
| c7201dd62c | |||
| e43a0e62b7 | |||
| 4bcf76819c | |||
| 31155c909c | |||
| ab2670358a | |||
| 3da70bdccc | |||
| e370e1937c | |||
| d9f6dd33d4 | |||
| e5d6e549bd | |||
| 145c0ce6c8 | |||
| a0174b94c6 | |||
| 109b489104 | |||
| 784c3fc338 | |||
| 77d6ac2caf | |||
| 321af22775 | |||
| 39ef9815e8 | |||
| bb3afba11f | |||
| e4fa160a90 | |||
| 34df9e2257 | |||
| cfdb5f021e | |||
| d08eea5c1e | |||
| ce30b5427b | |||
| e38fed89e9 | |||
| d4b12bf3f7 | |||
| 40d75a91c6 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -68,3 +68,4 @@ crashlytics-build.properties
|
||||
/UserSettings
|
||||
/*.zip
|
||||
*.lnk
|
||||
/HybridCLRData
|
||||
|
||||
Binary file not shown.
BIN
Assets/Animations/IConfig.anim
Normal file
BIN
Assets/Animations/IConfig.anim
Normal file
Binary file not shown.
8
Assets/Animations/IConfig.anim.meta
Normal file
8
Assets/Animations/IConfig.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e0c61e29fd90f04b9e41265d93e2029
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
Binary file not shown.
BIN
Assets/Animations/TConfig_Main.anim
Normal file
BIN
Assets/Animations/TConfig_Main.anim
Normal file
Binary file not shown.
8
Assets/Animations/TConfig_Main.anim.meta
Normal file
8
Assets/Animations/TConfig_Main.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d815e4d844e6a1c4d849e96e199f8881
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Animations/TMain_Config.anim
Normal file
BIN
Assets/Animations/TMain_Config.anim
Normal file
Binary file not shown.
8
Assets/Animations/TMain_Config.anim.meta
Normal file
8
Assets/Animations/TMain_Config.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82867c59112ff5a419fbea2ebff2d3b9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,8 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyCompany("Cryville")]
|
||||
[assembly: AssemblyCopyright("Copyright © Cryville 2020-2022")]
|
||||
[assembly: AssemblyDefaultAlias("Cosmo Resona")]
|
||||
[assembly: AssemblyProduct("Cosmo Resona")]
|
||||
[assembly: AssemblyTitle("Cosmo Resona")]
|
||||
[assembly: AssemblyVersion("0.5.0")]
|
||||
Binary file not shown.
@@ -33,12 +33,12 @@ namespace Cryville.Common {
|
||||
public override object ChangeType(object value, Type type, CultureInfo culture) {
|
||||
if (value == null)
|
||||
return null;
|
||||
else if (type == value.GetType())
|
||||
else if (type.IsAssignableFrom(value.GetType()))
|
||||
return value;
|
||||
else if (type.IsEnum && value is string) {
|
||||
return Enum.Parse(type, (string)value);
|
||||
}
|
||||
throw new InvalidCastException();
|
||||
throw new InvalidCastException(string.Format("Cannot cast {0} to {1}", value.GetType(), type));
|
||||
}
|
||||
|
||||
public override void ReorderArgumentArray(ref object[] args, object state) {
|
||||
|
||||
90
Assets/Cryville/Common/Buffers/CategorizedPool.cs
Normal file
90
Assets/Cryville/Common/Buffers/CategorizedPool.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
/// A set of resource pools categorized by a category type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TCategory">The category type.</typeparam>
|
||||
/// <typeparam name="TObject">The type of the objects in the pool.</typeparam>
|
||||
public abstract class CategorizedPool<TCategory, TObject> where TObject : class {
|
||||
/// <summary>
|
||||
/// The set of underlying pools.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The <see cref="Rent(TCategory)" /> and <see cref="Return(TCategory, TObject)" /> method select an underlying pool directly from this set with the category as the key. When overridden, this set must be available since construction.</para>
|
||||
/// </remarks>
|
||||
protected abstract IReadOnlyDictionary<TCategory, ObjectPool<TObject>> Buckets { get; }
|
||||
/// <summary>
|
||||
/// The count of objects rented from the set of pools.
|
||||
/// </summary>
|
||||
public int RentedCount { get; private set; }
|
||||
/// <summary>
|
||||
/// Rents an object from the pool.
|
||||
/// </summary>
|
||||
/// <param name="category">The category.</param>
|
||||
/// <returns>The rented object.</returns>
|
||||
public TObject Rent(TCategory category) {
|
||||
var obj = Buckets[category].Rent();
|
||||
RentedCount++;
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a rented object to the pool.
|
||||
/// </summary>
|
||||
/// <param name="category">The category.</param>
|
||||
/// <param name="obj">The object to return.</param>
|
||||
public void Return(TCategory category, TObject obj) {
|
||||
Buckets[category].Return(obj);
|
||||
--RentedCount;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// A utility to access a categorized pool, representing a single unit that uses a shared categorized pool.
|
||||
/// </summary>
|
||||
/// <typeparam name="TCategory">The category type.</typeparam>
|
||||
/// <typeparam name="TObject">The type of the objects in the pool.</typeparam>
|
||||
public class CategorizedPoolAccessor<TCategory, TObject> where TObject : class {
|
||||
readonly CategorizedPool<TCategory, TObject> _pool;
|
||||
static readonly SimpleObjectPool<Dictionary<TObject, TCategory>> _dictPool
|
||||
= new SimpleObjectPool<Dictionary<TObject, TCategory>>(1024);
|
||||
Dictionary<TObject, TCategory> _rented;
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="CategorizedPoolAccessor{TCategory, TObject}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="pool">The categorized pool.</param>
|
||||
public CategorizedPoolAccessor(CategorizedPool<TCategory, TObject> pool) {
|
||||
_pool = pool;
|
||||
}
|
||||
/// <summary>
|
||||
/// Rents an object from the pool.
|
||||
/// </summary>
|
||||
/// <param name="category">The category.</param>
|
||||
/// <returns>The rented object.</returns>
|
||||
public TObject Rent(TCategory category) {
|
||||
var obj = _pool.Rent(category);
|
||||
if (_rented == null) _rented = _dictPool.Rent();
|
||||
_rented.Add(obj, category);
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a rented object to the pool.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to return.</param>
|
||||
public void Return(TObject obj) {
|
||||
_pool.Return(_rented[obj], obj);
|
||||
_rented.Remove(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns all objects rented by this accessor to the pool.
|
||||
/// </summary>
|
||||
public void ReturnAll() {
|
||||
if (_rented == null) return;
|
||||
foreach (var obj in _rented) {
|
||||
_pool.Return(obj.Value, obj.Key);
|
||||
}
|
||||
_rented.Clear();
|
||||
_dictPool.Return(_rented);
|
||||
_rented = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ed0687e714ce1042921c0057f42039f
|
||||
guid: ec18f22479042d747b88c093aa90c5c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -14,6 +14,10 @@
|
||||
_objs = new T[capacity];
|
||||
}
|
||||
/// <summary>
|
||||
/// The count of objects rented from the pool.
|
||||
/// </summary>
|
||||
public int RentedCount { get { return _index; } }
|
||||
/// <summary>
|
||||
/// Rents a object from the pool.
|
||||
/// </summary>
|
||||
/// <returns>The rented object.</returns>
|
||||
@@ -24,6 +28,7 @@
|
||||
_objs[_index++] = null;
|
||||
}
|
||||
if (obj == null) obj = Construct();
|
||||
else Reset(obj);
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -38,5 +43,10 @@
|
||||
/// </summary>
|
||||
/// <returns>The new instance.</returns>
|
||||
protected abstract T Construct();
|
||||
/// <summary>
|
||||
/// Resets an object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object.</param>
|
||||
protected virtual void Reset(T obj) { }
|
||||
}
|
||||
}
|
||||
|
||||
135
Assets/Cryville/Common/Buffers/TargetString.cs
Normal file
135
Assets/Cryville/Common/Buffers/TargetString.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
/// An auto-resized <see cref="char" /> array as a variable-length string used as a target that is modified frequently.
|
||||
/// </summary>
|
||||
public class TargetString : IEnumerable<char> {
|
||||
public event Action OnUpdate;
|
||||
char[] _arr;
|
||||
bool _invalidated;
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="TargetString" /> class with a capacity of 16.
|
||||
/// </summary>
|
||||
public TargetString() : this(16) { }
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="TargetString" /> class.
|
||||
/// </summary>
|
||||
/// <param name="capacity">The initial capacity of the string.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity" /> is less than or equal to 0.</exception>
|
||||
public TargetString(int capacity) {
|
||||
if (capacity <= 0) throw new ArgumentOutOfRangeException("capacity");
|
||||
_arr = new char[capacity];
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets one of the characters in the string.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the character.</param>
|
||||
/// <returns>The character at the given index.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> is less than 0 or not less than <see cref="Length" />.</exception>
|
||||
/// <remarks>
|
||||
/// <para>Set <see cref="Length" /> to a desired value before updating the characters.</para>
|
||||
/// <para>Call <see cref=" Validate" /> after all the characters are updated.</para>
|
||||
/// </remarks>
|
||||
public char this[int index] {
|
||||
get {
|
||||
if (index < 0 || index >= m_length)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
return _arr[index];
|
||||
}
|
||||
set {
|
||||
if (index < 0 || index >= m_length)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
if (_arr[index] == value) return;
|
||||
_arr[index] = value;
|
||||
_invalidated = true;
|
||||
}
|
||||
}
|
||||
int m_length;
|
||||
/// <summary>
|
||||
/// The length of the string.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentOutOfRangeException">The value specified for a set operation is less than 0.</exception>
|
||||
public int Length {
|
||||
get {
|
||||
return m_length;
|
||||
}
|
||||
set {
|
||||
if (Length < 0) throw new ArgumentOutOfRangeException("length");
|
||||
if (m_length == value) return;
|
||||
if (_arr.Length < value) {
|
||||
var len = _arr.Length;
|
||||
while (len < value) len *= 2;
|
||||
var arr2 = new char[len];
|
||||
Array.Copy(_arr, arr2, m_length);
|
||||
_arr = arr2;
|
||||
}
|
||||
m_length = value;
|
||||
_invalidated = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Validates the string.
|
||||
/// </summary>
|
||||
public void Validate() {
|
||||
if (!_invalidated) return;
|
||||
_invalidated = false;
|
||||
var ev = OnUpdate;
|
||||
if (ev != null) ev.Invoke();
|
||||
}
|
||||
internal char[] TrustedAsArray() { return _arr; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates through the <see cref="TargetString" />.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Enumerator" /> for the <see cref="TargetString" />.</returns>
|
||||
public Enumerator GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
IEnumerator<char> IEnumerable<char>.GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
public struct Enumerator : IEnumerator<char> {
|
||||
readonly TargetString _self;
|
||||
int _index;
|
||||
internal Enumerator(TargetString self) {
|
||||
_self = self;
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
public char Current {
|
||||
get {
|
||||
if (_index < 0)
|
||||
throw new InvalidOperationException(_index == -1 ? "Enum not started" : "Enum ended");
|
||||
return _self[_index];
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
|
||||
public void Dispose() {
|
||||
_index = -2;
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
if (_index == -2) return false;
|
||||
_index++;
|
||||
if (_index >= _self.Length) {
|
||||
_index = -2;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
_index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6a3a023271b82a4985d1bbcc86e6fa8
|
||||
guid: f0fc34ac257793d4883a9cfcdb6941b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9bd9e24d7c553341a2a12391843542f
|
||||
guid: c4ef48e4a4983de4e9c31483df2a918e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
8
Assets/Cryville/Common/Collections/Generic.meta
Normal file
8
Assets/Cryville/Common/Collections/Generic.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ec674235c0dd6744af2dab2b58dd53c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Cryville/Common/Collections/Generic/IPairList.cs
Normal file
8
Assets/Cryville/Common/Collections/Generic/IPairList.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Collections.Generic {
|
||||
public interface IPairList<TKey, TValue> : IList<KeyValuePair<TKey, TValue>> {
|
||||
void Add(TKey key, TValue value);
|
||||
void Insert(int index, TKey key, TValue value);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3c5a8bf05d5e284ba498e91cb0dd35e
|
||||
guid: 73fb17b484b343242bcce27c15ed7d44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
46
Assets/Cryville/Common/Collections/Generic/PairCollection.cs
Normal file
46
Assets/Cryville/Common/Collections/Generic/PairCollection.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Cryville.Common.Collections.Generic {
|
||||
[DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairCollectionDebugView<,>))]
|
||||
public struct PairCollection<TKey, TValue> : IDisposable {
|
||||
public void Dispose() { }
|
||||
readonly IPairList<TKey, TValue> _pairList;
|
||||
readonly IDictionary<TKey, TValue> _dictionary;
|
||||
public PairCollection(object collection) : this() {
|
||||
var type = collection.GetType();
|
||||
if (typeof(IPairList<TKey, TValue>).IsAssignableFrom(type)) _pairList = (IPairList<TKey, TValue>)collection;
|
||||
else if (typeof(IDictionary<TKey, TValue>).IsAssignableFrom(type)) _dictionary = (IDictionary<TKey, TValue>)collection;
|
||||
else throw new ArgumentException("Parameter is not a pair collection");
|
||||
}
|
||||
public int Count {
|
||||
get {
|
||||
if (_pairList != null) return _pairList.Count;
|
||||
else return _dictionary.Count;
|
||||
}
|
||||
}
|
||||
public void Add(TKey key, TValue value) {
|
||||
if (_pairList != null) _pairList.Add(key, value);
|
||||
else _dictionary.Add(key, value);
|
||||
}
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int index) {
|
||||
if (_pairList != null) _pairList.CopyTo(array, index);
|
||||
else _dictionary.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
internal class PairCollectionDebugView<TKey, TValue> {
|
||||
readonly PairCollection<TKey, TValue> _self;
|
||||
public PairCollectionDebugView(PairCollection<TKey, TValue> self) {
|
||||
_self = self;
|
||||
}
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||
public KeyValuePair<TKey, TValue>[] Items {
|
||||
get {
|
||||
KeyValuePair<TKey, TValue>[] array = new KeyValuePair<TKey, TValue>[_self.Count];
|
||||
_self.CopyTo(array, 0);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2517e8f040bd36f46948e5fafaf5335c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user