Add project files.
This commit is contained in:
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[*.cs]
|
||||||
|
|
||||||
|
# IDE0008: Use explicit type
|
||||||
|
dotnet_diagnostic.IDE0008.severity = none
|
||||||
|
csharp_style_var_when_type_is_apparent=false:suggestion
|
||||||
|
csharp_style_var_for_built_in_types=false:suggestion
|
||||||
|
csharp_style_var_elsewhere=false:suggestion
|
||||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -58,3 +58,12 @@ sysinfo.txt
|
|||||||
# Crashlytics generated file
|
# Crashlytics generated file
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
|
|
||||||
|
#
|
||||||
|
/Docs
|
||||||
|
/Issues
|
||||||
|
/Obsolete
|
||||||
|
/Snapshots
|
||||||
|
/UI
|
||||||
|
/UserSettings
|
||||||
|
/*.zip
|
||||||
|
*.lnk
|
||||||
|
|||||||
6
.vsconfig
Normal file
6
.vsconfig
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"components": [
|
||||||
|
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||||
|
]
|
||||||
|
}
|
||||||
9
Assets/Animations.meta
Normal file
9
Assets/Animations.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ff84d017aa87efe40a398305f6c66f4d
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1611481582
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/Canvas.controller
Normal file
BIN
Assets/Animations/Canvas.controller
Normal file
Binary file not shown.
8
Assets/Animations/Canvas.controller.meta
Normal file
8
Assets/Animations/Canvas.controller.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c96c5f91fd684d14d9d4c09a5f34ee5d
|
||||||
|
timeCreated: 1637144068
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/IMain.anim
Normal file
BIN
Assets/Animations/IMain.anim
Normal file
Binary file not shown.
8
Assets/Animations/IMain.anim.meta
Normal file
8
Assets/Animations/IMain.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2162866fb7549724a85cb3c854a136ad
|
||||||
|
timeCreated: 1637144548
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/IQuit.anim
Normal file
BIN
Assets/Animations/IQuit.anim
Normal file
Binary file not shown.
8
Assets/Animations/IQuit.anim.meta
Normal file
8
Assets/Animations/IQuit.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e50faab4238b5548bb05a7d421f5405
|
||||||
|
timeCreated: 1637145598
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/ISettings.anim
Normal file
BIN
Assets/Animations/ISettings.anim
Normal file
Binary file not shown.
8
Assets/Animations/ISettings.anim.meta
Normal file
8
Assets/Animations/ISettings.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b9f1682ee8026b468ad15885e1ff6a5
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/IStartup.anim
Normal file
BIN
Assets/Animations/IStartup.anim
Normal file
Binary file not shown.
8
Assets/Animations/IStartup.anim.meta
Normal file
8
Assets/Animations/IStartup.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9d0c0a0c88a0e7a43b77b0065bb64721
|
||||||
|
timeCreated: 1637144134
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/TMain_Settings.anim
Normal file
BIN
Assets/Animations/TMain_Settings.anim
Normal file
Binary file not shown.
8
Assets/Animations/TMain_Settings.anim.meta
Normal file
8
Assets/Animations/TMain_Settings.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 961473ba26b4b1942806c224266f8db7
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/TQuit_.anim
Normal file
BIN
Assets/Animations/TQuit_.anim
Normal file
Binary file not shown.
8
Assets/Animations/TQuit_.anim.meta
Normal file
8
Assets/Animations/TQuit_.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0cc97e0bf50ad9c4e834c28e6eddf416
|
||||||
|
timeCreated: 1637145877
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/TSettings_Main.anim
Normal file
BIN
Assets/Animations/TSettings_Main.anim
Normal file
Binary file not shown.
8
Assets/Animations/TSettings_Main.anim.meta
Normal file
8
Assets/Animations/TSettings_Main.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f6fb5723dba03d42b9e8a3c3e9091a5
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/TStartup_Main.anim
Normal file
BIN
Assets/Animations/TStartup_Main.anim
Normal file
Binary file not shown.
8
Assets/Animations/TStartup_Main.anim.meta
Normal file
8
Assets/Animations/TStartup_Main.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 63a0e2075f5ba8d489d8cd318c14720b
|
||||||
|
timeCreated: 1637144068
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Animations/T_Quit.anim
Normal file
BIN
Assets/Animations/T_Quit.anim
Normal file
Binary file not shown.
8
Assets/Animations/T_Quit.anim.meta
Normal file
8
Assets/Animations/T_Quit.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cc249d3462d795b46aff263bc04baee2
|
||||||
|
timeCreated: 1637144561
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Config.unity
Normal file
BIN
Assets/Config.unity
Normal file
Binary file not shown.
7
Assets/Config.unity.meta
Normal file
7
Assets/Config.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 215ebdd4cb9187741a2e24f5e7d8511d
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Console.unity
Normal file
BIN
Assets/Console.unity
Normal file
Binary file not shown.
8
Assets/Console.unity.meta
Normal file
8
Assets/Console.unity.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a36c371ab6077d43ac28fe09b0fe675
|
||||||
|
timeCreated: 1620725915
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/Cryville.meta
Normal file
9
Assets/Cryville.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bdfbc84283159e8429c29a3d47e35bad
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1605323574
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/Cryville/Common.meta
Normal file
9
Assets/Cryville/Common.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d213440bfd40d0d49a2950e04f3008ab
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1594270605
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
Assets/Cryville/Common/AsyncDelivery.cs
Normal file
14
Assets/Cryville/Common/AsyncDelivery.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Common {
|
||||||
|
public class AsyncDelivery<T> {
|
||||||
|
public Action CancelSource { private get; set; }
|
||||||
|
public Action<bool, T> Destination { private get; set; }
|
||||||
|
public void Deliver(bool succeeded, T result) {
|
||||||
|
if (Destination != null) Destination(succeeded, result);
|
||||||
|
}
|
||||||
|
public void Cancel() {
|
||||||
|
if (CancelSource != null) CancelSource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Cryville/Common/AsyncDelivery.cs.meta
Normal file
12
Assets/Cryville/Common/AsyncDelivery.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 857c1f0e990462a47bd0ed83448f923b
|
||||||
|
timeCreated: 1637755775
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
59
Assets/Cryville/Common/BinderAttribute.cs
Normal file
59
Assets/Cryville/Common/BinderAttribute.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Cryville.Common {
|
||||||
|
public class BinderAttribute : Attribute {
|
||||||
|
public BinderAttribute(Type type) {
|
||||||
|
BinderType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type BinderType;
|
||||||
|
|
||||||
|
public static Binder CreateBinderOfType(Type type) {
|
||||||
|
var l = type.GetCustomAttributes(typeof(BinderAttribute), true);
|
||||||
|
if (l.Length > 0) {
|
||||||
|
return (Binder)ReflectionHelper.InvokeEmptyConstructor(
|
||||||
|
((BinderAttribute)l[0]).BinderType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return new EmptyBinder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EmptyBinder : Binder {
|
||||||
|
/*static readonly Type[] emptyTypeArray = {};
|
||||||
|
static readonly object[] emptyObjectArray = {};*/
|
||||||
|
|
||||||
|
public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ChangeType(object value, Type type, CultureInfo culture) {
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
else if (type == value.GetType())
|
||||||
|
return value;
|
||||||
|
else if (type.IsEnum && value is string) {
|
||||||
|
return Enum.Parse(type, (string)value);
|
||||||
|
}
|
||||||
|
throw new InvalidCastException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ReorderArgumentArray(ref object[] args, object state) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Cryville/Common/BinderAttribute.cs.meta
Normal file
12
Assets/Cryville/Common/BinderAttribute.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 146a308dba289ad4f91c07c69bb4688b
|
||||||
|
timeCreated: 1608801352
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Cryville/Common/Buffers.meta
Normal file
8
Assets/Cryville/Common/Buffers.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 53f4e3167a1eee2478b0abc6302aee8f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
65
Assets/Cryville/Common/Buffers/ArrayPool.cs
Normal file
65
Assets/Cryville/Common/Buffers/ArrayPool.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
/// <summary>
|
||||||
|
/// A resource pool that allows reusing instances of arrays of type <typeparamref name="T" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The item type of the arrays in the pool.</typeparam>
|
||||||
|
public class ArrayPool<T> {
|
||||||
|
private class Bucket : ObjectPool<T[]> {
|
||||||
|
readonly int _size;
|
||||||
|
public Bucket(int size, int capacity) : base(capacity) {
|
||||||
|
_size = size;
|
||||||
|
}
|
||||||
|
protected override T[] Construct() {
|
||||||
|
return new T[_size];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bucket[] _buckets;
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="ArrayPool{T}" /> class with the default maximum list size and bucket capacity.
|
||||||
|
/// </summary>
|
||||||
|
public ArrayPool() : this(0x40000000, 256) { }
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="ArrayPool{T}" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="maxSize">The maximum size of the arrays in the pool.</param>
|
||||||
|
/// <param name="capacityPerBucket">The capacity of each bucket. The pool groups arrays of similar sizes into buckets for faster access.</param>
|
||||||
|
public ArrayPool(int maxSize, int capacityPerBucket) {
|
||||||
|
if (maxSize < 16) maxSize = 16;
|
||||||
|
int num = GetID(maxSize) + 1;
|
||||||
|
_buckets = new Bucket[num];
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
_buckets[i] = new Bucket(GetSize(i), capacityPerBucket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Rents an array that is at least the specified size from the pool.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="size">The minimum size of the array.</param>
|
||||||
|
/// <returns>An array of type <see cref="T" /> that is at least the specified size.</returns>
|
||||||
|
public T[] Rent(int size) {
|
||||||
|
int len2 = size;
|
||||||
|
if (len2 < 16) len2 = 16;
|
||||||
|
var arr = _buckets[GetID(len2)].Rent();
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a rented array to the pool.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arr">The array to return.</param>
|
||||||
|
public void Return(T[] arr) {
|
||||||
|
int len2 = arr.Length;
|
||||||
|
if (len2 < 16) len2 = 16;
|
||||||
|
_buckets[GetID(len2)].Return(arr);
|
||||||
|
}
|
||||||
|
static int GetID(int size) {
|
||||||
|
size -= 1;
|
||||||
|
size >>= 4;
|
||||||
|
int num = 0;
|
||||||
|
for (; size != 0; size >>= 1) num++;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
static int GetSize(int id) {
|
||||||
|
return 0x10 << id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Buffers/ArrayPool.cs.meta
Normal file
11
Assets/Cryville/Common/Buffers/ArrayPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: df66519fa93e1b94ea5bb1702cc91b3f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
71
Assets/Cryville/Common/Buffers/ListPool.cs
Normal file
71
Assets/Cryville/Common/Buffers/ListPool.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
/// <summary>
|
||||||
|
/// A resource pool that allows reusing instances of lists of type <typeparamref name="T" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The item type of the lists in the pool.</typeparam>
|
||||||
|
public class ListPool<T> {
|
||||||
|
private class Bucket : ObjectPool<List<T>> {
|
||||||
|
readonly int _size;
|
||||||
|
public Bucket(int size, int capacity) : base(capacity) {
|
||||||
|
_size = size;
|
||||||
|
}
|
||||||
|
protected override List<T> Construct() {
|
||||||
|
return new List<T>(_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bucket[] _buckets;
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="ListPool{T}" /> class with the default maximum list size and bucket capacity.
|
||||||
|
/// </summary>
|
||||||
|
public ListPool() : this(0x40000000, 256) { }
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="ListPool{T}" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="maxSize">The maximum size of the lists in the pool.</param>
|
||||||
|
/// <param name="capacityPerBucket">The capacity of each bucket. The pool groups lists of similar sizes into buckets for faster access.</param>
|
||||||
|
public ListPool(int maxSize, int capacityPerBucket) {
|
||||||
|
if (maxSize < 16) maxSize = 16;
|
||||||
|
int num = GetID(maxSize) + 1;
|
||||||
|
_buckets = new Bucket[num];
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
_buckets[i] = new Bucket(GetSize(i), capacityPerBucket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Rents a list of the specified size from the pool. The size of the list must not be changed when it is rented.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="size">The size of the list.</param>
|
||||||
|
/// <returns>A <see cref="List{T}" /> of the specified size.</returns>
|
||||||
|
public List<T> Rent(int size) {
|
||||||
|
int len2 = size;
|
||||||
|
if (len2 < 16) len2 = 16;
|
||||||
|
var list = _buckets[GetID(len2)].Rent();
|
||||||
|
if (list.Count < size)
|
||||||
|
for (int i = list.Count; i < size; i++) list.Add(default(T));
|
||||||
|
else if (list.Count > size)
|
||||||
|
list.RemoveRange(size, list.Count - size);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a rented list to the pool.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">The list to return.</param>
|
||||||
|
public void Return(List<T> list) {
|
||||||
|
int len2 = list.Capacity;
|
||||||
|
if (len2 < 16) len2 = 16;
|
||||||
|
_buckets[GetID(len2)].Return(list);
|
||||||
|
}
|
||||||
|
static int GetID(int size) {
|
||||||
|
size -= 1;
|
||||||
|
size >>= 4;
|
||||||
|
int num = 0;
|
||||||
|
for (; size != 0; size >>= 1) num++;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
static int GetSize(int id) {
|
||||||
|
return 0x10 << id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Buffers/ListPool.cs.meta
Normal file
11
Assets/Cryville/Common/Buffers/ListPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b7b45ff20c33ac47b476371673b037c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
42
Assets/Cryville/Common/Buffers/ObjectPool.cs
Normal file
42
Assets/Cryville/Common/Buffers/ObjectPool.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
/// <summary>
|
||||||
|
/// A resource pool that allows reusing instances of type <typeparamref name="T" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the objects in the pool.</typeparam>
|
||||||
|
public abstract class ObjectPool<T> where T : class {
|
||||||
|
int _index;
|
||||||
|
readonly T[] _objs;
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="ObjectPool{T}" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capacity">The capacity of the pool.</param>
|
||||||
|
public ObjectPool(int capacity) {
|
||||||
|
_objs = new T[capacity];
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Rents a object from the pool.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The rented object.</returns>
|
||||||
|
public T Rent() {
|
||||||
|
T obj = null;
|
||||||
|
if (_index < _objs.Length) {
|
||||||
|
obj = _objs[_index];
|
||||||
|
_objs[_index++] = null;
|
||||||
|
}
|
||||||
|
if (obj == null) obj = Construct();
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a rented object to the pool.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The object to return.</param>
|
||||||
|
public void Return(T obj) {
|
||||||
|
if (_index > 0) _objs[--_index] = obj;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance of type <typeparamref name="T" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The new instance.</returns>
|
||||||
|
protected abstract T Construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Buffers/ObjectPool.cs.meta
Normal file
11
Assets/Cryville/Common/Buffers/ObjectPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2745c44c3cc32be4ab3a43888c14b9a1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
Assets/Cryville/Common/Buffers/SimpleObjectPool.cs
Normal file
16
Assets/Cryville/Common/Buffers/SimpleObjectPool.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
/// <summary>
|
||||||
|
/// A resource pool that allows reusing instances of type <typeparamref name="T" />, which has a parameterless constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the objects in the pool.</typeparam>
|
||||||
|
public class SimpleObjectPool<T> : ObjectPool<T> where T : class, new() {
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="SimpleObjectPool{T}" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capacity">The capacity of the pool.</param>
|
||||||
|
public SimpleObjectPool(int capacity) : base(capacity) { }
|
||||||
|
protected override T Construct() {
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Buffers/SimpleObjectPool.cs.meta
Normal file
11
Assets/Cryville/Common/Buffers/SimpleObjectPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b8cd439340f088d4eb83711a5bc6384d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
10
Assets/Cryville/Common/Buffers/WStringPool.cs
Normal file
10
Assets/Cryville/Common/Buffers/WStringPool.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
public class WStringPool {
|
||||||
|
public WStringPool() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Buffers/WStringPool.cs.meta
Normal file
11
Assets/Cryville/Common/Buffers/WStringPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 704270b37917aa1458db9d14bab07073
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Cryville/Common/ComponentModel.meta
Normal file
8
Assets/Cryville/Common/ComponentModel.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3c27afc8f4f76d04dac0f0914798ccc0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Common.ComponentModel {
|
||||||
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||||
|
public class LogarithmicScaleAttribute : Attribute {
|
||||||
|
public LogarithmicScaleAttribute() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c1e8a5b839ed6a64dbb9fc6b0bcf7cc2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
12
Assets/Cryville/Common/ComponentModel/PrecisionAttribute.cs
Normal file
12
Assets/Cryville/Common/ComponentModel/PrecisionAttribute.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Common.ComponentModel {
|
||||||
|
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
|
||||||
|
public class PrecisionAttribute : Attribute {
|
||||||
|
public PrecisionAttribute(double precision) {
|
||||||
|
Precision = precision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Precision { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ea83b8e303a1b8b43a2f2ff74a7a9a7a
|
||||||
|
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