Initial commit of Unity files, Network Library, Project settings (Compiler flags for networking to work on Unity), Unity Version 2019.4 LTS
This commit is contained in:
parent
8ec6828fa0
commit
9b69003715
119 changed files with 15444 additions and 0 deletions
55
Assets/Runtime/Extensions/DoubleDictionary.cs
Normal file
55
Assets/Runtime/Extensions/DoubleDictionary.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class DoubleDictionary<Key, Value>{
|
||||
|
||||
static Dictionary<Key, Value> keys;
|
||||
static Dictionary<Value, Key> values;
|
||||
|
||||
static DoubleDictionary(){
|
||||
Create();
|
||||
}
|
||||
|
||||
public static void Create(){
|
||||
keys = new Dictionary<Key, Value>();
|
||||
values = new Dictionary<Value, Key>();
|
||||
}
|
||||
|
||||
public static void Set(Key key, Value value){
|
||||
keys.Add(key, value);
|
||||
values.Add(value, key);
|
||||
}
|
||||
|
||||
public static void Remove(Key key){
|
||||
Value value;
|
||||
if (keys.TryGetValue(key, out value)){
|
||||
keys.Remove(key);
|
||||
values.Remove(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Remove(Value value){
|
||||
Key key;
|
||||
if (values.TryGetValue(value, out key)){
|
||||
keys.Remove(key);
|
||||
values.Remove(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Remove(Key key, Value value){
|
||||
keys.Remove(key);
|
||||
values.Remove(value);
|
||||
}
|
||||
|
||||
public static Key Get(Value value){
|
||||
Key key;
|
||||
return values.TryGetValue(value, out key) ? key : default;
|
||||
}
|
||||
|
||||
public static Value Get(Key key){
|
||||
Value value;
|
||||
return keys.TryGetValue(key, out value) ? value : default;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Runtime/Extensions/DoubleDictionary.cs.meta
Normal file
11
Assets/Runtime/Extensions/DoubleDictionary.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f87146a5f00172e4c8bde3d6fb4918df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/Runtime/Extensions/StringExtension.cs
Normal file
21
Assets/Runtime/Extensions/StringExtension.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
public static class StringExtensionMethods
|
||||
{
|
||||
public static int GetStableHashCode(this string str)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hash1 = 5381;
|
||||
int hash2 = hash1;
|
||||
|
||||
for(int i = 0; i < str.Length && str[i] != '\0'; i += 2)
|
||||
{
|
||||
hash1 = ((hash1 << 5) + hash1) ^ str[i];
|
||||
if (i == str.Length - 1 || str[i+1] == '\0')
|
||||
break;
|
||||
hash2 = ((hash2 << 5) + hash2) ^ str[i+1];
|
||||
}
|
||||
|
||||
return hash1 + (hash2*1566083941);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Runtime/Extensions/StringExtension.cs.meta
Normal file
11
Assets/Runtime/Extensions/StringExtension.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 91365f7329a827044a590282cb8a77c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue