diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95bb254 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +[Ll]ibrary/ +[Tt]emp/ +[Oo]bj/ +[Bb]uild/ +[Bb]uilds/ +Assets/AssetStoreTools* + +# Visual Studio cache directory +.vs/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.opendb + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta + +# Unity3D Generated File On Crash Reports +sysinfo.txt + +# Builds +*.apk +*.unitypackage +.idea/ diff --git a/Assets/CodegenExecutor.asset b/Assets/CodegenExecutor.asset new file mode 100644 index 0000000..dce2c0f --- /dev/null +++ b/Assets/CodegenExecutor.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 16d40f4c171d6f647a7e84fcaaf26327, type: 3} + m_Name: CodegenExecutor + m_EditorClassIdentifier: + OutputPath: Sources/Generated diff --git a/Assets/CodegenExecutor.asset.meta b/Assets/CodegenExecutor.asset.meta new file mode 100644 index 0000000..08432ca --- /dev/null +++ b/Assets/CodegenExecutor.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfe90b200262b1b45991edd4f790833b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated.meta b/Assets/Generated.meta new file mode 100644 index 0000000..f4875d3 --- /dev/null +++ b/Assets/Generated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c80740628c7025e4c8a1ba02229082f2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Contexts.cs b/Assets/Generated/Contexts.cs new file mode 100644 index 0000000..a80e8a9 --- /dev/null +++ b/Assets/Generated/Contexts.cs @@ -0,0 +1,124 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ContextsGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class Contexts : Entitas.IContexts { + + public static Contexts sharedInstance { + get { + if (_sharedInstance == null) { + _sharedInstance = new Contexts(); + } + + return _sharedInstance; + } + set { _sharedInstance = value; } + } + + static Contexts _sharedInstance; + + public GameContext game { get; set; } + + public Entitas.IContext[] allContexts { get { return new Entitas.IContext [] { game }; } } + + public Contexts() { + game = new GameContext(); + + var postConstructors = System.Linq.Enumerable.Where( + GetType().GetMethods(), + method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute)) + ); + + foreach (var postConstructor in postConstructors) { + postConstructor.Invoke(this, null); + } + } + + public void Reset() { + var contexts = allContexts; + for (int i = 0; i < contexts.Length; i++) { + contexts[i].Reset(); + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EntityIndexGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class Contexts { + + public const string Connection = "Connection"; + public const string ControlledBy = "ControlledBy"; + public const string Id = "Id"; + + [Entitas.CodeGeneration.Attributes.PostConstructor] + public void InitializeEntityIndices() { + game.AddEntityIndex(new Entitas.PrimaryEntityIndex( + Connection, + game.GetGroup(GameMatcher.Connection), + (e, c) => ((Connection)c).Id)); + + game.AddEntityIndex(new Entitas.PrimaryEntityIndex( + ControlledBy, + game.GetGroup(GameMatcher.ControlledBy), + (e, c) => ((ControlledBy)c).Value)); + + game.AddEntityIndex(new Entitas.PrimaryEntityIndex( + Id, + game.GetGroup(GameMatcher.Id), + (e, c) => ((IdComponent)c).Value)); + } +} + +public static class ContextsExtensions { + + public static GameEntity GetEntityWithConnection(this GameContext context, ushort Id) { + return ((Entitas.PrimaryEntityIndex)context.GetEntityIndex(Contexts.Connection)).GetEntity(Id); + } + + public static GameEntity GetEntityWithControlledBy(this GameContext context, ushort Value) { + return ((Entitas.PrimaryEntityIndex)context.GetEntityIndex(Contexts.ControlledBy)).GetEntity(Value); + } + + public static GameEntity GetEntityWithId(this GameContext context, ushort Value) { + return ((Entitas.PrimaryEntityIndex)context.GetEntityIndex(Contexts.Id)).GetEntity(Value); + } +} +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class Contexts { + +#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR) + + [Entitas.CodeGeneration.Attributes.PostConstructor] + public void InitializeContextObservers() { + try { + CreateContextObserver(game); + } catch(System.Exception) { + } + } + + public void CreateContextObserver(Entitas.IContext context) { + if (UnityEngine.Application.isPlaying) { + var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context); + UnityEngine.Object.DontDestroyOnLoad(observer.gameObject); + } + } + +#endif +} diff --git a/Assets/Generated/Contexts.cs.meta b/Assets/Generated/Contexts.cs.meta new file mode 100644 index 0000000..014af29 --- /dev/null +++ b/Assets/Generated/Contexts.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b477ffa1c2dba4b40941c68b85814921 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Events.meta b/Assets/Generated/Events.meta new file mode 100644 index 0000000..8c4e34c --- /dev/null +++ b/Assets/Generated/Events.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 779317088a284ff1ba1d2b3339ab0331 +timeCreated: 1556833408 \ No newline at end of file diff --git a/Assets/Generated/Events/Components.meta b/Assets/Generated/Events/Components.meta new file mode 100644 index 0000000..6207f2a --- /dev/null +++ b/Assets/Generated/Events/Components.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8d5a79b46f4e4748aa822669026ae728 +timeCreated: 1556833408 \ No newline at end of file diff --git a/Assets/Generated/Events/Components/DestroyedListenerComponent.cs b/Assets/Generated/Events/Components/DestroyedListenerComponent.cs new file mode 100644 index 0000000..4e8c59d --- /dev/null +++ b/Assets/Generated/Events/Components/DestroyedListenerComponent.cs @@ -0,0 +1,12 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +[Entitas.CodeGeneration.Attributes.DontGenerate(false)] +public sealed class DestroyedListenerComponent : Entitas.IComponent { + public System.Collections.Generic.List value; +} diff --git a/Assets/Generated/Events/Components/DestroyedListenerComponent.cs.meta b/Assets/Generated/Events/Components/DestroyedListenerComponent.cs.meta new file mode 100644 index 0000000..1ee43e6 --- /dev/null +++ b/Assets/Generated/Events/Components/DestroyedListenerComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f980e7c5350e48fcb6ca16e676d9fd4d +timeCreated: 1556833466 \ No newline at end of file diff --git a/Assets/Generated/Events/GameEventSystems.cs b/Assets/Generated/Events/GameEventSystems.cs new file mode 100644 index 0000000..cfcefee --- /dev/null +++ b/Assets/Generated/Events/GameEventSystems.cs @@ -0,0 +1,14 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EventSystemsGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed class GameEventSystems : Feature { + + public GameEventSystems(Contexts contexts) { + Add(new DestroyedEventSystem(contexts)); // priority: 0 + } +} diff --git a/Assets/Generated/Events/GameEventSystems.cs.meta b/Assets/Generated/Events/GameEventSystems.cs.meta new file mode 100644 index 0000000..a292d00 --- /dev/null +++ b/Assets/Generated/Events/GameEventSystems.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5961e8f36b0b46fcb7afb02bb69478b6 +timeCreated: 1556833408 \ No newline at end of file diff --git a/Assets/Generated/Events/Interfaces.meta b/Assets/Generated/Events/Interfaces.meta new file mode 100644 index 0000000..ab422d7 --- /dev/null +++ b/Assets/Generated/Events/Interfaces.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3d3d9084a43b4ebe8928a272840a1ccb +timeCreated: 1556833408 \ No newline at end of file diff --git a/Assets/Generated/Events/Interfaces/IDestroyedListener.cs b/Assets/Generated/Events/Interfaces/IDestroyedListener.cs new file mode 100644 index 0000000..8d46f0d --- /dev/null +++ b/Assets/Generated/Events/Interfaces/IDestroyedListener.cs @@ -0,0 +1,11 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EventListenertInterfaceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public interface IDestroyedListener { + void OnDestroyed(GameEntity entity); +} diff --git a/Assets/Generated/Events/Interfaces/IDestroyedListener.cs.meta b/Assets/Generated/Events/Interfaces/IDestroyedListener.cs.meta new file mode 100644 index 0000000..16018fa --- /dev/null +++ b/Assets/Generated/Events/Interfaces/IDestroyedListener.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3954a8b58c974ffab194f1dd71033072 +timeCreated: 1556833466 \ No newline at end of file diff --git a/Assets/Generated/Events/Systems.meta b/Assets/Generated/Events/Systems.meta new file mode 100644 index 0000000..5e13c74 --- /dev/null +++ b/Assets/Generated/Events/Systems.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3f8e737659cd4d0cadee54ce117ac396 +timeCreated: 1556833408 \ No newline at end of file diff --git a/Assets/Generated/Events/Systems/DestroyedEventSystem.cs b/Assets/Generated/Events/Systems/DestroyedEventSystem.cs new file mode 100644 index 0000000..ec47836 --- /dev/null +++ b/Assets/Generated/Events/Systems/DestroyedEventSystem.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EventSystemGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed class DestroyedEventSystem : Entitas.ReactiveSystem { + + readonly System.Collections.Generic.List _listenerBuffer; + + public DestroyedEventSystem(Contexts contexts) : base(contexts.game) { + _listenerBuffer = new System.Collections.Generic.List(); + } + + protected override Entitas.ICollector GetTrigger(Entitas.IContext context) { + return Entitas.CollectorContextExtension.CreateCollector( + context, Entitas.TriggerOnEventMatcherExtension.Added(GameMatcher.Destroyed) + ); + } + + protected override bool Filter(GameEntity entity) { + return entity.isDestroyed && entity.hasDestroyedListener; + } + + protected override void Execute(System.Collections.Generic.List entities) { + foreach (var e in entities) { + + _listenerBuffer.Clear(); + _listenerBuffer.AddRange(e.destroyedListener.value); + foreach (var listener in _listenerBuffer) { + listener.OnDestroyed(e); + } + } + } +} diff --git a/Assets/Generated/Events/Systems/DestroyedEventSystem.cs.meta b/Assets/Generated/Events/Systems/DestroyedEventSystem.cs.meta new file mode 100644 index 0000000..5184357 --- /dev/null +++ b/Assets/Generated/Events/Systems/DestroyedEventSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f05154bca9f94378a5019b8ce41eb39e +timeCreated: 1556833466 \ No newline at end of file diff --git a/Assets/Generated/Feature.cs b/Assets/Generated/Feature.cs new file mode 100644 index 0000000..afa80bc --- /dev/null +++ b/Assets/Generated/Feature.cs @@ -0,0 +1,110 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR) + +public class Feature : Entitas.VisualDebugging.Unity.DebugSystems { + + public Feature(string name) : base(name) { + } + + public Feature() : base(true) { + var typeName = DesperateDevs.Utils.SerializationTypeExtension.ToCompilableString(GetType()); + var shortType = DesperateDevs.Utils.SerializationTypeExtension.ShortTypeName(typeName); + var readableType = DesperateDevs.Utils.StringExtension.ToSpacedCamelCase(shortType); + + initialize(readableType); + } +} + +#elif (!ENTITAS_DISABLE_DEEP_PROFILING && DEVELOPMENT_BUILD) + +public class Feature : Entitas.Systems { + + System.Collections.Generic.List _initializeSystemNames; + System.Collections.Generic.List _executeSystemNames; + System.Collections.Generic.List _cleanupSystemNames; + System.Collections.Generic.List _tearDownSystemNames; + + public Feature(string name) : this() { + } + + public Feature() { + _initializeSystemNames = new System.Collections.Generic.List(); + _executeSystemNames = new System.Collections.Generic.List(); + _cleanupSystemNames = new System.Collections.Generic.List(); + _tearDownSystemNames = new System.Collections.Generic.List(); + } + + public override Entitas.Systems Add(Entitas.ISystem system) { + var systemName = system.GetType().FullName; + + if (system is Entitas.IInitializeSystem) { + _initializeSystemNames.Add(systemName); + } + + if (system is Entitas.IExecuteSystem) { + _executeSystemNames.Add(systemName); + } + + if (system is Entitas.ICleanupSystem) { + _cleanupSystemNames.Add(systemName); + } + + if (system is Entitas.ITearDownSystem) { + _tearDownSystemNames.Add(systemName); + } + + return base.Add(system); + } + + public override void Initialize() { + for (int i = 0; i < _initializeSystems.Count; i++) { + UnityEngine.Profiling.Profiler.BeginSample(_initializeSystemNames[i]); + _initializeSystems[i].Initialize(); + UnityEngine.Profiling.Profiler.EndSample(); + } + } + + public override void Execute() { + for (int i = 0; i < _executeSystems.Count; i++) { + UnityEngine.Profiling.Profiler.BeginSample(_executeSystemNames[i]); + _executeSystems[i].Execute(); + UnityEngine.Profiling.Profiler.EndSample(); + } + } + + public override void Cleanup() { + for (int i = 0; i < _cleanupSystems.Count; i++) { + UnityEngine.Profiling.Profiler.BeginSample(_cleanupSystemNames[i]); + _cleanupSystems[i].Cleanup(); + UnityEngine.Profiling.Profiler.EndSample(); + } + } + + public override void TearDown() { + for (int i = 0; i < _tearDownSystems.Count; i++) { + UnityEngine.Profiling.Profiler.BeginSample(_tearDownSystemNames[i]); + _tearDownSystems[i].TearDown(); + UnityEngine.Profiling.Profiler.EndSample(); + } + } +} + +#else + +public class Feature : Entitas.Systems { + + public Feature(string name) { + } + + public Feature() { + } +} + +#endif diff --git a/Assets/Generated/Feature.cs.meta b/Assets/Generated/Feature.cs.meta new file mode 100644 index 0000000..825130a --- /dev/null +++ b/Assets/Generated/Feature.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df0b9bce881f899489edf2ddd86f8a4b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game.meta b/Assets/Generated/Game.meta new file mode 100644 index 0000000..2852b3f --- /dev/null +++ b/Assets/Generated/Game.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: af40b36d15416c948aeac23703c4c336 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/Components.meta b/Assets/Generated/Game/Components.meta new file mode 100644 index 0000000..b61d4d4 --- /dev/null +++ b/Assets/Generated/Game/Components.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 77a71e7e3b234c70a82750d468be57b9 +timeCreated: 1556833342 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameCharacterComponent.cs b/Assets/Generated/Game/Components/GameCharacterComponent.cs new file mode 100644 index 0000000..15764ea --- /dev/null +++ b/Assets/Generated/Game/Components/GameCharacterComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + static readonly Character characterComponent = new Character(); + + public bool isCharacter { + get { return HasComponent(GameComponentsLookup.Character); } + set { + if (value != isCharacter) { + var index = GameComponentsLookup.Character; + if (value) { + var componentPool = GetComponentPool(index); + var component = componentPool.Count > 0 + ? componentPool.Pop() + : characterComponent; + + AddComponent(index, component); + } else { + RemoveComponent(index); + } + } + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherCharacter; + + public static Entitas.IMatcher Character { + get { + if (_matcherCharacter == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.Character); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherCharacter = matcher; + } + + return _matcherCharacter; + } + } +} diff --git a/Assets/Generated/Game/Components/GameCharacterComponent.cs.meta b/Assets/Generated/Game/Components/GameCharacterComponent.cs.meta new file mode 100644 index 0000000..418e6de --- /dev/null +++ b/Assets/Generated/Game/Components/GameCharacterComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2f8446bf22884ce0b877837b1494ad71 +timeCreated: 1558107371 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs b/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs new file mode 100644 index 0000000..164b9d1 --- /dev/null +++ b/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs @@ -0,0 +1,58 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public ClientDataBuffer clientDataBuffer { get { return (ClientDataBuffer)GetComponent(GameComponentsLookup.ClientDataBuffer); } } + public bool hasClientDataBuffer { get { return HasComponent(GameComponentsLookup.ClientDataBuffer); } } + + public void AddClientDataBuffer(ushort newCommandCount, NetStack.Serialization.BitBuffer newValue) { + var index = GameComponentsLookup.ClientDataBuffer; + var component = (ClientDataBuffer)CreateComponent(index, typeof(ClientDataBuffer)); + component.CommandCount = newCommandCount; + component.Value = newValue; + AddComponent(index, component); + } + + public void ReplaceClientDataBuffer(ushort newCommandCount, NetStack.Serialization.BitBuffer newValue) { + var index = GameComponentsLookup.ClientDataBuffer; + var component = (ClientDataBuffer)CreateComponent(index, typeof(ClientDataBuffer)); + component.CommandCount = newCommandCount; + component.Value = newValue; + ReplaceComponent(index, component); + } + + public void RemoveClientDataBuffer() { + RemoveComponent(GameComponentsLookup.ClientDataBuffer); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherClientDataBuffer; + + public static Entitas.IMatcher ClientDataBuffer { + get { + if (_matcherClientDataBuffer == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.ClientDataBuffer); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherClientDataBuffer = matcher; + } + + return _matcherClientDataBuffer; + } + } +} diff --git a/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs.meta b/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs.meta new file mode 100644 index 0000000..645d54a --- /dev/null +++ b/Assets/Generated/Game/Components/GameClientDataBufferComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cd02a16ef6dd4950aaba768c0cf12315 +timeCreated: 1557610066 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameConnectionComponent.cs b/Assets/Generated/Game/Components/GameConnectionComponent.cs new file mode 100644 index 0000000..a62659f --- /dev/null +++ b/Assets/Generated/Game/Components/GameConnectionComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public Connection connection { get { return (Connection)GetComponent(GameComponentsLookup.Connection); } } + public bool hasConnection { get { return HasComponent(GameComponentsLookup.Connection); } } + + public void AddConnection(ushort newId) { + var index = GameComponentsLookup.Connection; + var component = (Connection)CreateComponent(index, typeof(Connection)); + component.Id = newId; + AddComponent(index, component); + } + + public void ReplaceConnection(ushort newId) { + var index = GameComponentsLookup.Connection; + var component = (Connection)CreateComponent(index, typeof(Connection)); + component.Id = newId; + ReplaceComponent(index, component); + } + + public void RemoveConnection() { + RemoveComponent(GameComponentsLookup.Connection); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherConnection; + + public static Entitas.IMatcher Connection { + get { + if (_matcherConnection == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.Connection); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherConnection = matcher; + } + + return _matcherConnection; + } + } +} diff --git a/Assets/Generated/Game/Components/GameConnectionComponent.cs.meta b/Assets/Generated/Game/Components/GameConnectionComponent.cs.meta new file mode 100644 index 0000000..b489ca6 --- /dev/null +++ b/Assets/Generated/Game/Components/GameConnectionComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fb02c5710f354db9bab550bbf79ca801 +timeCreated: 1557591816 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs b/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs new file mode 100644 index 0000000..279299a --- /dev/null +++ b/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public ConnectionPeer connectionPeer { get { return (ConnectionPeer)GetComponent(GameComponentsLookup.ConnectionPeer); } } + public bool hasConnectionPeer { get { return HasComponent(GameComponentsLookup.ConnectionPeer); } } + + public void AddConnectionPeer(ENet.Peer newValue) { + var index = GameComponentsLookup.ConnectionPeer; + var component = (ConnectionPeer)CreateComponent(index, typeof(ConnectionPeer)); + component.Value = newValue; + AddComponent(index, component); + } + + public void ReplaceConnectionPeer(ENet.Peer newValue) { + var index = GameComponentsLookup.ConnectionPeer; + var component = (ConnectionPeer)CreateComponent(index, typeof(ConnectionPeer)); + component.Value = newValue; + ReplaceComponent(index, component); + } + + public void RemoveConnectionPeer() { + RemoveComponent(GameComponentsLookup.ConnectionPeer); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherConnectionPeer; + + public static Entitas.IMatcher ConnectionPeer { + get { + if (_matcherConnectionPeer == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.ConnectionPeer); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherConnectionPeer = matcher; + } + + return _matcherConnectionPeer; + } + } +} diff --git a/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs.meta b/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs.meta new file mode 100644 index 0000000..ebb8037 --- /dev/null +++ b/Assets/Generated/Game/Components/GameConnectionPeerComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ea1f873e943540c081df0989cb261f89 +timeCreated: 1557610066 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameControlledByComponent.cs b/Assets/Generated/Game/Components/GameControlledByComponent.cs new file mode 100644 index 0000000..1d6493b --- /dev/null +++ b/Assets/Generated/Game/Components/GameControlledByComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public ControlledBy controlledBy { get { return (ControlledBy)GetComponent(GameComponentsLookup.ControlledBy); } } + public bool hasControlledBy { get { return HasComponent(GameComponentsLookup.ControlledBy); } } + + public void AddControlledBy(ushort newValue) { + var index = GameComponentsLookup.ControlledBy; + var component = (ControlledBy)CreateComponent(index, typeof(ControlledBy)); + component.Value = newValue; + AddComponent(index, component); + } + + public void ReplaceControlledBy(ushort newValue) { + var index = GameComponentsLookup.ControlledBy; + var component = (ControlledBy)CreateComponent(index, typeof(ControlledBy)); + component.Value = newValue; + ReplaceComponent(index, component); + } + + public void RemoveControlledBy() { + RemoveComponent(GameComponentsLookup.ControlledBy); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherControlledBy; + + public static Entitas.IMatcher ControlledBy { + get { + if (_matcherControlledBy == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.ControlledBy); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherControlledBy = matcher; + } + + return _matcherControlledBy; + } + } +} diff --git a/Assets/Generated/Game/Components/GameControlledByComponent.cs.meta b/Assets/Generated/Game/Components/GameControlledByComponent.cs.meta new file mode 100644 index 0000000..9a25e46 --- /dev/null +++ b/Assets/Generated/Game/Components/GameControlledByComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f47dbdf5a52d45a089c81da0582dcac2 +timeCreated: 1558107372 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameDestroyedComponent.cs b/Assets/Generated/Game/Components/GameDestroyedComponent.cs new file mode 100644 index 0000000..3c00ce8 --- /dev/null +++ b/Assets/Generated/Game/Components/GameDestroyedComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + static readonly DestroyedComponent destroyedComponent = new DestroyedComponent(); + + public bool isDestroyed { + get { return HasComponent(GameComponentsLookup.Destroyed); } + set { + if (value != isDestroyed) { + var index = GameComponentsLookup.Destroyed; + if (value) { + var componentPool = GetComponentPool(index); + var component = componentPool.Count > 0 + ? componentPool.Pop() + : destroyedComponent; + + AddComponent(index, component); + } else { + RemoveComponent(index); + } + } + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherDestroyed; + + public static Entitas.IMatcher Destroyed { + get { + if (_matcherDestroyed == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.Destroyed); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherDestroyed = matcher; + } + + return _matcherDestroyed; + } + } +} diff --git a/Assets/Generated/Game/Components/GameDestroyedComponent.cs.meta b/Assets/Generated/Game/Components/GameDestroyedComponent.cs.meta new file mode 100644 index 0000000..4eb9c28 --- /dev/null +++ b/Assets/Generated/Game/Components/GameDestroyedComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a36e5ed35849438680a5db8af520bfab +timeCreated: 1556833466 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs b/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs new file mode 100644 index 0000000..cadbe6b --- /dev/null +++ b/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs @@ -0,0 +1,85 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public DestroyedListenerComponent destroyedListener { get { return (DestroyedListenerComponent)GetComponent(GameComponentsLookup.DestroyedListener); } } + public bool hasDestroyedListener { get { return HasComponent(GameComponentsLookup.DestroyedListener); } } + + public void AddDestroyedListener(System.Collections.Generic.List newValue) { + var index = GameComponentsLookup.DestroyedListener; + var component = (DestroyedListenerComponent)CreateComponent(index, typeof(DestroyedListenerComponent)); + component.value = newValue; + AddComponent(index, component); + } + + public void ReplaceDestroyedListener(System.Collections.Generic.List newValue) { + var index = GameComponentsLookup.DestroyedListener; + var component = (DestroyedListenerComponent)CreateComponent(index, typeof(DestroyedListenerComponent)); + component.value = newValue; + ReplaceComponent(index, component); + } + + public void RemoveDestroyedListener() { + RemoveComponent(GameComponentsLookup.DestroyedListener); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherDestroyedListener; + + public static Entitas.IMatcher DestroyedListener { + get { + if (_matcherDestroyedListener == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.DestroyedListener); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherDestroyedListener = matcher; + } + + return _matcherDestroyedListener; + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EventEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public void AddDestroyedListener(IDestroyedListener value) { + var listeners = hasDestroyedListener + ? destroyedListener.value + : new System.Collections.Generic.List(); + listeners.Add(value); + ReplaceDestroyedListener(listeners); + } + + public void RemoveDestroyedListener(IDestroyedListener value, bool removeComponentWhenEmpty = true) { + var listeners = destroyedListener.value; + listeners.Remove(value); + if (removeComponentWhenEmpty && listeners.Count == 0) { + RemoveDestroyedListener(); + } else { + ReplaceDestroyedListener(listeners); + } + } +} diff --git a/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs.meta b/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs.meta new file mode 100644 index 0000000..fa13027 --- /dev/null +++ b/Assets/Generated/Game/Components/GameDestroyedListenerComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a2c73f377e0a4cd99cebf163ba605544 +timeCreated: 1556833466 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameIdComponent.cs b/Assets/Generated/Game/Components/GameIdComponent.cs new file mode 100644 index 0000000..931e2c2 --- /dev/null +++ b/Assets/Generated/Game/Components/GameIdComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public IdComponent id { get { return (IdComponent)GetComponent(GameComponentsLookup.Id); } } + public bool hasId { get { return HasComponent(GameComponentsLookup.Id); } } + + public void AddId(ushort newValue) { + var index = GameComponentsLookup.Id; + var component = (IdComponent)CreateComponent(index, typeof(IdComponent)); + component.Value = newValue; + AddComponent(index, component); + } + + public void ReplaceId(ushort newValue) { + var index = GameComponentsLookup.Id; + var component = (IdComponent)CreateComponent(index, typeof(IdComponent)); + component.Value = newValue; + ReplaceComponent(index, component); + } + + public void RemoveId() { + RemoveComponent(GameComponentsLookup.Id); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherId; + + public static Entitas.IMatcher Id { + get { + if (_matcherId == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.Id); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherId = matcher; + } + + return _matcherId; + } + } +} diff --git a/Assets/Generated/Game/Components/GameIdComponent.cs.meta b/Assets/Generated/Game/Components/GameIdComponent.cs.meta new file mode 100644 index 0000000..26ed875 --- /dev/null +++ b/Assets/Generated/Game/Components/GameIdComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4a0cc3635a2c44c5a871dceb2e7755b1 +timeCreated: 1556835313 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs b/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs new file mode 100644 index 0000000..aef19a8 --- /dev/null +++ b/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + static readonly RequiresWorldState requiresWorldStateComponent = new RequiresWorldState(); + + public bool isRequiresWorldState { + get { return HasComponent(GameComponentsLookup.RequiresWorldState); } + set { + if (value != isRequiresWorldState) { + var index = GameComponentsLookup.RequiresWorldState; + if (value) { + var componentPool = GetComponentPool(index); + var component = componentPool.Count > 0 + ? componentPool.Pop() + : requiresWorldStateComponent; + + AddComponent(index, component); + } else { + RemoveComponent(index); + } + } + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherRequiresWorldState; + + public static Entitas.IMatcher RequiresWorldState { + get { + if (_matcherRequiresWorldState == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.RequiresWorldState); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherRequiresWorldState = matcher; + } + + return _matcherRequiresWorldState; + } + } +} diff --git a/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs.meta b/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs.meta new file mode 100644 index 0000000..1341e4a --- /dev/null +++ b/Assets/Generated/Game/Components/GameRequiresWorldStateComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d5d3cbed09c428fb75d4f7cbcf37e2c +timeCreated: 1557701508 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameSyncComponent.cs b/Assets/Generated/Game/Components/GameSyncComponent.cs new file mode 100644 index 0000000..6335634 --- /dev/null +++ b/Assets/Generated/Game/Components/GameSyncComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + static readonly Sync syncComponent = new Sync(); + + public bool isSync { + get { return HasComponent(GameComponentsLookup.Sync); } + set { + if (value != isSync) { + var index = GameComponentsLookup.Sync; + if (value) { + var componentPool = GetComponentPool(index); + var component = componentPool.Count > 0 + ? componentPool.Pop() + : syncComponent; + + AddComponent(index, component); + } else { + RemoveComponent(index); + } + } + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherSync; + + public static Entitas.IMatcher Sync { + get { + if (_matcherSync == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.Sync); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherSync = matcher; + } + + return _matcherSync; + } + } +} diff --git a/Assets/Generated/Game/Components/GameSyncComponent.cs.meta b/Assets/Generated/Game/Components/GameSyncComponent.cs.meta new file mode 100644 index 0000000..f4a9eff --- /dev/null +++ b/Assets/Generated/Game/Components/GameSyncComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d1ae1e9177494bf6ba8c684272248dda +timeCreated: 1557591816 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameWasSyncedComponent.cs b/Assets/Generated/Game/Components/GameWasSyncedComponent.cs new file mode 100644 index 0000000..bcd4de2 --- /dev/null +++ b/Assets/Generated/Game/Components/GameWasSyncedComponent.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + static readonly WasSynced wasSyncedComponent = new WasSynced(); + + public bool isWasSynced { + get { return HasComponent(GameComponentsLookup.WasSynced); } + set { + if (value != isWasSynced) { + var index = GameComponentsLookup.WasSynced; + if (value) { + var componentPool = GetComponentPool(index); + var component = componentPool.Count > 0 + ? componentPool.Pop() + : wasSyncedComponent; + + AddComponent(index, component); + } else { + RemoveComponent(index); + } + } + } + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherWasSynced; + + public static Entitas.IMatcher WasSynced { + get { + if (_matcherWasSynced == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.WasSynced); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherWasSynced = matcher; + } + + return _matcherWasSynced; + } + } +} diff --git a/Assets/Generated/Game/Components/GameWasSyncedComponent.cs.meta b/Assets/Generated/Game/Components/GameWasSyncedComponent.cs.meta new file mode 100644 index 0000000..500e4b2 --- /dev/null +++ b/Assets/Generated/Game/Components/GameWasSyncedComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b0e5939ccd384cbe962a75cb018b4e34 +timeCreated: 1557682277 \ No newline at end of file diff --git a/Assets/Generated/Game/Components/GameWorldStateComponent.cs b/Assets/Generated/Game/Components/GameWorldStateComponent.cs new file mode 100644 index 0000000..071d9ff --- /dev/null +++ b/Assets/Generated/Game/Components/GameWorldStateComponent.cs @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameContext { + + public GameEntity worldStateEntity { get { return GetGroup(GameMatcher.WorldState).GetSingleEntity(); } } + public WorldState worldState { get { return worldStateEntity.worldState; } } + public bool hasWorldState { get { return worldStateEntity != null; } } + + public GameEntity SetWorldState(ushort newEntityCount, NetStack.Serialization.BitBuffer newBuffer) { + if (hasWorldState) { + throw new Entitas.EntitasException("Could not set WorldState!\n" + this + " already has an entity with WorldState!", + "You should check if the context already has a worldStateEntity before setting it or use context.ReplaceWorldState()."); + } + var entity = CreateEntity(); + entity.AddWorldState(newEntityCount, newBuffer); + return entity; + } + + public void ReplaceWorldState(ushort newEntityCount, NetStack.Serialization.BitBuffer newBuffer) { + var entity = worldStateEntity; + if (entity == null) { + entity = SetWorldState(newEntityCount, newBuffer); + } else { + entity.ReplaceWorldState(newEntityCount, newBuffer); + } + } + + public void RemoveWorldState() { + worldStateEntity.Destroy(); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public partial class GameEntity { + + public WorldState worldState { get { return (WorldState)GetComponent(GameComponentsLookup.WorldState); } } + public bool hasWorldState { get { return HasComponent(GameComponentsLookup.WorldState); } } + + public void AddWorldState(ushort newEntityCount, NetStack.Serialization.BitBuffer newBuffer) { + var index = GameComponentsLookup.WorldState; + var component = (WorldState)CreateComponent(index, typeof(WorldState)); + component.EntityCount = newEntityCount; + component.Buffer = newBuffer; + AddComponent(index, component); + } + + public void ReplaceWorldState(ushort newEntityCount, NetStack.Serialization.BitBuffer newBuffer) { + var index = GameComponentsLookup.WorldState; + var component = (WorldState)CreateComponent(index, typeof(WorldState)); + component.EntityCount = newEntityCount; + component.Buffer = newBuffer; + ReplaceComponent(index, component); + } + + public void RemoveWorldState() { + RemoveComponent(GameComponentsLookup.WorldState); + } +} + +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + static Entitas.IMatcher _matcherWorldState; + + public static Entitas.IMatcher WorldState { + get { + if (_matcherWorldState == null) { + var matcher = (Entitas.Matcher)Entitas.Matcher.AllOf(GameComponentsLookup.WorldState); + matcher.componentNames = GameComponentsLookup.componentNames; + _matcherWorldState = matcher; + } + + return _matcherWorldState; + } + } +} diff --git a/Assets/Generated/Game/Components/GameWorldStateComponent.cs.meta b/Assets/Generated/Game/Components/GameWorldStateComponent.cs.meta new file mode 100644 index 0000000..111f9cf --- /dev/null +++ b/Assets/Generated/Game/Components/GameWorldStateComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8f95dbd140449cfa717ace034f7d81d +timeCreated: 1557703029 \ No newline at end of file diff --git a/Assets/Generated/Game/GameAttribute.cs b/Assets/Generated/Game/GameAttribute.cs new file mode 100644 index 0000000..f613db0 --- /dev/null +++ b/Assets/Generated/Game/GameAttribute.cs @@ -0,0 +1,13 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ContextAttributeGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed class GameAttribute : Entitas.CodeGeneration.Attributes.ContextAttribute { + + public GameAttribute() : base("Game") { + } +} diff --git a/Assets/Generated/Game/GameAttribute.cs.meta b/Assets/Generated/Game/GameAttribute.cs.meta new file mode 100644 index 0000000..f5b21de --- /dev/null +++ b/Assets/Generated/Game/GameAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f57e353c99697184a837721f0ee12e13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/GameComponentsLookup.cs b/Assets/Generated/Game/GameComponentsLookup.cs new file mode 100644 index 0000000..93723b0 --- /dev/null +++ b/Assets/Generated/Game/GameComponentsLookup.cs @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ComponentLookupGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public static class GameComponentsLookup { + + public const int Character = 0; + public const int ClientDataBuffer = 1; + public const int Connection = 2; + public const int ConnectionPeer = 3; + public const int ControlledBy = 4; + public const int Destroyed = 5; + public const int DestroyedListener = 6; + public const int Id = 7; + public const int RequiresWorldState = 8; + public const int Sync = 9; + public const int WasSynced = 10; + public const int WorldState = 11; + + public const int TotalComponents = 12; + + public static readonly string[] componentNames = { + "Character", + "ClientDataBuffer", + "Connection", + "ConnectionPeer", + "ControlledBy", + "Destroyed", + "DestroyedListener", + "Id", + "RequiresWorldState", + "Sync", + "WasSynced", + "WorldState" + }; + + public static readonly System.Type[] componentTypes = { + typeof(Character), + typeof(ClientDataBuffer), + typeof(Connection), + typeof(ConnectionPeer), + typeof(ControlledBy), + typeof(DestroyedComponent), + typeof(DestroyedListenerComponent), + typeof(IdComponent), + typeof(RequiresWorldState), + typeof(Sync), + typeof(WasSynced), + typeof(WorldState) + }; +} diff --git a/Assets/Generated/Game/GameComponentsLookup.cs.meta b/Assets/Generated/Game/GameComponentsLookup.cs.meta new file mode 100644 index 0000000..44eb33c --- /dev/null +++ b/Assets/Generated/Game/GameComponentsLookup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7ad7b8ead6868b4eac97f4329709b56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/GameContext.cs b/Assets/Generated/Game/GameContext.cs new file mode 100644 index 0000000..ceeb5e5 --- /dev/null +++ b/Assets/Generated/Game/GameContext.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ContextGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameContext : Entitas.Context { + + public GameContext() + : base( + GameComponentsLookup.TotalComponents, + 0, + new Entitas.ContextInfo( + "Game", + GameComponentsLookup.componentNames, + GameComponentsLookup.componentTypes + ), + (entity) => + +#if (ENTITAS_FAST_AND_UNSAFE) + new Entitas.UnsafeAERC(), +#else + new Entitas.SafeAERC(entity), +#endif + () => new GameEntity() + ) { + } +} diff --git a/Assets/Generated/Game/GameContext.cs.meta b/Assets/Generated/Game/GameContext.cs.meta new file mode 100644 index 0000000..348da14 --- /dev/null +++ b/Assets/Generated/Game/GameContext.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ad01bce7e1a52544d8070a22e7c90a47 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/GameEntity.cs b/Assets/Generated/Game/GameEntity.cs new file mode 100644 index 0000000..afda5b0 --- /dev/null +++ b/Assets/Generated/Game/GameEntity.cs @@ -0,0 +1,10 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.EntityGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameEntity : Entitas.Entity { +} diff --git a/Assets/Generated/Game/GameEntity.cs.meta b/Assets/Generated/Game/GameEntity.cs.meta new file mode 100644 index 0000000..551f834 --- /dev/null +++ b/Assets/Generated/Game/GameEntity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8f4ca1ebdac8a944c81a7523c37b8024 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/GameMatcher.cs b/Assets/Generated/Game/GameMatcher.cs new file mode 100644 index 0000000..4259b56 --- /dev/null +++ b/Assets/Generated/Game/GameMatcher.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGeneration.Plugins.ContextMatcherGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +public sealed partial class GameMatcher { + + public static Entitas.IAllOfMatcher AllOf(params int[] indices) { + return Entitas.Matcher.AllOf(indices); + } + + public static Entitas.IAllOfMatcher AllOf(params Entitas.IMatcher[] matchers) { + return Entitas.Matcher.AllOf(matchers); + } + + public static Entitas.IAnyOfMatcher AnyOf(params int[] indices) { + return Entitas.Matcher.AnyOf(indices); + } + + public static Entitas.IAnyOfMatcher AnyOf(params Entitas.IMatcher[] matchers) { + return Entitas.Matcher.AnyOf(matchers); + } +} diff --git a/Assets/Generated/Game/GameMatcher.cs.meta b/Assets/Generated/Game/GameMatcher.cs.meta new file mode 100644 index 0000000..090ce03 --- /dev/null +++ b/Assets/Generated/Game/GameMatcher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e52cc74a6212834abd744f867ea60fc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Generated/Game/Systems.meta b/Assets/Generated/Game/Systems.meta new file mode 100644 index 0000000..c2af202 --- /dev/null +++ b/Assets/Generated/Game/Systems.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 401be2b04b6844388efa5f35d4e7963f +timeCreated: 1556834250 \ No newline at end of file diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..3cab3f6 --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 010971b045d5ac74b92fd4b9e5fe29f4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs.meta b/Assets/Plugins/DesperateDevs.meta new file mode 100644 index 0000000..6dfe312 --- /dev/null +++ b/Assets/Plugins/DesperateDevs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 317deb88db51d41779e0dbf6a1f16d02 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Compile.cs b/Assets/Plugins/DesperateDevs/Compile.cs new file mode 100644 index 0000000..eeb2cff --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Compile.cs @@ -0,0 +1,5 @@ +namespace DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor { + + class Compile { + } +} diff --git a/Assets/Plugins/DesperateDevs/Compile.cs.meta b/Assets/Plugins/DesperateDevs/Compile.cs.meta new file mode 100644 index 0000000..b8107db --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Compile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 649f7d3f032f9e1418532660d09c3cb7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll b/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll new file mode 100644 index 0000000..f12d12c Binary files /dev/null and b/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll differ diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll.meta b/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll.meta new file mode 100644 index 0000000..ea108fa --- /dev/null +++ b/Assets/Plugins/DesperateDevs/DesperateDevs.Logging.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 8dd99fb7af3105c419ba76e88d6be135 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll b/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll new file mode 100644 index 0000000..9a6b4e4 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll differ diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll.meta b/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll.meta new file mode 100644 index 0000000..c0cb82e --- /dev/null +++ b/Assets/Plugins/DesperateDevs/DesperateDevs.Networking.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 9e1ef8545e4ada44f91db7998a60ec6a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll b/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll new file mode 100644 index 0000000..eae53c7 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll differ diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll.meta b/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll.meta new file mode 100644 index 0000000..bbec341 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/DesperateDevs.Serialization.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: e196ddd12388e754db5090712f5c690e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll b/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll new file mode 100644 index 0000000..66f4394 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll differ diff --git a/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll.meta b/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll.meta new file mode 100644 index 0000000..f7e808f --- /dev/null +++ b/Assets/Plugins/DesperateDevs/DesperateDevs.Utils.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 824df2be42f737449992f3132ec8e2d6 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor.meta b/Assets/Plugins/DesperateDevs/Editor.meta new file mode 100644 index 0000000..135f278 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 079f846ebfbf36f41b987ef1deae729e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll new file mode 100644 index 0000000..8bb0a13 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll.meta b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll.meta new file mode 100644 index 0000000..5e0adec --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Analytics.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 75896b85ae761ef4a9cce4070eed2a48 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll new file mode 100644 index 0000000..c5bfb6e Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll.meta b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll.meta new file mode 100644 index 0000000..8e8764e --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 468a8e14c587a244eb50c899de980bf5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll new file mode 100644 index 0000000..783f19d Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll.meta b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll.meta new file mode 100644 index 0000000..eb86cb6 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.CodeGenerator.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 5536f1ad1460f194e8df9c6b674f87a5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll new file mode 100644 index 0000000..fdaf486 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll.meta b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll.meta new file mode 100644 index 0000000..1b2230a --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.CodeGeneration.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: c8bedbf7a91288941a67e44404307803 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll new file mode 100644 index 0000000..3f88406 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll.meta b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll.meta new file mode 100644 index 0000000..7a40eac --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/DesperateDevs.Unity.Editor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: aa545073af5a0df4586eb87f7e543995 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/Images.meta b/Assets/Plugins/DesperateDevs/Editor/Images.meta new file mode 100644 index 0000000..c7b17e6 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/Images.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: baf3bd330228f00459ba4dad29373afe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png b/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png new file mode 100644 index 0000000..93c1273 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png differ diff --git a/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png.meta b/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png.meta new file mode 100644 index 0000000..ca825c7 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/Images/Jenny-Header.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 62c57d751cb8541c2afeeee44410ea23 +labels: +- Jenny-Header +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: dec394311a18449ed96f63646ffa6c80 + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/Plugins.meta b/Assets/Plugins/DesperateDevs/Editor/Plugins.meta new file mode 100644 index 0000000..b2e8180 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a2620ebc6e56824f94db090b3a50975 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll new file mode 100644 index 0000000..0343544 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll.meta b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll.meta new file mode 100644 index 0000000..70f5378 --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Plugins.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 2241fb30c2bffbe4cbb7e737fdb1ddce +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll new file mode 100644 index 0000000..e9395b4 Binary files /dev/null and b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll differ diff --git a/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll.meta b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll.meta new file mode 100644 index 0000000..7f7932d --- /dev/null +++ b/Assets/Plugins/DesperateDevs/Editor/Plugins/DesperateDevs.CodeGeneration.Unity.Plugins.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 7c26808e77177ca459769368b9fc35fe +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Disruptor.meta b/Assets/Plugins/Disruptor.meta new file mode 100644 index 0000000..18a0220 --- /dev/null +++ b/Assets/Plugins/Disruptor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e16cb14662ba7634b81f91017db8c4ec +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Disruptor/RingBuffer.cs b/Assets/Plugins/Disruptor/RingBuffer.cs new file mode 100644 index 0000000..2fa6862 --- /dev/null +++ b/Assets/Plugins/Disruptor/RingBuffer.cs @@ -0,0 +1,275 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading; + +namespace DisruptorUnity3d +{ + /// + /// Implementation of the Disruptor pattern + /// + /// the type of item to be stored + public class RingBuffer + { + private readonly T[] _entries; + private readonly int _modMask; + private Volatile.PaddedLong _consumerCursor = new Volatile.PaddedLong(); + private Volatile.PaddedLong _producerCursor = new Volatile.PaddedLong(); + + /// + /// Creates a new RingBuffer with the given capacity + /// + /// The capacity of the buffer + /// Only a single thread may attempt to consume at any one time + public RingBuffer(int capacity) + { + capacity = NextPowerOfTwo(capacity); + _modMask = capacity - 1; + _entries = new T[capacity]; + } + + /// + /// The maximum number of items that can be stored + /// + public int Capacity + { + get { return _entries.Length; } + } + + public T this[long index] + { + get { unchecked { return _entries[index & _modMask]; } } + set { unchecked { _entries[index & _modMask] = value; } } + } + + /// + /// Removes an item from the buffer. + /// + /// The next available item + public T Dequeue() + { + var next = _consumerCursor.ReadAcquireFence() + 1; + while (_producerCursor.ReadAcquireFence() < next) // makes sure we read the data from _entries after we have read the producer cursor + { + Thread.SpinWait(1); + } + var result = this[next]; + _consumerCursor.WriteReleaseFence(next); // makes sure we read the data from _entries before we update the consumer cursor + return result; + } + + /// + /// Attempts to remove an items from the queue + /// + /// the items + /// True if successful + public bool TryDequeue(out T obj) + { + var next = _consumerCursor.ReadAcquireFence() + 1; + + if (_producerCursor.ReadAcquireFence() < next) + { + obj = default(T); + return false; + } + obj = Dequeue(); + return true; + } + + /// + /// Add an item to the buffer + /// + /// + public void Enqueue(T item) + { + var next = _producerCursor.ReadAcquireFence() + 1; + + long wrapPoint = next - _entries.Length; + long min = _consumerCursor.ReadAcquireFence(); + + while (wrapPoint > min) + { + min = _consumerCursor.ReadAcquireFence(); + Thread.SpinWait(1); + } + + this[next] = item; + _producerCursor.WriteReleaseFence(next); // makes sure we write the data in _entries before we update the producer cursor + } + + /// + /// The number of items in the buffer + /// + /// for indicative purposes only, may contain stale data + public int Count { get { return (int)(_producerCursor.ReadFullFence() - _consumerCursor.ReadFullFence()); } } + + private static int NextPowerOfTwo(int x) + { + var result = 2; + while (result < x) + { + result <<= 1; + } + return result; + } + + + } + public static class Volatile + { + private const int CacheLineSize = 64; + + [StructLayout(LayoutKind.Explicit, Size = CacheLineSize * 2)] + public struct PaddedLong + { + [FieldOffset(CacheLineSize)] + private long _value; + + /// + /// Create a new with the given initial value. + /// + /// Initial value + public PaddedLong(long value) + { + _value = value; + } + + /// + /// Read the value without applying any fence + /// + /// The current value + public long ReadUnfenced() + { + return _value; + } + + /// + /// Read the value applying acquire fence semantic + /// + /// The current value + public long ReadAcquireFence() + { + var value = _value; + Thread.MemoryBarrier(); + return value; + } + + /// + /// Read the value applying full fence semantic + /// + /// The current value + public long ReadFullFence() + { + Thread.MemoryBarrier(); + return _value; + } + + /// + /// Read the value applying a compiler only fence, no CPU fence is applied + /// + /// The current value + [MethodImpl(MethodImplOptions.NoOptimization)] + public long ReadCompilerOnlyFence() + { + return _value; + } + + /// + /// Write the value applying release fence semantic + /// + /// The new value + public void WriteReleaseFence(long newValue) + { + Thread.MemoryBarrier(); + _value = newValue; + } + + /// + /// Write the value applying full fence semantic + /// + /// The new value + public void WriteFullFence(long newValue) + { + Thread.MemoryBarrier(); + _value = newValue; + } + + /// + /// Write the value applying a compiler fence only, no CPU fence is applied + /// + /// The new value + [MethodImpl(MethodImplOptions.NoOptimization)] + public void WriteCompilerOnlyFence(long newValue) + { + _value = newValue; + } + + /// + /// Write without applying any fence + /// + /// The new value + public void WriteUnfenced(long newValue) + { + _value = newValue; + } + + /// + /// Atomically set the value to the given updated value if the current value equals the comparand + /// + /// The new value + /// The comparand (expected value) + /// + public bool AtomicCompareExchange(long newValue, long comparand) + { + return Interlocked.CompareExchange(ref _value, newValue, comparand) == comparand; + } + + /// + /// Atomically set the value to the given updated value + /// + /// The new value + /// The original value + public long AtomicExchange(long newValue) + { + return Interlocked.Exchange(ref _value, newValue); + } + + /// + /// Atomically add the given value to the current value and return the sum + /// + /// The value to be added + /// The sum of the current value and the given value + public long AtomicAddAndGet(long delta) + { + return Interlocked.Add(ref _value, delta); + } + + /// + /// Atomically increment the current value and return the new value + /// + /// The incremented value. + public long AtomicIncrementAndGet() + { + return Interlocked.Increment(ref _value); + } + + /// + /// Atomically increment the current value and return the new value + /// + /// The decremented value. + public long AtomicDecrementAndGet() + { + return Interlocked.Decrement(ref _value); + } + + /// + /// Returns the string representation of the current value. + /// + /// the string representation of the current value. + public override string ToString() + { + var value = ReadFullFence(); + return value.ToString(); + } + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/Disruptor/RingBuffer.cs.meta b/Assets/Plugins/Disruptor/RingBuffer.cs.meta new file mode 100644 index 0000000..43559d0 --- /dev/null +++ b/Assets/Plugins/Disruptor/RingBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4fc0077e999e66844bd8ffeb5ea08a46 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/ENet.meta b/Assets/Plugins/ENet.meta new file mode 100644 index 0000000..d1ca8f6 --- /dev/null +++ b/Assets/Plugins/ENet.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96611547a82c86b4fbaab2e991fedcb6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/ENet/ENet.cs b/Assets/Plugins/ENet/ENet.cs new file mode 100644 index 0000000..f425663 --- /dev/null +++ b/Assets/Plugins/ENet/ENet.cs @@ -0,0 +1,1063 @@ +/* + * Managed C# wrapper for an extended version of ENet + * Copyright (c) 2013 James Bellinger + * Copyright (c) 2016 Nate Shoffner + * Copyright (c) 2018 Stanislav Denisov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; + +namespace ENet { + [Flags] + public enum PacketFlags { + None = 0, + Reliable = 1 << 0, + Unsequenced = 1 << 1, + NoAllocate = 1 << 2, + UnreliableFragment = 1 << 3 + } + + public enum EventType { + None = 0, + Connect = 1, + Disconnect = 2, + Receive = 3, + Timeout = 4 + } + + public enum PeerState { + Uninitialized = -1, + Disconnected = 0, + Connecting = 1, + AcknowledgingConnect = 2, + ConnectionPending = 3, + ConnectionSucceeded = 4, + Connected = 5, + DisconnectLater = 6, + Disconnecting = 7, + AcknowledgingDisconnect = 8, + Zombie = 9 + } + + [StructLayout(LayoutKind.Sequential)] + public struct ENetAddress { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[] host; + public ushort port; + public ushort scope; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ENetEvent { + public EventType type; + public IntPtr peer; + public byte channelID; + public uint data; + public IntPtr packet; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ENetCallbacks { + public AllocCallback malloc; + public FreeCallback free; + public NoMemoryCallback noMemory; + } + + public delegate IntPtr AllocCallback(IntPtr size); + public delegate void FreeCallback(IntPtr memory); + public delegate void NoMemoryCallback(); + public delegate void PacketFreeCallback(Packet packet); + + internal static class ArrayPool { + [ThreadStatic] + private static byte[] byteBuffer; + [ThreadStatic] + private static IntPtr[] pointerBuffer; + + public static byte[] GetByteBuffer() { + if (byteBuffer == null) + byteBuffer = new byte[64]; + + return byteBuffer; + } + + public static IntPtr[] GetPointerBuffer() { + if (pointerBuffer == null) + pointerBuffer = new IntPtr[Library.maxPeers]; + + return pointerBuffer; + } + } + + public struct Address { + private ENetAddress nativeAddress; + + internal ENetAddress NativeData { + get { + return nativeAddress; + } + + set { + nativeAddress = value; + } + } + + public Address(ENetAddress address) { + nativeAddress = address; + } + + public ushort Port { + get { + return nativeAddress.port; + } + + set { + nativeAddress.port = value; + } + } + + public string GetIP() { + StringBuilder ip = new StringBuilder(1024); + + if (Native.enet_address_get_host_ip(nativeAddress, ip, (IntPtr)ip.Capacity) != 0) + return String.Empty; + + return ip.ToString(); + } + + public bool SetIP(string ip) { + if (ip == null) + throw new ArgumentNullException("ip"); + + return Native.enet_address_set_host_ip(ref nativeAddress, ip) == 0; + } + + public string GetHost() { + StringBuilder hostName = new StringBuilder(1024); + + if (Native.enet_address_get_host(nativeAddress, hostName, (IntPtr)hostName.Capacity) != 0) + return String.Empty; + + return hostName.ToString(); + } + + public bool SetHost(string hostName) { + if (hostName == null) + throw new ArgumentNullException("hostName"); + + return Native.enet_address_set_host(ref nativeAddress, hostName) == 0; + } + } + + public struct Event { + private ENetEvent nativeEvent; + + internal ENetEvent NativeData { + get { + return nativeEvent; + } + + set { + nativeEvent = value; + } + } + + public Event(ENetEvent @event) { + nativeEvent = @event; + } + + public EventType Type { + get { + return nativeEvent.type; + } + } + + public Peer Peer { + get { + return new Peer(nativeEvent.peer); + } + } + + public byte ChannelID { + get { + return nativeEvent.channelID; + } + } + + public uint Data { + get { + return nativeEvent.data; + } + } + + public Packet Packet { + get { + return new Packet(nativeEvent.packet); + } + } + } + + public class Callbacks { + private ENetCallbacks nativeCallbacks; + + internal ENetCallbacks NativeData { + get { + return nativeCallbacks; + } + + set { + nativeCallbacks = value; + } + } + + public Callbacks(AllocCallback allocCallback, FreeCallback freeCallback, NoMemoryCallback noMemoryCallback) { + nativeCallbacks.malloc = allocCallback; + nativeCallbacks.free = freeCallback; + nativeCallbacks.noMemory = noMemoryCallback; + } + } + + public struct Packet : IDisposable { + private IntPtr nativePacket; + + internal IntPtr NativeData { + get { + return nativePacket; + } + + set { + nativePacket = value; + } + } + + public Packet(IntPtr packet) { + nativePacket = packet; + } + + public void Dispose() { + if (nativePacket != IntPtr.Zero) { + Native.enet_packet_dispose(nativePacket); + nativePacket = IntPtr.Zero; + } + } + + public bool IsSet { + get { + return nativePacket != IntPtr.Zero; + } + } + + public IntPtr Data { + get { + CheckCreated(); + + return Native.enet_packet_get_data(nativePacket); + } + } + + public int Length { + get { + CheckCreated(); + + return Native.enet_packet_get_length(nativePacket); + } + } + + public bool HasReferences { + get { + CheckCreated(); + + return Native.enet_packet_check_references(nativePacket) != 0; + } + } + + internal void CheckCreated() { + if (nativePacket == IntPtr.Zero) + throw new InvalidOperationException("Packet not created"); + } + + public void SetFreeCallback(IntPtr callback) { + CheckCreated(); + + Native.enet_packet_set_free_callback(nativePacket, callback); + } + + public void SetFreeCallback(PacketFreeCallback callback) { + CheckCreated(); + + Native.enet_packet_set_free_callback(nativePacket, Marshal.GetFunctionPointerForDelegate(callback)); + } + + public void Create(byte[] data) { + if (data == null) + throw new ArgumentNullException("data"); + + Create(data, data.Length); + } + + public void Create(byte[] data, int length) { + Create(data, length, PacketFlags.None); + } + + public void Create(byte[] data, PacketFlags flags) { + Create(data, data.Length, flags); + } + + public void Create(byte[] data, int length, PacketFlags flags) { + if (data == null) + throw new ArgumentNullException("data"); + + if (length < 0 || length > data.Length) + throw new ArgumentOutOfRangeException(); + + nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags); + } + + public void Create(IntPtr data, int length, PacketFlags flags) { + if (data == IntPtr.Zero) + throw new ArgumentNullException("data"); + + if (length < 0) + throw new ArgumentOutOfRangeException(); + + nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags); + } + + public void Create(byte[] data, int offset, int length, PacketFlags flags) { + if (data == null) + throw new ArgumentNullException("data"); + + if (offset < 0 || length < 0 || length > data.Length) + throw new ArgumentOutOfRangeException(); + + nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags); + } + + public void Create(IntPtr data, int offset, int length, PacketFlags flags) { + if (data == IntPtr.Zero) + throw new ArgumentNullException("data"); + + if (offset < 0 || length < 0) + throw new ArgumentOutOfRangeException(); + + nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags); + } + + public void CopyTo(byte[] destination) { + if (destination == null) + throw new ArgumentNullException("destination"); + + Marshal.Copy(Data, destination, 0, Length); + } + } + + public class Host : IDisposable { + private IntPtr nativeHost; + + internal IntPtr NativeData { + get { + return nativeHost; + } + + set { + nativeHost = value; + } + } + + public void Dispose() { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) { + if (nativeHost != IntPtr.Zero) { + Native.enet_host_destroy(nativeHost); + nativeHost = IntPtr.Zero; + } + } + + ~Host() { + Dispose(false); + } + + public bool IsSet { + get { + return nativeHost != IntPtr.Zero; + } + } + + public uint PeersCount { + get { + CheckCreated(); + + return Native.enet_host_get_peers_count(nativeHost); + } + } + + public uint PacketsSent { + get { + CheckCreated(); + + return Native.enet_host_get_packets_sent(nativeHost); + } + } + + public uint PacketsReceived { + get { + CheckCreated(); + + return Native.enet_host_get_packets_received(nativeHost); + } + } + + public uint BytesSent { + get { + CheckCreated(); + + return Native.enet_host_get_bytes_sent(nativeHost); + } + } + + public uint BytesReceived { + get { + CheckCreated(); + + return Native.enet_host_get_bytes_received(nativeHost); + } + } + + internal void CheckCreated() { + if (nativeHost == IntPtr.Zero) + throw new InvalidOperationException("Host not created"); + } + + private void CheckChannelLimit(int channelLimit) { + if (channelLimit < 0 || channelLimit > Library.maxChannelCount) + throw new ArgumentOutOfRangeException("channelLimit"); + } + + public void Create() { + Create(null, 1, 0); + } + + public void Create(Address? address, int peerLimit) { + Create(address, peerLimit, 0); + } + + public void Create(Address? address, int peerLimit, int channelLimit) { + Create(address, peerLimit, channelLimit, 0, 0); + } + + public void Create(int peerLimit, int channelLimit) { + Create(null, peerLimit, channelLimit, 0, 0); + } + + public void Create(int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { + Create(null, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth); + } + + public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { + if (nativeHost != IntPtr.Zero) + throw new InvalidOperationException("Host already created"); + + if (peerLimit < 0 || peerLimit > Library.maxPeers) + throw new ArgumentOutOfRangeException("peerLimit"); + + CheckChannelLimit(channelLimit); + + if (address != null) { + var nativeAddress = address.Value.NativeData; + + nativeHost = Native.enet_host_create(ref nativeAddress, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth); + } else { + nativeHost = Native.enet_host_create(IntPtr.Zero, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth); + } + + if (nativeHost == IntPtr.Zero) + throw new InvalidOperationException("Host creation call failed"); + } + + public void EnableCompression() { + CheckCreated(); + + Native.enet_host_enable_compression(nativeHost); + } + + public void PreventConnections(bool state) { + CheckCreated(); + + Native.enet_host_prevent_connections(nativeHost, (byte)(state ? 1 : 0)); + } + + public void Broadcast(byte channelID, ref Packet packet) { + CheckCreated(); + + packet.CheckCreated(); + Native.enet_host_broadcast(nativeHost, channelID, packet.NativeData); + packet.NativeData = IntPtr.Zero; + } + + public void Broadcast(byte channelID, ref Packet packet, Peer excludedPeer) { + CheckCreated(); + + packet.CheckCreated(); + Native.enet_host_broadcast_excluding(nativeHost, channelID, packet.NativeData, excludedPeer.NativeData); + packet.NativeData = IntPtr.Zero; + } + + public void Broadcast(byte channelID, ref Packet packet, Peer[] peers) { + CheckCreated(); + + packet.CheckCreated(); + + if (peers.Length > 0) { + IntPtr[] nativePeers = ArrayPool.GetPointerBuffer(); + int nativeCount = 0; + + for (int i = 0; i < peers.Length; i++) { + if (peers[i].NativeData != IntPtr.Zero) { + nativePeers[nativeCount] = peers[i].NativeData; + nativeCount++; + } + } + + Native.enet_host_broadcast_selective(nativeHost, channelID, packet.NativeData, nativePeers, (IntPtr)nativeCount); + } + + packet.NativeData = IntPtr.Zero; + } + + public int CheckEvents(out Event @event) { + CheckCreated(); + + ENetEvent nativeEvent; + + var result = Native.enet_host_check_events(nativeHost, out nativeEvent); + + if (result <= 0) { + @event = new Event(); + + return result; + } + + @event = new Event(nativeEvent); + + return result; + } + + public Peer Connect(Address address) { + return Connect(address, 0, 0); + } + + public Peer Connect(Address address, int channelLimit) { + return Connect(address, channelLimit, 0); + } + + public Peer Connect(Address address, int channelLimit, uint data) { + CheckCreated(); + CheckChannelLimit(channelLimit); + + var nativeAddress = address.NativeData; + var peer = new Peer(Native.enet_host_connect(nativeHost, ref nativeAddress, (IntPtr)channelLimit, data)); + + if (peer.NativeData == IntPtr.Zero) + throw new InvalidOperationException("Host connect call failed"); + + return peer; + } + + public int Service(int timeout, out Event @event) { + if (timeout < 0) + throw new ArgumentOutOfRangeException("timeout"); + + CheckCreated(); + + ENetEvent nativeEvent; + + var result = Native.enet_host_service(nativeHost, out nativeEvent, (uint)timeout); + + if (result <= 0) { + @event = new Event(); + + return result; + } + + @event = new Event(nativeEvent); + + return result; + } + + public void SetBandwidthLimit(uint incomingBandwidth, uint outgoingBandwidth) { + CheckCreated(); + + Native.enet_host_bandwidth_limit(nativeHost, incomingBandwidth, outgoingBandwidth); + } + + public void SetChannelLimit(int channelLimit) { + CheckCreated(); + CheckChannelLimit(channelLimit); + + Native.enet_host_channel_limit(nativeHost, (IntPtr)channelLimit); + } + + public void Flush() { + CheckCreated(); + + Native.enet_host_flush(nativeHost); + } + } + + public struct Peer { + private IntPtr nativePeer; + private uint nativeID; + + internal IntPtr NativeData { + get { + return nativePeer; + } + + set { + nativePeer = value; + } + } + + public Peer(IntPtr peer) { + nativePeer = peer; + nativeID = nativePeer != IntPtr.Zero ? Native.enet_peer_get_id(nativePeer) : 0; + } + + public bool IsSet { + get { + return nativePeer != IntPtr.Zero; + } + } + + public uint ID { + get { + return nativeID; + } + } + + public string IP { + get { + CheckCreated(); + + byte[] ip = ArrayPool.GetByteBuffer(); + + if (Native.enet_peer_get_ip(nativePeer, ip, (IntPtr)ip.Length) == 0) { + if (Encoding.ASCII.GetString(ip).Remove(7) != "::ffff:") + return Encoding.ASCII.GetString(ip, 0, ip.StringLength()); + else + return Encoding.ASCII.GetString(ip, 0, ip.StringLength()).Substring(7); + } else { + return String.Empty; + } + } + } + + public ushort Port { + get { + CheckCreated(); + + return Native.enet_peer_get_port(nativePeer); + } + } + + public uint MTU { + get { + CheckCreated(); + + return Native.enet_peer_get_mtu(nativePeer); + } + } + + public PeerState State { + get { + return nativePeer == IntPtr.Zero ? PeerState.Uninitialized : Native.enet_peer_get_state(nativePeer); + } + } + + public uint RoundTripTime { + get { + CheckCreated(); + + return Native.enet_peer_get_rtt(nativePeer); + } + } + + public uint LastSendTime { + get { + CheckCreated(); + + return Native.enet_peer_get_lastsendtime(nativePeer); + } + } + + public uint LastReceiveTime { + get { + CheckCreated(); + + return Native.enet_peer_get_lastreceivetime(nativePeer); + } + } + + public ulong PacketsSent { + get { + CheckCreated(); + + return Native.enet_peer_get_packets_sent(nativePeer); + } + } + + public ulong PacketsLost { + get { + CheckCreated(); + + return Native.enet_peer_get_packets_lost(nativePeer); + } + } + + public ulong BytesSent { + get { + CheckCreated(); + + return Native.enet_peer_get_bytes_sent(nativePeer); + } + } + + public ulong BytesReceived { + get { + CheckCreated(); + + return Native.enet_peer_get_bytes_received(nativePeer); + } + } + + public IntPtr Data { + get { + CheckCreated(); + + return Native.enet_peer_get_data(nativePeer); + } + + set { + CheckCreated(); + + Native.enet_peer_set_data(nativePeer, value); + } + } + + internal void CheckCreated() { + if (nativePeer == IntPtr.Zero) + throw new InvalidOperationException("Peer not created"); + } + + public void ConfigureThrottle(uint interval, uint acceleration, uint deceleration) { + CheckCreated(); + + Native.enet_peer_throttle_configure(nativePeer, interval, acceleration, deceleration); + } + + public bool Send(byte channelID, ref Packet packet) { + CheckCreated(); + + packet.CheckCreated(); + + return Native.enet_peer_send(nativePeer, channelID, packet.NativeData) == 0; + } + + public void Ping() { + CheckCreated(); + + Native.enet_peer_ping(nativePeer); + } + + public void PingInterval(uint interval) { + CheckCreated(); + + Native.enet_peer_ping_interval(nativePeer, interval); + } + + public void Timeout(uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum) { + CheckCreated(); + + Native.enet_peer_timeout(nativePeer, timeoutLimit, timeoutMinimum, timeoutMaximum); + } + + public void Disconnect(uint data) { + CheckCreated(); + + Native.enet_peer_disconnect(nativePeer, data); + } + + public void DisconnectNow(uint data) { + CheckCreated(); + + Native.enet_peer_disconnect_now(nativePeer, data); + } + + public void DisconnectLater(uint data) { + CheckCreated(); + + Native.enet_peer_disconnect_later(nativePeer, data); + } + + public void Reset() { + CheckCreated(); + + Native.enet_peer_reset(nativePeer); + } + } + + public static class Extensions { + public static int StringLength(this byte[] data) { + if (data == null) + throw new ArgumentNullException("data"); + + int i; + + for (i = 0; i < data.Length && data[i] != 0; i++); + + return i; + } + } + + public static class Library { + public const uint maxChannelCount = 0xFF; + public const uint maxPeers = 0xFFF; + public const uint maxPacketSize = 32 * 1024 * 1024; + public const uint throttleScale = 32; + public const uint throttleAcceleration = 2; + public const uint throttleDeceleration = 2; + public const uint throttleInterval = 5000; + public const uint timeoutLimit = 32; + public const uint timeoutMinimum = 5000; + public const uint timeoutMaximum = 30000; + public const uint version = (2 << 16) | (2 << 8) | (5); + + public static bool Initialize() { + return Native.enet_initialize() == 0; + } + + public static bool Initialize(Callbacks inits) { + return Native.enet_initialize_with_callbacks(version, inits.NativeData) == 0; + } + + public static void Deinitialize() { + Native.enet_deinitialize(); + } + + public static uint Time { + get { + return Native.enet_time_get(); + } + } + } + + [SuppressUnmanagedCodeSecurity] + internal static class Native { + #if __IOS__ || UNITY_IOS && !UNITY_EDITOR + private const string nativeLibrary = "__Internal"; + #else + private const string nativeLibrary = "enet"; + #endif + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_initialize(); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_initialize_with_callbacks(uint version, ENetCallbacks inits); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_deinitialize(); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_time_get(); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_address_set_host_ip(ref ENetAddress address, string ip); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_address_set_host(ref ENetAddress address, string hostName); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_address_get_host_ip(ENetAddress address, StringBuilder ip, IntPtr ipLength); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_address_get_host(ENetAddress address, StringBuilder hostName, IntPtr nameLength); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_packet_create(byte[] data, IntPtr dataLength, PacketFlags flags); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_packet_create(IntPtr data, IntPtr dataLength, PacketFlags flags); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_packet_create_offset(byte[] data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_packet_create_offset(IntPtr data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_packet_check_references(IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_packet_get_data(IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_packet_get_length(IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_packet_set_free_callback(IntPtr packet, IntPtr callback); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_packet_dispose(IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_host_create(IntPtr address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, IntPtr channelCount, uint data); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_broadcast_excluding(IntPtr host, byte channelID, IntPtr packet, IntPtr excludedPeer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_broadcast_selective(IntPtr host, byte channelID, IntPtr packet, IntPtr[] peers, IntPtr peersLength); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_host_service(IntPtr host, out ENetEvent @event, uint timeout); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_host_check_events(IntPtr host, out ENetEvent @event); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_channel_limit(IntPtr host, IntPtr channelLimit); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_host_get_peers_count(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_host_get_packets_sent(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_host_get_packets_received(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_host_get_bytes_sent(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_host_get_bytes_received(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_flush(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_destroy(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_enable_compression(IntPtr host); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_host_prevent_connections(IntPtr host, byte state); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_throttle_configure(IntPtr peer, uint interval, uint acceleration, uint deceleration); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_peer_get_id(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_peer_get_ip(IntPtr peer, byte[] ip, IntPtr ipLength); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern ushort enet_peer_get_port(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_peer_get_mtu(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern PeerState enet_peer_get_state(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_peer_get_rtt(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_peer_get_lastsendtime(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint enet_peer_get_lastreceivetime(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern ulong enet_peer_get_packets_sent(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern ulong enet_peer_get_packets_lost(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern ulong enet_peer_get_bytes_sent(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern ulong enet_peer_get_bytes_received(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr enet_peer_get_data(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_set_data(IntPtr peer, IntPtr data); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_ping(IntPtr peer); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_ping_interval(IntPtr peer, uint pingInterval); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_timeout(IntPtr peer, uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_disconnect(IntPtr peer, uint data); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data); + + [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)] + internal static extern void enet_peer_reset(IntPtr peer); + } +} \ No newline at end of file diff --git a/Assets/Plugins/ENet/ENet.cs.meta b/Assets/Plugins/ENet/ENet.cs.meta new file mode 100644 index 0000000..3155a71 --- /dev/null +++ b/Assets/Plugins/ENet/ENet.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63f983852b846de4fb6f4b5f5c8ff2ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/ENet/enet.bundle b/Assets/Plugins/ENet/enet.bundle new file mode 100644 index 0000000..fcea0f1 Binary files /dev/null and b/Assets/Plugins/ENet/enet.bundle differ diff --git a/Assets/Plugins/ENet/enet.bundle.meta b/Assets/Plugins/ENet/enet.bundle.meta new file mode 100644 index 0000000..0261662 --- /dev/null +++ b/Assets/Plugins/ENet/enet.bundle.meta @@ -0,0 +1,87 @@ +fileFormatVersion: 2 +guid: d8b22096e0cd05d438a5ce5c8c476dde +timeCreated: 1534525764 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': OSXIntel + second: + enabled: 0 + settings: + CPU: None + - first: + '': OSXIntel64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: x86_64 + DefaultValueInitialized: true + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/ENet/enet.dll b/Assets/Plugins/ENet/enet.dll new file mode 100644 index 0000000..8456205 Binary files /dev/null and b/Assets/Plugins/ENet/enet.dll differ diff --git a/Assets/Plugins/ENet/enet.dll.meta b/Assets/Plugins/ENet/enet.dll.meta new file mode 100644 index 0000000..582d07b --- /dev/null +++ b/Assets/Plugins/ENet/enet.dll.meta @@ -0,0 +1,100 @@ +fileFormatVersion: 2 +guid: ea612cd63b7675e45a42fb9dfe0f1130 +timeCreated: 1523304125 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXUniversal: 0 + Exclude Win: 1 + Exclude Win64: 0 + - first: + '': OSXIntel + second: + enabled: 0 + settings: + CPU: None + - first: + '': OSXIntel64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/ENet/libenet.so b/Assets/Plugins/ENet/libenet.so new file mode 100644 index 0000000..92ccdc2 Binary files /dev/null and b/Assets/Plugins/ENet/libenet.so differ diff --git a/Assets/Plugins/ENet/libenet.so.meta b/Assets/Plugins/ENet/libenet.so.meta new file mode 100644 index 0000000..84233df --- /dev/null +++ b/Assets/Plugins/ENet/libenet.so.meta @@ -0,0 +1,100 @@ +fileFormatVersion: 2 +guid: 2c08207c2b3231b44b4d0e0b3f192720 +timeCreated: 1534085982 +licenseType: Pro +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXUniversal: 1 + Exclude Win: 0 + Exclude Win64: 0 + - first: + '': OSXIntel + second: + enabled: 0 + settings: + CPU: None + - first: + '': OSXIntel64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 1 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor.meta b/Assets/Plugins/Editor.meta new file mode 100644 index 0000000..00bac3d --- /dev/null +++ b/Assets/Plugins/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0beb693c809d0984c9c7cab0ec68d95f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/JetBrains.meta b/Assets/Plugins/Editor/JetBrains.meta new file mode 100644 index 0000000..900761c --- /dev/null +++ b/Assets/Plugins/Editor/JetBrains.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3bd1b32cca60b2c42b4f4cfa0d2c7131 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll b/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll new file mode 100644 index 0000000..762a23c Binary files /dev/null and b/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll differ diff --git a/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll.meta b/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll.meta new file mode 100644 index 0000000..4d518ad --- /dev/null +++ b/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 00c1842c82111de41a0cfca34a666b63 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas.meta b/Assets/Plugins/Entitas.meta new file mode 100644 index 0000000..81d8de5 --- /dev/null +++ b/Assets/Plugins/Entitas.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b26923a7bb19648c08460aa6a08afb22 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/CHANGELOG.md b/Assets/Plugins/Entitas/CHANGELOG.md new file mode 100644 index 0000000..fd8aca1 --- /dev/null +++ b/Assets/Plugins/Entitas/CHANGELOG.md @@ -0,0 +1,2336 @@ +## [1.13.0] - 2019-02-20 +### Added +- Update roslyn +- Update hierarchy icons + +### Changed +- Change Preferences minified and doubleQuoteMode api + +### Fixed +- Fix hierarchy icon null warning + +## [1.12.2] - 2018-12-15 +### Fixed +- Fix EntityLinkHierarchyIcon #843 + +## [1.12.1] - 2018-12-09 +### Added +- Fix Jenny.exe load default `Jenny.properties` when not specified + +## [1.12.0] - 2018-12-09 +### Added +- Add Preferences require concrete properties path +- Add CodeGeneratorPreferencesWindow +- Add EntitasEntityLinkHierarchyIcon + +### Changed +- Move Jenny Unity Preferences to its own editor window `Tools/Jenny/Preferences...` + +### Removed +- Remove EntitasCache + +### Upgrade +- Jenny has been decoupled from Entitas even more +- Jenny now stores its config in Jenny.properties by default +- Entitas now stores its config in Entitas.properties by default +- Please split Preferences.properties into Entitas.properties and Jenny.properties or delete them to automatically create new default files + +## [1.11.0] - 2018-11-19 +### Added +- Add support for multiple event attributes with different event target #810 + +### Upgrade +- All listener interfaces with `EventTarget.Any` need to be renamed + - `IPositionListener` -> `IAnyPositionListener` + - `OnPosition` -> `OnAnyPosition` + +## [1.10.0] - 2018-11-14 +### Changed +- Remove IContext from EntityLink.Link() method signature + +### Upgrade +- Remove IContext from EntityLink.Link() method signature + +## [1.9.2] - 2018-11-04 +### Added +- Hotfix for Unity Asset Store missing mono hosted msbuild + +## [1.9.1] - 2018-11-03 +### Added +- Fix MultiReactive system retaining entities multiple times #818 + +## [1.9.0] - 2018-11-03 +### Added +- Optimize generated code #780 + - This increases entity and component creation performance +- Optimize Visual Debugging performance #799 + - This increases the performance especially when having thousands of entities +- Generate XML documentation #792 + - This will show documentation in the IDE +- Using latest [bee](https://github.com/sschmid/bee) + +### Changed +- Context ctor signature changed. Generate to fix compiler errors. + If you don't use the [Entitas.Roslyn plugins](http://u3d.as/NuJ) from the Unity Asset Store, + you have to manually fix the affected generated context classes. E.g. `Generated/Game/GameContext.cs`, + add `() => new GameEntity()` as a last argument + +```csharp +public sealed partial class GameContext : Entitas.Context { + + public GameContext() + : base( + GameComponentsLookup.TotalComponents, + 0, + new Entitas.ContextInfo( + "Game", + GameComponentsLookup.componentNames, + GameComponentsLookup.componentTypes + ), + (entity) => + +#if (ENTITAS_FAST_AND_UNSAFE) + new Entitas.UnsafeAERC(), +#else + new Entitas.SafeAERC(entity), +#endif + () => new GameEntity() // <---------- update here + ) { + } +} +``` + +- Release retained entities when ReactiveSystem.Execute() has an exception #812 + - This fixes spamming the Unity console with error messages + +# 1.8.2 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +http://u3d.as/NuJ + +#### Entitas +⚙️ Add "@" in front of component name if it is a C# keyword #744 #756 @roygear +⚙️ Added convenience ctor to JobSystem to use all available threads on the device +⚙️ JobSystem.Execute() is now virtual + + +#### Jenny +🛠 Fixed delays when running `jenny server` +🆕 `jenny wiz` beta. Running Jenny.exe without args will automatically run `jenny wiz` +🆕 `jenny help` aka man page + +Jenny Wizard is wip. If you have feedback or feature request, please add a comment here +https://github.com/sschmid/Entitas-CSharp/issues/778 + + +# 1.8.1 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +⚙️ Add "@" in front of component name if it is a C# keyword #744 #756 @roygear +⚙️ Added convenience ctor to JobSystem to use all available threads on the device +⚙️ JobSystem.Execute() is now virtual + + +#### Jenny +🛠 Fixed delays when running `jenny server` +🆕 `jenny wiz` beta. Running Jenny.exe without args will automatically run `jenny wiz` +🆕 `jenny help` aka man page + +Jenny Wizard is wip. If you have feedback or feature request, please add a comment here +https://github.com/sschmid/Entitas-CSharp/issues/778 + + +# 1.8.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +⚙️ Enabled [Event] for non components #743 +⚠️ Renamed `CustomComponentNameAttribute` to `ComponentNameAttribute` + + +#### Jenny +⚙️ Added more logs to `gen` command +```csharp +Generating using /Users/sschmid/Dev/C#/Half-life3/Jenny.properties +Generating done (13220 files in 4 seconds) +``` +⚙️ Added group to ICommand to support grouped usage overview +#### Asset Store Version + + +# 1.7.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Visual Debugging +⚙️ StringTypeDrawer now uses EditorGUILayout.DelayedTextField + +#### Code Generator +🆕 Added CleanupAttribute +⚠️ Renamed `UniquePrefixAttribute` to `FlagPrefixAttribute` + +#### Asset Store Version +🆕 Cleanup Data Providers and Code Generators + +Instead of manually writing custom systems to remove components or destroy +entities, you can now use the new `[Cleanup]` attribute to automatically +generate `CleanupSystems` for you. + +E.g. adding the `[Cleanup]` attribute to a `DestroyedComponent` can replace +your custom `DestroyEntitySystem`. + +```csharp +[Cleanup(CleanupMode.DestroyEntity)] +public sealed class DestroyedComponent : IComponent { +} +``` + +There are currently two options: +- CleanupMode.DestroyEntity +- CleanupMode.RemoveComponent + +`CleanupMode.DestroyEntity` will generate a system that destroys all +entities which have this component. + +`CleanupMode.RemoveComponent` will generate a system that will remove +this component from all entities which have this component. + + +# 1.6.1 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +🛠 Fixed context.Reset() which doesn't remove event handlers anymore #725 +🛠 Updated EntitasStats to exclude JobSystem and Feature + +#### Jenny +🛠 Fixed Jenny dropdown UI to not show 'mixed...' anymore +⚙️ Added Jenny Server toggle to UI +⚙️ Added dry run option +⚠️ Removed EnsureStandalonePreProcessor +🆕 Added WarnIfCompilationErrorsPreProcessor + + +# 1.6.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### General +⚠️ Changed Entitas Asset Store package structure by separating Desperate Devs dlls into their own folder +Please run `jenny auto-import -s` or modify `Preferences.properties` to update the paths to the plugins if necessary + + +#### Entitas +🛠 Added support to remove event listeners within event callback #698 + +⚠️ Improved Entitas Event API `[Event(bool)]` #717 +Use "find and replace" to update all your EventAttribute usages +`[Event(true)]` is now `[Event(EventTarget.Self)]` +`[Event(false)]` is now `[Event(EventTarget.Any)]` + +⚙️ Added support for `[DontDrawComponent]` for all components #678 +💄 Updated comments for `group.RemoveAllEventHandlers()` #684 +🛠 Fixed check for updates + + +#### DesperateDevs +⚙️ Updated `TargetFrameworkProfilePreProcessor` #721 +🛠 Added `str.ToUnixPath()` + + +# 1.5.2 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +🛠 Fixed EventSystemsGenerator generated EventSystems per context but those systems contained EventSystems from all context + +#### DesperateDevs +🛠 Added TcpMessageParser to reliably receive separate messages from a tcp stream + + + +# 1.5.1 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### DesperateDevs +⚙️ Added better error message to EnsureStandalonePreProcessor + +When EnsureStandalonePreProcessor is activated it will prevent you from accidentally generating in Unity. +To generate in Unity make sure EnsureStandalonePreProcessor is not activated. + + +# 1.5.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +🆕 Added JobSystem for multi threading as a proof of concept. + +```csharp +public sealed class RotateSystem : JobSystem { + + public RotateSystem(GameContext context, int threads) : + base(context.GetGroup(GameMatcher.AllOf(GameMatcher.Rotation, GameMatcher.RotationVector)), threads) { + } + + protected override void Execute(GameEntity entity) { + entity.rotation.value = entity.rotation.value * Quaternion.Euler(entity.rotationVector.value); + } +} +``` + +Limitations: +- Don't use generated methods like Add() and Replace() +- Modify component values directly +See https://github.com/sschmid/Entitas-CSharp/issues/325#issuecomment-373961878 + +This is not a general purpose solution for all problems. It can be used to solve certain performance intense areas in your game. It can be very useful if there's a very large number of entities that have to be processed, or if the data transformation involves heavy calulations. + +⚠️ EventSystemsGenerator generates EventSystems per context now. +🛠 Removed dependency on Entitas.CodeGeneration.Plugins from Entitas.VisualDebugging.Unity.Editor #312 + +#### DesperateDevs +🆕 Added EnsureStandalonePreProcessor to prevent accidentally generating in Unity + + +# 1.4.2 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +This is a hotfix release to patch the bugs introduced by the code generator refactoring from 1.4.0. + +#### Entitas +🛠 Fixed needing to generate code twice to when event got removed #620 +⚙️ Added group.AsEnumerable() to support linq +⚙️ Added partial keyword to ComponentEntityApiInterfaceGenerator #607 +⚙️ Changed EntityLink exception to be a warning +⚙️ ComponentData can clone CodeGeneratorData + +#### Jenny +🆕 Added ValidateProjectPathPreProcessor #572 #563 + +#### DesperateDevs +⚙️ Added logger.Reset() + + +# 1.4.1 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +This is a hotfix release to patch the bugs introduced by the code generator refactoring from 1.4.0. + +#### Entitas +🛠 Fixed component name generation for EventType.Removed #631 (thanks to @hegi25) + +#### Jenny +🛠 Fixed jenny "Collection was modified; enumeration operation may not execute." #628 +🛠 Fixed jenny "Index was outside the bounds of the array." #628 + + + +# 1.4.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +Breaking changes are marked with ⚠️️ + +#### Entitas +🆕 Added group.GetEntities(buffer) #624 +🆕 Made group iteration alloc free #624 +⚙️ Added support for multiple events per component +⚙️ Added `removeComponentWhenEmpty` to optionally remove or keep empty listener component +🛠 Fixed accessing non existing component in generated event system for EventType.Removed +🛠 Fixed events inheriting unique attribute from component +⚠️ Removed EventType.AddedOrRemoved +💄 Refactored and simplified all code generators + +# 1.3.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +This update improves the new Entitas Events introduced in 1.1.0 + +Breaking changes are marked with ⚠️️ + +#### Entitas +⚙️ Added support for multiple event listeners per entity +⚙️ EventInterfaceGenerator generates correct filename matching the class name. Thanks to @c0ffeeartc +⚠️️ Renamed some generators. Please use `auto-import` to update the generator names + + +# 1.2.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +This update improves the new Entitas Events introduced in 1.1.0 + +Breaking changes are marked with ⚠️️ + +#### Entitas +⚙️ Added support for multiple contexts for events. Context prefix will be skipped if a component only has one context in favour of a nicer API +⚠️️ Passing sender entity as first argument in event delegate +🆕 Added new optional event types `EventType.Added`, `EventType.Removed`, `EventType.AddedOrRemoved` +🛠 Fixed typo `_listsners` in event generator Thanks to @FNGgames + + +#### Jenny +🛠 Fixed `scan` command + + +# 1.1.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +🆕 Added Events aka Reactive-UI #591 +⚠️ Changed `ComponentEntityInterfaceGenerator` to generate `IXyzEntity` insetad of `IXyz` to avoid name collisions with `EventInterfaceGenerator` +⚙️ Added enum support for Code Generator Attributes +⚙️ Removed `partial` keyword from ComponentGenerator +⚙️ Removed attributes from generated components + +#### Jenny +🆕 Added `Jenny-Auto-Import` scripts to reducde terminal interaction +⚙️ Added silent `-s` info to Jenny help page +⚙️ Using Console.WriteLine when prompting user input to support silent mode +⚙️ CodeGeneratorData can now be cloned + + +# 1.0.0 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +🛠 Workaround for Unity 2017.3 GUI mask bug (still shows `Mixed...` instead of `Everything` -> Unity bug) #569 + + +# 0.47.9 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +🛠 Fixed issue with Entitas.Roslyn plugin and non-components with context attibute #564 +🛠 Fixed `auto-import` not making relative search paths on Windows + +#### Other +⚙️ Included readme files in zip +⚙️ Updated CONTRIBUTING.md and updated bee 🐝 + + +# 0.47.8 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +🛠 Fixed `The given assembly name or codebase was invalid` on windows #561 + + +# 0.47.7 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +🛠 Auto-Import properly handles paths with spaces #555 + + +# 0.47.6 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +- Using correct properties file for each Unity project by saving only the filename instead of full path + + +# 0.47.5 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +- Hotfix for EntityLink throwing errors OnApplicationQuit + + +# 0.47.4 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +#### Entitas +- Hotfix for broken EntityLink (thanks to @c0ffeeartc for reporting so quickly) + + +# 0.47.3 + +As always, the Unity Asset Store version might take a few days to be processed +and accepted by Unity. Please check for updates in 2 - 4 days here: +https://www.assetstore.unity3d.com/#!/content/87638 + +See and discuss changes in [Milestone 0.47.3](https://github.com/sschmid/Entitas-CSharp/milestone/17?closed=1) + +(Finally went back to Milestone development :) Transparency FTW!) + +#### Entitas +- EntityLink will immediately throw an exception if the gameObject is destroyed but still linked to an entity #470 +- Fixed VisualDebugging Toggle in the Entitas Preferences Window #540 + +#### Jenny +- Even more support for multiple properties, see #550 + + +# 0.47.2 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days here: https://www.assetstore.unity3d.com/#!/content/87638 + +Here's another update to improve the code generator experience. Thanks again for all your great feedback! +And thanks for going through this with me :) We're almost there! + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added migration 0.47.2 + +#### Jenny +- Added silent mode for `jenny fix` to simplify `jenny auto-import` experience. Use `-s`, e.g `jenny auto-import -s` +- Added a potential fix for `jenny client gen` command never completes #546 +- Renamed keys from `CodeGenerator.*` to `Jenny.*`. Please apply migration 0.47.2 +- Added support to run CLI from any location +- Warning when no properties found +- Removed leading "./" from added searchPaths added by `jenny auto-import` +- The Roslyn foundation moved to DesperateDevs +- Using the latest Roslyn libs + +#### Other +- Entitas project cleanup and maintenance +- Added more automation tasks to bee 🐝 + +# 0.47.1 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days here: https://www.assetstore.unity3d.com/#!/content/87638 + +#### Jenny +- Handling BadImageFormatException +- Not showing warnings for unresolved assemblies anymore +- Fixed closing AssemblyResolver before all plugin dependencies were loaded +- Fixed jenny server construction not complete before executing client command + + +# 0.47.0 + +#### General +- Brand new build automation workflow (bee 🐝) +- Completely automated build, sync and release flow for faster future updates (bzzz 🐝) +- Only Entitas.zip is attached to GitHub releases +- Jenny CLI is only bundled in Asset Store version +- Added Assets folder to Entitas.zip #535 +- More flexible plugin-based CLI architecture + +#### Jenny +- Unity support for multiple properties files by adding switch button to Entitas Preferences in case multiple properties files exist #536 +- Better CLI support for multiple properties files by showing a warning in case multiple properties files exist #536 +- Fixes for server / client errors (ObjectDisposedException) #529 +- Renamed key `CodeGenerator.CLI.Ignore.UnusedKeys` to `Ignore.Keys` +- `auto-import` reflects assemblies and sets plugins based on content instead of name +- `auto-import` automatically detects custom plugins in Unity project without manually setting up searchPaths +- Added visual lines to `dump` +- Renamed `ICodeGeneratorBase` to `ICodeGenerationPlugin` +- Fixed `IConfigurable` commands not getting configured +- Added minified properties support + +#### Asset Store +- Fix for NullReferenceException (Entitas.Roslyn.SymbolExtension.ToCompilableString) #534 +- Support for WrapperComponent #532 + +# 0.46.3 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### Code Generation +- Added `IPreProcessor` +- Added TargetFrameworkProfilePreProcessor +- Fixed problems with Roslyn Generator and Visual Studio on Windows #503 + + +# 0.46.2 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### Code Generation +- Added `IDoctor` for custom diagnosis and custom symptoms treatment :) Will help improving the + code generator setup experience that is aimimg for a one-click setup +- Implemented IDoctor for ComponentDataProvider, EntityIndexDataProvider and DebugLogPostProcessor +- Removed `isEnabledByDefault`from all plugins + +#### TCPezy +- ResolveHost returns IPv4 address to fix issue with server / client mode on windows + + +# 0.46.1 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### Entitas.VisualDebugging.CodeGeneration.Plugins +- Added deep device profiling support to generated Feature class #497 + +#### Unity +- Added buttons to generate DefaultInstanceDrawer and TypeDrawer +- Added deep device profiling toggle to Entitas Preferences + +Entitas - Deep Device Profiling + + +# 0.46.0 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +This release is a maintenance release as announced here: + +https://github.com/sschmid/Entitas-CSharp/issues/508 + +As the project got more mature the Entitas repository not only contained the ECS core but also a few other +modules like Logging, Serialization, Networking, Code Generator, Common Utils and more. +The goal of this refactoring was to extract reusable modules and increase the focus of the Entitas repository +on ECS. Reusable modules have been successfully extracted to their own standalone projects. Overall, with the +increased focus that is achieved by having standalone projects I expect the quality to raise, too. This is +generally the case when you have reusable code that is battle tested in multiple different scenarios. + +As mentioned in #508 those projects all have the `DesperateDevs` namespace. You maybe already know about +Desperate Devs because of the new YouTube channel where I will upload more and more Video on ECS, +best practices and Software Architecture. Subscribe if you don't want to miss future videos. + +https://www.youtube.com/channel/UC2q7q7tcrwWHu5GSGyt_JEQ + +As a result of this refactoring I was able to remove a lot of noise from the Entitas repository and I could +easily fix platform depended bugs without any distraction. + +entitas-desperatedevs + +Entitas will benefit from having the Desperate Devs dependencies as it enforces modularity and reusability. +Additionally, it will be possible to use awesome tools like TCPezy (DesperateDev.Networking) and Jenny (DesperateDevs.CodeGeneration) independently. + + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Obsolete notice +- Removed methods marked obsolete in 0.42.0 from April 2017 +- Blueprints are now completely removed from the zip files (sources still available) + +#### Preferences +- Showing properties name in Edit Button + +#### Jenny (aka Code Generator) +- CodeGeneratorPreferencesDrawer will keep unavailable plugins #496 +- Added Display Dialog for auto import +- Added a secret and hidden cli command, can you find it? ❤️ + +#### TCPezy (aka entitas server) +- Fixed Unhandled Exception (appeared on Windows only) #489 + +#### Other +- Changed language level of all projects to C# 4.0 +- Deleted CodeGenerator Unity Test project + + +# 0.45.1 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### CodeGenerator +- Added Auto Import Button to Entitas Preferences. This will detect plugins and automatically set them in Entitas.properties + + +# 0.45.0 + +Thanks for the feedback on the new code generator so far. This update contains a lot of great improvments. +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + + +#### Entitas +- Fixed flag components increasing the componentPool stack #445 +- Logging all retained entities in ContextStillHasRetainedEntitiesException #448 +- Added support for multiple indexed members per component #464 + +``` +public sealed class MyComponent : IComponent { + + // Multiple fields are now supported + + [EntityIndex] + public int value; + + [EntityIndex] + public int otherValue; +} + +// will generate +context.GetEntitiesWithMyValue(...); +context.GetEntitiesWithMyOtherValue(...); +``` + + +#### CodeGenerator +- Displaying more prominent popup in Unity when trying to generate with compile errors #463 + +![entitas-codegenerator-compileerrorpopup](https://user-images.githubusercontent.com/233700/32519395-e8dccbdc-c40c-11e7-8a6c-08f176b23244.png) + +- AssemblyResolver won't append dll to exe extension +- Changed code generator keys and removed default values +- Changed code generator cli keys and removed default values +- Added auto-import command. Use `entitas auto-import` to automatically populate Entitas.properties +- `entitas status` command will detect potential collisions, e.g. duplicate providers from the default plugins and the roslyn plugins +- `entitas fix` can resolve plugin collisions +- `entitas fix` command will tell you to press any key +- Removed `-a` keepAlive in favour of `entitas server` and `entitas client` +- Fixed client only sending first command to server #482 +- Default Plugins are now in folder called Entitas +- Refactored all commands and simplified many utils methods +- `Entitas.exe` now with capital E + + +#### Roslyn +- Added custom support for multi-dimensional arrays types like `int[,,]` #481 +Let me know if more types need custom support. + +#### Migration +- Added migration for 0.45.0 + + +# 0.44.0 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### Unity CodeGenerator +- Added new menu item which connects to an external code generator server instance + +#### CodeGenerator CLI +- Added server command +- Added client command +- Added startCodeGenerator files for macOS and Windows + +#### Example +Start the code generator server by double clicking `startCodeGenerator` on macOS or `startCodeGenerator.bat` on Windows, or use the terminal + +``` +$ mono CodeGenerator/entitas.exe server +``` + +You can now either use the new Unity menu item `Tools/Entitas/Generate with external Code Generator` +which connects to a running server and sends the `gen` command or connect yourself like this + +``` +$ mono CodeGenerator/entitas.exe client gen +``` + +This will connect to a running server and send the `gen` command. This is useful if you want to add your own custom commands +in your IDE like Visual Studio or Rider (or others). + +Using the code generator server and client is optional but can greatly improve your workflow and +can drastically reduce the overhead of generating new files. + + +# 0.43.0 + +As always, the Unity Asset Store version might take a few days to be processed and accepted by Unity. +Please check for updates in 2 - 4 days. + +#### Breaking changes +The new code generator is part of `Entitas.Roslyn`. The Roslyn Plugins are now called `Entitas.Roslyn.CodeGeneration.Plugins`. If you already tested the new code generator beta, please update Entitas.properties +- `Entitas.Roslyn.CodeGeneration.Plugins` +- `Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider` +- `Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider` + +New mandatory keys have been added to Entitas.properties. You can automatically add them by running `entitas fix` + +#### CodeGenerator +- Added `ICodeGeneratorCachable` to cache and share objects between multiple plugins to avoid redundant calculations +- Using the objectCache to share the AssemblyResolver between all plugins +- Added CodeGenerator to default searchPaths +- Added Unity menu item to generate with CLI + +entitas-unity-cli + +#### CodeGenerator CLI +- Updated New command to use preferences +- Added CLIConfig with new key `Entitas.CodeGeneration.CodeGenerator.CLI.Ignore.UnusedKeys` to add keys that should be ignored when running `entitas status` or `entitas doctor`. You can automatically ignore keys by pressing `i` + +entitas-cli-ignoreunusedkeys + +- Added support for custom properties files. Each command optionally accepts a path to a properties file. This way you can have multiple different configs how to run the code generator, e.g. one with the reflection-based code generator and one with the roslyn code generator. + +```csharp +entitas gen My.properties +``` +- Pretty CLI + +#### Unity +- Added Edit Button to Entitas Preferences + +entitas-preferences-editbutton + +#### Asset Store Version +- Changed project structure. The Plugins are now called `Entitas.Roslyn.CodeGeneration.Plugins` +- Using the objectCache to share the ProjectParser between all plugins which speeds up the code generation process +- Updated all packages to latest version and downgraded all projects from .NET 4.6.1 to .NET 4.6 +- Added more dependencies to remove warnings when running `entitas doctor` or `entitas gen` + +entitas-roslyn-nowarnings + + +# 0.42.5 + +#### General +- Refactored Preferences to fully embrace Entitas.properties and User.properties + +#### CodeGenerator CLI +- Added format command +- keepAlive argument which will keep the process alive. This is very useful when using the new roslyn code generator to avoid reloading the whole parsing infrastructure. Using this argument ith roslyn results in super fast generation time + +```csharp +$ entitas gen -a +``` + + +# 0.42.4 + +#### Notes +Entitas development is back on track again and the wait is over. This is probably one of the last updates before Entitas reaches 1.0.0. +This verion has been tested successfully in combination with the new code generator that will work even when the code is not compiling. + +#### General +- Added support for User.properties. You can now either overwrite values sepcified in Entitas.properties or use placeholders + +Create a new file called User.properties and specify the keys and values that should be overwritten. +You can also specify placeholers like this `${myPlaceholder}` and specify the key either in Entitas.properties or User.properties. +see: [Match One - Entitas.properties](https://github.com/sschmid/Match-One/blob/master/Entitas.properties) +see: [Match One - User.properties](https://github.com/sschmid/Match-One/blob/master/User.properties) + +#### Entitas +- Groups are now enumerable to iterate over groups circumventing the internal caching and potentially reducing memory allocations #408 + +```csharp +foreach (var e in group) { + // Look closely: no group.GetEntities() +} +``` + +#### CodeGenerator CLI +- Added commands add, set, remove, dump + +#### VisualDebugging +- Fixed Entitas Stats not ignoring built-in MultiReactiveSystem in systems count +- VisualDebugging only lets you add components that the entity doesn't already have +- GUI fixes + +#### Other +- Properties are now formatted by default for better readability +- Ensuring dependencies in build scripts + + +# 0.42.3 + +Hotfix release for +- Fix Code Generation NullReferenceException in Unity 2017 #414 + + +# 0.42.2 + +See and discuss changes in [Milestone 0.42.2](https://github.com/sschmid/Entitas-CSharp/milestone/16) + +#### CodeGenerator +- Fix Code Generation NullReferenceException in Unity 2017 #414 +- EntityIndexGenerator is sorting entity indices +- CodeGenerator fix command runs recursively #409 +- Code Generator CLI maintenance + +#### VisualDebugging +- Update EntityDrawer to draw correct object type #399 #406 + + +# 0.42.1 + +## Top new features: +Added missing support for flag components in ComponentEntityInterfaceGenerator + +### General +- CodeGenerator CLI + Plugins are now included in zips and not deployed as separate zips + +#### CodeGenerator +- Added support for flag components in ComponentEntityInterfaceGenerator +- Removed GameState from default contexts. Defaults are now Game and Input + + +# 0.42.0 + +See and discuss changes in [Milestone 0.42.0](https://github.com/sschmid/Entitas-CSharp/milestone/15) + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +- Removed Entitas.Blueprints.Unity.* +- Changed ReactiveSystem.GetTrigger method signature +- Marked obsolete: `context.DestroyEntity(entity)`. Use `entity.Destroy()` instead +- Marked obsolete: `context.CreateCollector(matcher, event)`, use new `context.CreateCollector(triggerOnEvent)` when you need `.Removed` or `.AddedOrRemoved` (e.g. GameMatcher.View.Removed()) + +## Top new features: +- Use MultiReactiveSystem to process entities from different contexts in one system (see [Test Example](https://github.com/sschmid/Entitas-CSharp/blob/develop/Tests/Unity/VisualDebugging/Assets/Examples/VisualDebugging/Systems/SomeMultiReactiveSystem.cs)) +- Use `entity.Destroy()` instead of `context.DestroyEntity(entity)` +- Unit Testing in external console works on Windows now + +#### General +- Moved Entitas menu item under the Tools tab +- Removed Entitas.Blueprints.Unity.* from zips +- Creating new zip for code generator default plugins +- UX improvements + +#### Entitas +- Added MultiReactiveSystem to support reactive systems observing different contexts #303 +- Added TriggerOnEvent +- Renamed `entity.Destroy()` to `entity.InternalDestroy()` to reduce confusion +- Added `entity.Destroy()` instead of `context.DestroyEntity(entity)` #254 + +#### CodeGenerator +- Added ComponentEntityInterfaceGenerator #303 +- Updated ContextObserverGenerator to avoid `System.Security.SecurityException` on Windows #375 +- .ToSafeDirectory() supports empty string and “.” to specify current directory + + +# 0.41.2 + +After installing please check your Entitas.properties. Due to the addition of `IConfigurable` for code generator plugins +some keys in Entitas.properties changed. `entitas.exe doctor`, `entitas.exe status` and `entitas.exe fix` can help you +fixing any issues. A new default Entitas.properties file will be created if none is found. The default Entitas.properties +should work with Unity without modification. For reference take a look at [Match-One - Entitas.properties](https://github.com/sschmid/Match-One/blob/master/Entitas.properties) + +Exiting limitation mentioned in the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) still apply (Entitas.Blueprints.CodeGeneration.Plugins is not supported in the code generator CLI) + +## Top new features: +- UpdateCSProjPostProcessor will update your project.csproj. Generated methods are available immediately without switching to Unity and waiting for the project to be updated. This feels even better when using the new code generator (roslyn coming soon) where you don't even have to compile your project anymore - super fast feedback loops! +- Better out-of-the-box experience when starting a new Unity project. Everything will work without any manual setup. Just generate :) +- Great code generator CLI experience with helpful commands like `status` and `fix` which will let you modify Entitas.properties interactively +- Logo refinements based on magic numbers (1.618 - golden ratio) :D + +#### CodeGenerator +- Added `IConfigurable` interface to easily create customizable and configurable code generator plugins +- Fixed `ignoreNamespaces` by using the new `IConfigurable` #376 +- Added UpdateCSProjPostProcessor which updates project.csproj so you don't need to wait for Unity to update your project +- Greatly improved the code generator CLI. `status` and `fix` command will help you a lot to spot and fix problems in Entitas.properties +- Added `Compile.cs` to ensure `Assembly-CSharp.dll` in Unity +- CodeGenFile converts to unix line endings when setting fileContent #352 +- Added progress indicator to code generator CLI when running with `-v` in verbose mode +- Added multiple smaller sub configs for TargetDirectory, ContextNames, Assemblies, ProjectPath, IgnoreNamespaces +- Placeholder `${myPlaceHolder}` in properties will remain even when overwriting +- Caching AssemblyResolver + +#### VisualDebugging +- Drawing generic text labels for configurables found in Entitas.properties +- Better error handling when Entitas.properties has problems + +### General +- Refined logo. More pleasant to the eye and more readable in smaller icons + + +# 0.41.1 + +See and discuss changes in [Milestone 0.41.1](https://github.com/sschmid/Entitas-CSharp/milestone/14) + +#### CodeGenerator +- Added ContextMatcherGenerator #358 #358 @marczaku + +```csharp +// instead of +Matcher.AllOf(GameMatcher.Position, GameMatcher.View); + +// you can write +GameMatcher.AllOf(GameMatcher.Position, GameMatcher.View); +``` + +- Added option to ignore namespace in generated api + - Simply add `Entitas.CodeGeneration.Plugins.IgnoreNamespaces = true` to your Entitas.properties + - You can run `entitas status` to see if any plugins require additional keys + +``` +$ entitas status +Missing key: Entitas.CodeGeneration.Plugins.IgnoreNamespaces +``` + +- Added `IConfigurable` to support optional keys needed in Entitas.properties + +#### Other +- Added properties.ToDictionary() + + +# 0.41.0 + +See and discuss changes in [Milestone 0.41.0](https://github.com/sschmid/Entitas-CSharp/milestone/13) + +This milestone paves the way for a more customizable version of Entitas. A streamlined and modular project structure enables +deploying Entitas as Dlls which opens the door for 3rd party Addons and the extendable command line code generator. + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +- Renamed Entitas.properties config keys +- Removed context.DeactivateAndRemoveEntityIndices() +- Removed context.ClearGroups() +- New namespaces as a consequence of project restructuring + +#### General +- Project restructuring. All Entitas projects are now in Entitas.sln, including all Addons and Unity projects +- Deploying Entitas as Dlls instead of source code which has multiple benefits, e.g. + - Entitas Unity menu appears even if code doesn't compile + - Enables 3rd party Addons and Plugins + - Enables command line code generator + +#### Entitas +- Extracted Automatic Entity Reference Counting (AERC) as a strategy which can be set per context +- Better exception handling for Entitas.properties config +- Renamed config keys +- Removed context.DeactivateAndRemoveEntityIndices() +- Removed context.ClearGroups() + +#### CodeGenerator +- Added command line code generator #158 #353 + - Unsupported Plugins: Entitas.Blueprints.CodeGeneration.Plugins, Entitas.CodeGeneration.Unity.Editor +- ContextObserverGenerator puts VisualDebugging in try-catch to support Unit Testing #362 +- Added FeatureClassGenerator and removed Feature class from Entitas to support conditional compilation with `#if UNITY_EDITOR` +- Added MethodData instead of using System.Reflection.MethodInfo +- Added CleanTargetDirectoryPostProcessor + +#### VisualDebugging +- Removed Feature class +- UX improvements +- Better exception handling for Entitas.properties config + + +# 0.40.0 + +See and discuss changes in [Milestone 0.40.0](https://github.com/sschmid/Entitas-CSharp/milestone/12) + +#### Note +Please update Entitas.properties by opening Entitas Preferences. Added `assemblyPath` and `codeGeneratorAssemblyPath` +to code generator config. When not selected already, navigate to `Library/ScriptAssemblies/` in your Unity project +and select `Assembly-CSharp.dll` for the assembly and `Assembly-CSharp-Editor.dll` for the code generator assembly. + +#### Entitas.CodeGenerator +- Add ConsoleWriteLinePostProcessor #342 +- Make EntitasPreferences.CONFIG_PATH public field in order to customize the path to the config file #342 +- Add CodeGeneratorUtil to simplify creating an instance based on Entitas.properties +- Add `assemblyPath` and `codeGeneratorAssemblyPath` to code generator config + +#### Entitas.Unity.VisualDebugging +- Added SystemWarningThreshold to visualize slow systems +- Tinting slow systems red +- Systems list unfolded by default + + +# 0.39.2 + +See and discuss changes in [Milestone 0.39.2](https://github.com/sschmid/Entitas-CSharp/milestone/11) + +#### Entitas +- Optimize group update performance for component add/remove #321 +- Ignore indexed properties in PublicMemberInfo #339 +- More explicit EntityIndex.ToString() +- More explicit EntityLink.ToString() + +#### Entitas.Unity.VisualDebugging +- Automatically draw types. No TypeDrawers #327 + + +# 0.39.1 + +See and discuss changes in [Milestone 0.39.1](https://github.com/sschmid/Entitas-CSharp/milestone/10) + +#### Entitas +- Added `entityIndex.ToString()` with name #329 + +#### Entitas.CodeGenerator +- Add ContextObserverGenerator #337 +- Simplified EntityIndexGenerator getKey + +#### Entitas.Unity.VisualDebugging +- Optimize DebugSystemsInspector #338 + +#### Entitas.Unity.Blueprints +- Blueprints not persistent after changes to components. #331 + + +# 0.39.0 + +See and discuss changes in [Milestone 0.39.0](https://github.com/sschmid/Entitas-CSharp/milestone/9) + +#### Entitas +- Added `entityIndex.ToString()` with name #329 + +#### Entitas.CodeGenerator +- Add `contexts.Reset()` (#317) +- Removed ComponentDataProvider without namespace #323 +- Don't generate EntityIndex when not specified #326 +- Cache static component index lookup into local var #316 +- Review and check for namespace awareness #328 + + +# 0.38.0 + +See and discuss changes in [Milestone 0.38.0](https://github.com/sschmid/Entitas-CSharp/milestone/8) + +This seems to be the release of enhancements! Lots of useful improvments and features have been added to +increase productivity and ease of use. + +#### Breaking changes +- Removed HideInBlueprintsInspector (#270 #306) +- Changed interface `ITypeDrawer` +- Added Contexts constructor (#286) + +# Entitas +- Using ToString on subclassed components, too (#290) +- Fixed cached entity ToString() wasn’t updated when calling entity.Release() +- Fixed typo `TEntitiy` to `TEntity`(#291) + +# Entitas.Unity +- Simplified DrawTexture +- Refactored EntitasLayout + +# Entitas.CodeGenerator +- Generating Entity Indices (#75 #319) +- Added priority to ICodeGenFilePostProcessor +- Move logic to DebugLogPostProcessor to speed up code generation +- Added MergeFilesPostProcessor (#301) +- Added Contexts constructor (#286) +- Added default context (#288) +- Using MemberData instead of PublicMemberInfo in DataProviders (#280) +- Added progess report to code generator + +# Entitas.Unity.CodeGenerator +- Added cancellable progess bar when generating + +# Entitas.Unity.VisualDebugging +- Redesigned Entitas Preferences Window +- Redesigned DebugSystemsInspector +- Redesigned Type Drawers +- Added component member search (#298) +- Added search field to DictionaryTypeDrawer (#299) +- Better UX, better Buttons +- Entitaslayout.SearchTextField won’t affect GUI.change +- Fixed Hashset changes didn’t replace component +- Added `context.FindContextObserver()` for getting ContextObserver (#295) +- Added default constructor to Feature class (#293) +- Added Entitas Stats Dialog +- EntityDrawer will use pooled components +- Simplified EntityDrawer and TypeDrawers +- Removed TypeEqualityComparer (#289) +- Drawing public fields of unsupported types +- Updated code templates for TypeDrawer and DefaultInstanceCreators (#297) + +# Entitas.Unity.Migration +- Redesigned Entitas Migration Window + +# General +- Using HD header textures + + +# 0.37.0 + +See and discuss changes in [Milestone 0.37.0](https://github.com/sschmid/Entitas-CSharp/milestone/7) + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +The deed is done. Entitas went type-safe! This was a huge task and I'm happy to finally share this with you guys! +This feature makes Entitas safer and more managable in growing code bases and will eliminate certain kind of bugs. Thanks to @mstrchrstphr +for starting the conversation and proposing solutions. + +#### Entitas +- Entitas went type-safe! (#257 #266) +- Entity API doesn't return Entity anymore (e.g. e.AddComponent()) +- Fixed matchers not recalculating hash when changed +- Added EntityIndex support for multiple keys (#279 #281) +- Removed as many virtual keywords as possible + +#### Entitas.CodeGenerator +- Entitas went type-safe! (#257 #266) +- Rewrote code generator architecture (#265 #274 #275) +- ComponentsGenerator doesn't generate `e.IsMoveble(value)`. Only `e.isMoveble = value` +- ComponentsGenerator Entity API doesn't return Entity anymore (e.g. e.AddPosition()) +- Added additional ComponentGenerator which respects namespaces (#274) + +#### Entitas.Blueprints +- Entitas went type-safe! (#257 #266) + +#### Entitas.Migration +- Automatically embedding all migrations to Entitas.Migration.exe + +#### Entitas.Unity.Codegenerator +- Added sloc (Source Lines Of Code) and loc (Lines Of Code) info + +#### Entitas.Unity.VisualDebugging +- Entitas went type-safe! (#257 #266) +- Added EntityLink (#271) +- Prettier search fields that support multiple search strings + +#### Other +- New folder structure with Entitas as the core and everything else as Addons +- Complete reorganization of the project structure (more modular and easier to reason about) + + +# 0.36.0 + +See and discuss changes in [Milestone 0.36.0](https://github.com/sschmid/Entitas-CSharp/milestone/6) + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Removed pool.CreateSystem() (#233 #237) +- Removed `IEnsureComponents`, `IExcludeComponents`, `ISetPools`, `ISetPool`, `IReactiveSystem`, `IMultiReactiveSystem`, `IEntityCollectorSystem` +- Changed the ReactiveSystem to be an abstract class instead of `IReactiveSystem`. You need to override `GetTrigger`, `Filter` and `Execute`. +This enables filtering entities based on component values (#234) +- Renamed the term Pool to Context (#99 #250) +- Renamed `EntityCollector` to `Collector` (#252 #253) +- Renamed `GroupEventType` to `GroupEvent` and removed the prefix `OnEntity` +- entity.ToString uses component.ToString(). Override ToString() in your components +to get a nice description, e.g. `Health(42)` (#203 #196) + +#### Entitas.CodeGenerator +- Removed OldPoolsGenerator +- Fixed code generator line ending for header + +#### Entitas.Unity.VisualDebugging +- Improved VisualDebugging performance by reusing StringBuilders +- Added support for `ICleanupSystem` and `ITearDownSystem` +- Changed SystemsMonitor.axisRounding to 1 +- Fix error when turning visual debugging on/off in Unity 5.4 or newer (#222) +- Changed default blueprint creation location (#206 #248) + +### Other +- Simplified build pipeline + + +# 0.35.0 + +See and discuss changes in [Milestone 0.35.0](https://github.com/sschmid/Entitas-CSharp/milestone/5) + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Fixed adding disabled entities to groups (#192, #193) +- Removed matcher with filter (#194, #195) + +### Other +- Maintenance, cleanup and formatting +- Completely new build system to create new releases + + +# 0.34.0 + +See and discuss changes in [Milestone 0.34.0](https://github.com/sschmid/Entitas-CSharp/milestone/4) + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added api to clone entities (#178, #182) + - `pool.CloneEntity(e);` + - `entity.CopyTo(target);` + +- Added EntityIndex constructor with EqualityComparer (#170, #186) +- Rename GroupObserver to EntityCollector (#168, #188) +- Added filter condition to matchers (#165, #189) + - `Matcher.Position.Where(e => e.position.x > 10);` + +#### Entitas.Serialization.Blueprints +- Added HideInBlueprintInspectorAttribute (#185) + +#### Other +- Improved snippets +- Added Visual Studio snippets (#172) +- Added TestRunner to support test debugging (#175, #176) +- Updated build scripts (#173, #177) +- Added tests for code formatting + + +# 0.33.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added pools.CreateSystem() +- Added ObjectPool and ObjectCache and updated EntitasCache to use ObjectCache (#157) +- Added entityIndex.Activate() and removing entity indices from pool (#163) +- Renamed IDeinitializeSystem to ITearDownSystem (#164) + +#### Entitas.CodeGenerator +- TypeReflectionProvider sorts pool names and ToUppercaseFirst() (#155) +- CodeGeneratorConfig doesn't add default pool anymore (#156) + +#### Other +- Added repository icon +- Added snippets (see Snippets folder) + + +# 0.32.0 + +Summer break is over! Entitas development is back on track! +Thanks all of you guys for using and contributing to Entitas. +This release is packed with improvements from all of you, thanks for that! + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### General +- Lots of maintenance, refactoring, documentation and cleanup. Checked every class and every test ;) +- Removed unused usings (#134 @thematthopkins ) +- Added script to generate docset and included it in build script (#141 @mstrchrstphr) +- Updated policy.mdpolicy to support latest Xamarin Studio +- Fixed inconsistent Line endings (#116 @ParagonFable) + +#### Entitas +- Added new `Pools` class. There is no static Pools anymore but an instance. +- Added `ISetPools` to inject the shared pools instance +- Removed `pool.CreateSystem()` and `pool.CreateSystem(Type type)` (Apply migration 0.32.0) +- Fixed `pool.CreateSystem()` not creating a ReactiveSystem for IGroupObserverSystem +- Added `EntityIndex` (#154) +- `pool.Reset()` removes all event handlers +- Fixed retain / release didn't update entity toString cache +- Added `EntitasCache` for object pooling of collections to reduce memory allocations +- Updated Entity, Matcher and Pool to use EntitasCache (less garbage :heart:) +- Added `ICleanupSystem` +- Added `IDeinitializeSystem` +- Pushing removed component to component pool after dispatching event + +#### Entitas.CodeGenerator +- Fixed ComponentIndicesGenerator with multiple pools (#124) +- CodeGeneratorConfig will add default pool +- Fixed pools order if default pool exists + +#### Entitas.Unity.CodeGenerator +- CodeGenerator Preferences is using MaskField instead of Toggles now + +#### Entitas.Unity.VisualDebugging +- Less editor repaints for DebugSystemsInspector to improve performance +- Fixed system stats (Log stats) not ignoring Feature class +- Add ITypeDrawer for doubles (#132 @bddckr) +- Added support for enum masks (#132 @bddckr) +- Adjusted foldout spacing in custom inspector (#149 @ByteSheep) + +#### Other +- Updated keys for Entitas.properties and moved files from Entitas.Unity to Entitas.Serialization.Configuration +- Moved Properties from Entitas.Unity to Entitas.Serialization + + +# 0.31.2 + +#### Entitas.CodeGenerator +- All attributes can now be used for classes, interfaces and structs + + +# 0.31.1 + +#### Entitas.CodeGenerator +- Improved component generation for classes and interfaces and added support for default pool [Pool] +- Added support to CustomComponentNameAttribute to generate multiple components with different names for one class or interface + +```csharp +// This will automatically generate PositionComponent and VelocityComponent for you +[Pool, CustomComponentName("Position", "Velocity")] +public struct IntVector2 { + public int x; + public int y; +} +``` + +- Added support for generating components for structs +- Not generating obsolete pool attributes for generated classes + + +# 0.31.0 + +#### General +- Removed obsolete code + +#### Entitas.CodeGenerator +- Generating components for attributed classes and interfaces + +```csharp +// will automatically generate SomeClassComponent for you +[Core] +public class SomeClass { + public string name; + + public SomeClass(string name) { + this.name = name; + } +} +``` + +- Added support to add empty PoolAttribute to assign component to default pool + +```csharp +// using [Pool] will also add this component to Pools.pool +[Core, Pool] +public class SomeComponent : IComponent { +} +``` + +#### Entitas.Unity.VisualDebugging +- Added IComponentDrawer which can draw the whole component +- Added EntitasEntityErrorHierarchyIcon to indicate retained entities in the hierarchy +- Added CharTypeDrawer +- Fixed components not updating in the inspector (#107) +- Improved SystemsMonitor and added average line + +![Entitas-SystemsMonitor](https://cloud.githubusercontent.com/assets/233700/15198441/a515d764-17d7-11e6-965c-83c027fa89f7.png) + +#### Entitas.Unity.Serialization.Blueprints +- Fixed finding all BinaryBlueprints even when not loaded +- Correctly saving Blueprints when setting all BinaryBlueprints +- Added BlueprintsNotFoundException +- BinaryBlueprintInspector creates new pools instead of using one of Pools.allPools +- Fixed pool not shown when entering play-mode while a blueprint was selected in the project view +- Not caching blueprints when UNITY_EDITOR to enable live edit + +# 0.30.3 + +#### Entitas.CodeGenerator +- Added support for whitespace, '-' and braces in blueprint names + +#### Entitas.Unity.Serialization.Blueprints +- Blueprints.FindAllBlueprints orders all blueprints by name +- Fixed pool not shown in hierarchy + + +# 0.30.2 + +#### Note +This release introduces Blueprints for Entitas (Beta). Update if you want to +use and play with Blueprints. [Read more...](https://github.com/sschmid/Entitas-CSharp/wiki/Blueprints-(Beta)) + +#### Entitas.CodeGenerator +- Only creating PoolObserver when Application.isPlaying +- Added BlueprintsGenerator + +#### Entitas.Unity.VisualDebugging +- Added more options for sorting systems in the inspector +- Removing event handlers from pool observer when leaving play-mode + +#### Entitas.Serialization.Blueprints +- Added Blueprints (and more) + +#### Entitas.Unity.Serialization.Blueprints +- Added BlueprintInspector (and more) + +#### Other +- Moved build scripts into a folder + + +# 0.30.1 + +#### Entitas.Unity.VisualDebugging +- Fixed GameObjectDestroyExtension.DestroyGameObject() compile time error (#91) +- Improved SystemsMonitor.Draw() to use correct available width even with scrollbars +- Tweaked drawing systems list +- Added EntitasPoolErrorHierarchyIcon to visualize when there are erros + +#### Other +- Updated build_commands.sh to generate C# project from Unity + + +# 0.30.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added IGroupObserverSystem which allows ReactiveSystems to observe multiple pools +- Added pools.CreateGroupObserver() to simplify creating a GroupObserver for multiple pools + +#### Entitas.CodeGenerator +- TypeReflectionProvider ignores abstract IComponents (#88) +- Renamed ComponentsGenerator to ComponentExtensionsGenerator +- Renamed PoolAttributeGenerator to PoolAttributesGenerator + +#### Entitas.Unity +- Moved Assets/Entitas.Unity to Assets/Entitas/Unity +- Simplified folder structure in Entitas-Unity.zip + +#### Entitas.Unity.CodeGenerator +- Ignoring obsolete code generators +- Generate button changes size depending on generators list height + +#### Entitas.Unity.VisualDebugging +- Added Feature class which inherits from Systems or DebugSystems for you, so you don't have to care anymore +- Fixed MissingReferenceException occurring occasionally when stopping game (#71) +- Added support for editing entities in EditorMode (non-playing mode) +- Fixed bug when components are added on entity creation (#87) +- Added clear buttons to search textfields +- Improved DateTimeTypeDrawer +- Added new hierarchy icons for pool and systems + +#### Entitas.Migration +- Added M0300 +- Moving Entitas.Migration into Entitas/Migration/Editor when creating Entitas-Unity.zip + + +# 0.29.1 + +#### Entitas.CodeGenerator +- Added missing support for components with properties +- Updated ComponentsGenerator to use entity.CreateComponent() + +#### Entitas.Unity.CodeGenerator +- Added missing support for components with properties + + +# 0.29.0 + +#### Obsolete +Marked old PoolMetaData constructor obsolete. If you encounter compile errors please apply Migration 0.26.0, open C# project and generate again. + +#### General +- Unified Entitas sub projects into a single project +- Unified all Unity projects into a single project +- Documentation maintenance + +#### Entitas +- Removing all event handler for entity.OnEntityReleased after event got dispatched +- Printing entity in EntityIsNotDestroyedException +- Added TypeExtension.ImplementsInterface() +- Added component types to PoolMetaData +- Made all methods in Systems virtual +- Added auto generated header to generated files + +``` +//------------------------------------------------------------------------------ +// +// This code was generated by Entitas.CodeGenerator.ComponentsGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +``` + +#### Entitas.CodeGenerator +- Using pool specific componentIds lookup when generating matchers for components with multiple pools +- TypeReflectionProvider ignores interfaces + +#### Entitas.Serialization +- Added Entitas.Serialization +- Added PublicMemberInfo + +#### Entitas.Unity.CodeGenerator +- Compile errors won't block code generation anymore +- Printing total generated file count when generating + +#### Entitas.Unity.VisualDebugging +- Destroying EntityBahviour when entity got released +- Using entity component pool and providing correct previous and new component +- Added unique color for each component in EntityInspector +- Added component search field in EntityInspector + +Entitas-Component-Search + +- 'Destroy Entity' Buttons are now red +- Simplified EntityInspector and made methods static +- Unfolded components info is now shared between entities within same pool +- Added shortcuts to Entitas Preferences and Generate +- Improved TypeDrawers +- Stepper UI tweaks + +![Entitas.Unity.VisualDebugging-Systems](https://cloud.githubusercontent.com/assets/233700/13554882/9c0bd7c0-e3b3-11e5-89ec-65fa888f0a48.png) + +- Renamed 'Script Call Optimization' to 'Optimizations' +- Added EntitasEditorLayout + + +# 0.28.2 + +#### Entitas +- Added ReactiveSystem destructor to prevent memory leaks +- Added GroupObserver destructor to prevent memory leaks + +#### Entitas.Unity.VisualDebugging +- EntityInspector now supports dropping UnityEngine.Object into fields that are null + +![Entitas.Unity.VisualDebugging-DefaultInstanceCreator](https://cloud.githubusercontent.com/assets/233700/12884636/ea8c468c-ce5f-11e5-91a9-0fdf83de7252.png) + +- UI tweaks + + +# 0.28.1 + +#### Entitas.Unity +- Added "Script Call Optimization" to Entitas Preferences Window +- Added priority to IEntitasPreferencesDrawer +- Tweaked UI + +![Entitas.Unity-ScriptCallOptimization](https://cloud.githubusercontent.com/assets/233700/12832387/e893b3ec-cb99-11e5-8ccb-d3478ca0c6dc.png) + +#### Entitas.Unity.VisualDebugging +- Added toggle to Entitas Preferences to enable or disable Visual Debugging +- Tweaked UI + +![Entitas.Unity.VisualDebugging-Toggle](https://cloud.githubusercontent.com/assets/233700/12832391/ec74d2e8-cb99-11e5-87b3-f76e2e9ea58d.png) + + +# 0.28.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added documentation (#55) +- Added an object pool for components (#58) +- Added pool.ClearComponentPool(index) and pool.ClearComponentPools() +- Added ENTITAS_FAST_AND_UNSAFE compiler flag. When set it will speed up e.Retain() and e.Release() (#59) + +#### Entitas.CodeGenerator +- Generated component extensions are now reusing components using a component object pool when destroying entities (#58) +- Added tests for testing the logic of generated files +- Decoupling code generation logic by adding Code Generator Intermediate Format (#62) +- Added TypeReflectionProvider +- Supporting components with namespace +- Simplified linq expressions +- Removed generated systems +- The Code Generator is not depending on Entitas anymore + +#### Entitas.CodeGenerator.TypeReflection +- Added Entitas.CodeGenerator.TypeReflection project + +#### Entitas.Unity +- Added `keys` and `values` getter to Properties + +#### Entitas.Unity.VisualDebugging +- Added system search field to DebugSystemsInspector +- UI tweaks and performance optimizations +- Fixed logging wrong system stats +- Added header image and current version label to Entitas Preferences Window + +![Entitas.Unity.Visualdebugging-preferences](https://cloud.githubusercontent.com/assets/233700/12795069/a13e5b6e-cab8-11e5-937d-870790e2bfe1.png) + +#### Entitas.Unity.Migration +- Added Entitas.Unity.Migration which provides an easy way to migrate source files +- Added header image and current version label to Entitas Migration Window + +![Entitas.Unity.Migration](https://cloud.githubusercontent.com/assets/233700/12795026/6acf24b4-cab8-11e5-90e3-98a103676d50.png) + +#### Other +- Removed redundant files and gitignored Entitas in all Unity projects (#63) +- Removed Unity projects from Entitas.sln +- Removed warnings + + +# 0.27.0 + +#### Note +If you're using Entitas with Unity, please open the Entitas preferences and make sure that all your desired code generators are activated. Due to some code generator renamings the ComponentLookupGenerator and the ComponentsGenerator are inactive. Activate them (if desired) and generate. + +#### Entitas +- Added `pool.Reset()` which clears all groups, destroys all entities and resets creationIndex + +#### Entitas.CodeGenerator +- Renamed some code generators +- Added `CustomPrefixAttribute` to support custom prefixes for flag components +``` +[CustomPrefix("flag")] +public class DestroyComponent : IComponent { +} + +// default +entity.isDestroy = true; + +// with CustomPrefixAttribute +entity.flagDestroy = true; +``` + +#### Entitas.Unity +- Added "Feedback" menu item to report bugs, request features, join the chat, read the wiki and donate + +#### Entitas.Unity.CodeGenerator +- Removing invalid code generator names from Entitas.properties + +#### Entitas.Unity.VisualDebugging +- Lots of UI tweaks +- Added toggle to sort systems by execution duration +- Added toggle to hide empty systems +- ReactiveSystems are highlighted with a white font color +- Added Clear Groups Button +- Added Entity Release Button +- Splitted systems list into initialize and execute systems and visualizing them separately +- Improved stepper UI + +#### Entitas.Migration +- All migrations now contain information about on which folder they should be applied + +``` +0.26.0 + - Deactivates code to prevent compile erros + - Use on folder, where generated files are located +``` + +#### Other +- Added Commands.GenerateProjectFiles and using it in build.sh +- Updated build.sh and build_commands.sh to include latest MigrationAssistant.exe + + +# 0.26.1 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + + +# 0.26.0 + +#### General +- Updated projects to Unity 5.3 +- Improved all error messages and added hints +- Changed and applied policy.mdpolicy to all sources + +#### Entitas.Unity +- Moved Entitas Preferences to its own Editor Window + +![Entitas.Unity - Entitas Preferences Window](https://cloud.githubusercontent.com/assets/233700/12222689/9492611a-b7c3-11e5-880d-c4cc83c9234e.png) + +#### Other +- Added runTests.bat for running test on windows (#49) +- Updated license + + +# 0.25.0 + +#### Entitas +- Improved AERC performance +- Added group.RemoveAllEventHandlers() +- Added pool.ClearGroups() to remove all groups and remove all their event handlers +- Added pool.ResetCreationIndex() +- Throwing exception when there are retained entities and pool.DestroyAllEntities() is called +- Renamed entity.refCount to entity.retainCount + +#### Entitas.Unity.VisualDebugging +- Fixed creating entities +- Showing warning when there are retained entities + +#### Other +- Added UnityTests project with Unity Test Tools to fix a Unity specific HashSet bug + + +# 0.24.6 + +#### Entitas +- Changed entity.Retain() to accept an owner object + +#### Entitas.Unity.VisualDebugging +- Added VisualDebugging support for displaying owners of entities + +![Entitas.Unity.VisualDebugging-RefrenceCount](https://cloud.githubusercontent.com/assets/233700/11320810/0463033a-90a7-11e5-931b-5074b50d7e62.png) + + +# 0.24.5 + +#### Entitas +- Fixed dispatching group events after all groups are updated + +#### Entitas.CodeGenerator +- Supporting ENTITAS_DISABLE_VISUAL_DEBUGGING compiler flag + + +# 0.24.4 + +#### Entitas +- Added entity.componentNames. This field is set by Entitas.Unity.VisualDebugging to provide better error messages +- Added matcher.componentNames. This field is set by Entitas.Unity.CodeGenerator to provide better error messages +- entity.ToString() now removes ComponentSuffix +- Fixed typo + +#### Entitas.Unity.CodeGenerator +- ComponentExtensionsGenerator sets matcher.componentNames +- Removed generating unused using in ComponentExtensionsGenerator + +#### Other +- Added update_project_dependencies.sh +- Refactored build commands into build_commands.sh + + +# 0.24.3 + +#### Entitas +- Added systems.ActivateReactiveSystems() and systems.DeactivateReactiveSystems which should be called when you don't use systems anymore + +#### Other +- Merged shell scripts + + +# 0.24.2 + +#### General +- Renamed XyzEditor to XyzInspector +- Streamlined naming + +#### Entitas.Unity.VisualDebugging +- Simplified adding a component at runtime + +#### Other +- buildPackage.sh now creates Entitas-CSharp.zip and Entitas-Unity.zip + + +# 0.24.1 + +#### Entitas.Unity.VisualDebugging +- Added support for adding components to multiple entities at once at runtime + +![Entitas.Unity.VisualDebugging-Entity](https://cloud.githubusercontent.com/assets/233700/10293066/d4668120-6bb2-11e5-895e-cfdd25cc2e74.png) + + +# 0.24.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas.Unity.CodeGenerator +- Throwing exception when attempting to generate while Unity is still compiling or assembly won't compile + +#### Entitas.Unity.VisualDebugging +- Added support for creating entities and adding components at runtime + +![Entitas.Unity.VisualDebugging-PoolObserver](https://cloud.githubusercontent.com/assets/233700/10291395/d83c3ec4-6ba9-11e5-9c1d-3e18fe2c6370.png) + +![Entitas.Unity.VisualDebugging-Entity](https://cloud.githubusercontent.com/assets/233700/10291401/e15d29be-6ba9-11e5-8fc1-87767430342c.png) + + +# 0.23.0 + +#### Breaking changes +Before updating, please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +- Gerneral + - Updated and applied policy + +#### Entitas +- Reimplemented new matcher AnyOf and NoneOf + +```csharp +Matcher.AllOf(Matcher.A, Matcher.B) + .AnyOf(Matcher.C, Matcher.D) + .NoneOf(Matcher.E, Matcher.F); + +``` + +#### Entitas.CodeGenerator +- Updated generators to work with new matchers +- PoolsGenerator generates Pools.allPools (#39) +- Code Generators convert local newline to unix newline + +#### Entitas.Unity.CodeGenerator +- Changed CodeGeneratorConfig.disabledCodeGenerators to CodeGeneratorConfig.enabledCodeGenerators + + +# 0.22.3 + +#### Entitas +- Added reactiveSystem.Clear() and systems.ClearReactiveSystems() +- Added IClearReactiveSystem. When implemented, clears reactive system after execute finished + + +# 0.22.2 + +#### Fixes +- Entitas + - GroupObserver retains entities only once + +#### Entitas.Unity.VisualDebugging +- PoolObserver now shows retained entities +- Destroying EntityBehaviour e.OnEntityReleased instead of e.OnComponentRemoved + +#### Other +- New logo + + +# 0.22.1 + +#### Entitas +- Throwing an exception when releasing an entity that is not destroyed yet (#32) + +#### Entitas.Unity.VisualDebugging +- Added hierarchy icon +- Renamed DebugSystems related classes + +#### Other +- buildPackage.sh includes HierarchyIcon.png.meta + + +# 0.22.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +- Entitas + - Restored previous pool.DestroyEntity() behaviour + - IReactiveSystem and IMultiReactiveSystem changed and use `TriggerOnEvent` + - Use the command line tool `MigrationAssistant.exe` to automatically migrate IReactiveSystem + - Renamed IStartSystem.Start to IInitializeSystem.Initialize (#21) + +#### Fixes +- Entitas + - e.RemoveAllComponents() updates toString cache, even if entity has no components + +#### Entitas +- Added AERC (Automatic Entity Reference Counting) (#30, solves #25) +- Reduced gc allocations in e.RemoveAllComponents() +- Reduced gc allocations in pool.CreateEntity() and pool.DestroyEntity() +- pool.DestroyEntity() will clean suscribed event delegates of entities (#27) +- entity.ToString() will always use component type +- Streamlined and refactored tests and sources + +#### Entitas.Unity.VisualDebugging +- Improved SystemMonitorEditor graph performance (#14) + +#### Entitas.Migration +- Added M0220 (Migrates IReactiveSystem to combine trigger and eventTypes to TriggerOnEvent) +- Updated migration descriptions + +#### Other +- Removed project files +- Renamed updateDependencies.sh to updateProjects.sh +- buildPackage.sh includes EntitasUpgradeGuide.md in Entitas.zip + + +# 0.21.0 + +#### Fixes +- Entitas.Migration + - Changed target framework to .NET 3.5 to fix build errors in VisualStudio (#22) + +#### Entitas +- Changed pool.DestroyEntity(entity) behaviour + - won't trigger group.OnEntityRemoved anymore + - triggers group.OnEntityWillBeDestroyed + - removes entity from all groupObserver.collectedEntities + - ReactiveSystem doesn't pass on destroyed entities anymore +- ReactiveSystem doesn't call Execute() when filtered entities.Count == 0 + +#### Other +- Added project files (#18) + + +# 0.20.0 + +#### Breaking changes +- Entitas + - Removed all matchers except AllOfMatcher + +#### Entitas +- Added `IEnsureComponents` to optionally ensure entities passed in via ReactiveSystem have certain components +- Added `IExcludeComponents` to optionally exclude entities passed in via ReactiveSystem +- Added support for multiple PoolAttributes on components + +```csharp +[PoolA, PoolB, PoolC] +public class SomeComponent : IComponent {} +``` + +#### Entitas.Unity.CodeGenerator +- Added `disabledCodeGenerators` to CodeGeneratorConfig +- Added code generator toggles to CodeGeneratorPreferencesDrawer + +![Entitas.Unity.Codegenerator.disabledcodegenerators](https://cloud.githubusercontent.com/assets/233700/9046406/b4c6b7c2-3a2a-11e5-8624-a8988f684579.png) + +#### Entitas.Unity.VisualDebugging +- Nicer stats + + +# 0.19.1 + +#### Entitas +- GroupObserver supports observing multiple groups +- Added support for IMultiReactiveSystem +- Added internal entity._isEnabled to prevent modifying pooled entities +- Replaced internal object pool with Stack + +#### Entitas.CodeGenerator +- Fixed generated replace method, when replacing non existent component + +#### Entitas.Unity.VisualDebugging +- Drastically improved performance and memory usage by caching ToString() and reducing setting gameObject.name + + +# 0.19.0 + +#### Breaking changes +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +- Entitas + - Added new e.OnComponentReplaced and removed all *WillBeRemoved events + - Added component index and changed component to OnEntityAdded and OnEntityRemoved + - IReactiveSystem.Execute takes List instead of Entity[] + - Entitas now runs without producing garbage! + +- Entitas.CodeGenerator + - Removed support for properties in components + +- Entitas.Unity.VisualDebugging + - Replaced DebugPool with a more flexible PoolObserver + +#### Entitas +- Added group.OnEntityUpdated event with previous and new component + +#### Entitas.CodeGenerator +- ComponentExtensionsGenerator generates component object pool +- Converting newlines in generated files to Environment.NewLine (Pull request #11, thanks @movrajr) + +#### Other +- Added policy.mdpolicy + + +# 0.18.3 + +#### Entitas +- Added ReactiveSystem.Activate() and .Deactivate() + +#### Entitas.Unity.VisualDebugging +- Displaying nested systems hierarchy for DebugSystems + +![Entitas.Unity.VisualDebugging-DebugSystemsHierarchy](https://cloud.githubusercontent.com/assets/233700/8761742/6e26dd22-2d61-11e5-943b-94683b7b02ec.png) +![Entitas.Unity.VisualDebugging-DebugSystemsHierarchyEditor](https://cloud.githubusercontent.com/assets/233700/8761746/9628dbfe-2d61-11e5-9b75-570e5c538c0d.png) +- Unchecking a ReacitveSystem in VisualDebugging deactivates it + + +# 0.18.2 + +#### Entitas.CodeGenerator +- Fixed #9 + + +# 0.18.1 + +#### Entitas.CodeGenerator +- ComponentExtensionsGenerator now supports properties + + +# 0.18.0 + +#### Breaking changes +- Use the command line tool `MigrationAssistant.exe` to automatically migrate + - Changed IReactiveSystem.GetTriggeringMatcher to IReactiveSystem.trigger + - Changed IReactiveSystem.GetEventType to IReactiveSystem.eventType + +Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas.Unity +- Fixed code generation issues on Windows by converting and normalizing line endings +- Fixed EntitasCheckForUpdates.CheckForUpdates() by temporarily trusting all sources + + +# 0.17.0 + +#### Breaking changes +- Added `systemCodeGenerators` to CodeGenerator.Generate() + +```csharp +CodeGenerator.Generate(Type[] types, string[] poolNames, string dir, + IComponentCodeGenerator[] componentCodeGenerators, + ISystemCodeGenerator[] systemCodeGenerators, + IPoolCodeGenerator[] poolCodeGenerators) +``` + +#### Entitas.CodeGenerator +- Added PoolsGenerator which creates a getter for all pools + +```csharp +var pool = Pools.pool; +var metaPool = Pools.meta; +``` + +- Added SystemExtensionsGenerator + +```csharp +new Systems() + .Add(pool.CreateGameBoardSystem()) + .Add(pool.CreateCreateGameBoardCacheSystem()) + .Add(pool.CreateFallSystem()) + .Add(pool.CreateFillSystem()) + + .Add(pool.CreateProcessInputSystem()) + + .Add(pool.CreateRemoveViewSystem()) + .Add(pool.CreateAddViewSystem()) + .Add(pool.CreateRenderPositionSystem()) + + .Add(pool.CreateDestroySystem()) + .Add(pool.CreateScoreSystem()); +``` +- Added Components, Systems & Pools sub folders to generated folder + +#### Entitas.Unity +- Properties split with Environment.NewLine instead of '\n' + +#### Entitas.Unity.CodeGenerator +- Entitas preferences appends "/Generated/" to generated folder if necessary + +#### Entitas.Unity.VisualDebugging +- Using Queue for SystemsDebugEditor.systemMonitorData + + +# 0.16.0 + +#### Breaking changes +- Moved system getters from Systems to DebugSystems + +#### Entitas.Unity.CodeGenerator +- Generated ComponentIds use array instead of dictionary for component name lookup + +#### Entitas.Unity.VisualDebugging +- Added "Step manually" to DebugSystems +- Added activate / deactivate systems at runtime +- Displaying Systems.totalSystemsCount in SystemsDebugEditor +- Added SystemsMonitor visual graph + +![Entitas.Unity.VisualDebugging-DebugSystems](https://cloud.githubusercontent.com/assets/233700/8241713/3bf5e3ce-160b-11e5-8876-497bb09c04b1.png) +- Removed override DebugSystems.DestroyAllEntities() + + +# 0.15.0 + +#### Entitas +- Added entitas_version file +- Added CreateSystem(ISystem) to PoolExtensions +- Fixed typo GroupObserver.ClearCollectedEntities() + +#### Entitas.Unity +- Added "Check for updates..." menu item + +#### Entitas.Unity.VisualDebugging +- Added Stats menu item to log current components, systems and pools + + +# 0.14.0 + +#### General +- Upgraded all Unity projects to Unity 5 + +#### Entitas +- Added Systems class +- Re-combined pool extensions for creating systems to pool.CreateSystem() and removed pool.CreateStartSystem() and pool.CreateExecuteSystem() +- Fixed: Pool won't destroy entities it doesn't contain + +#### Entitas.Unity +- Properties now support multiline values and placeholder replacement with ${key} + +#### Entitas.Unity.CodeGenerator +- Added fluent api to Entity + +```csharp +pool.CreateEntity() + .IsGameBoardElement(true) + .IsMovable(true) + .AddPosition(x, y) + .AddResource(Res.Piece0) + .IsInteractive(true); +``` +- CodeGenerator takes arrays of IComponentCodeGenerator and IPoolCodeGenerator to generate files so you can easily provide your own custom code generators +- Added dialog for 'Migrate Matcher' menu item + +#### Entitas.Unity.VisualDebugging +- Added DebugSystems + +![Entitas.Unity.VisualDebugging-Systems](https://cloud.githubusercontent.com/assets/233700/7938066/ebe8b4b6-0943-11e5-9cec-ce694d624aca.png) +- Added HashSetTypeDrawer + + +# 0.13.0 + +#### Reminder +- Entitas 0.12.0 generates prefixed matchers based on the PoolAttribute and introduces some API changes. Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### General +- Split into multiple modules and seperate projects. Entitas now consists of + - Entitas + - Entitas.CodeGenerator + - Entitas.Unity + - Entitas.Unity.CodeGenerator + - Entitas.Unity.VisualDebugging + +#### Entitas.Unity +- Added IEntitasPreferencesDrawer to be able to extend the Entitas preferences panel + +#### Entitas.Unity.CodeGenerator +- Entitas preferences internal keys changed. Please check your settings in projectRoot/Entitas.properties and update keys + - Entitas.CodeGenerator.GeneratedFolderPath -> Entitas.Unity.CodeGenerator.GeneratedFolderPath + - Entitas.CodeGenerator.Pools -> Entitas.Unity.CodeGenerator.Pools + +#### Entitas.Unity.VisualDebugging +- Added support to set fields to null +- Added support to create a new instance if the value of a field is null +- Added IDefaultInstanceCreator to create default objects for unsupported types +- Added IDefaultInstanceCreator implementations for array, dictionary and string +- Added support to insert and remove elements from lists, arrays and dictionaries + +![Entitas.Unity.VisualDebugging-ITypeDrawer](https://cloud.githubusercontent.com/assets/233700/7339538/226d8028-ec72-11e4-8971-53029fb20da8.png) +- Added name property to DebugPool +- Added VisualDebuggingConfig and VisualDebuggingPreferencesDrawer + +![Entitas.Unity.VisualDebugging-Preferences](https://cloud.githubusercontent.com/assets/233700/7339599/ef454f34-ec74-11e4-9775-963f477bfb16.png) +- EntityDebugEditor can generate IDefaultInstanceCreator and ITypeDrawer implementations for unsupported types +- Fixed: handling null values +- Renamed ICustomTypeDrawer to ITypeDrawer +- Big refactoring to simplify drawing types + +#### Other +- buildPackage.sh keeps uncompressed source files in bin folder +- Added updateDependencies.sh which updates all dependencies of Entitas.Unity.CodeGenerator, Entitas.Unity.VisualDebugging and tests +- Renamed and moved files and folders to be more consistent with the new project structure + + +# 0.12.0 + +#### Important +- Entitas 0.12.0 generates prefixed matchers based on the PoolAttribute and introduces some API changes. Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added IStartSystem and pool.CreateStartSystem() extension +- Renamed pool.CreateSystem() to pool.CreateExecuteSystem() +- Added pool.CreateStartSystem() +- Added EntitasUpdater to automatically update the introduced matcher API changes + +#### Visual Debugging +- Fixed null exceptions +- Added support for multi dimensional and jagged arrays +- Removed Debug.Log + +#### Code Generator +- Added Code Generator PreferenceItem + - set generated folder path + - define multiple pools + +![Entitas.Unity.CodeGenerator-Preferences](https://cloud.githubusercontent.com/assets/233700/7296726/8d74bb5a-e9c2-11e4-8324-10a0db7191ff.png) +- Added PoolAttributeGenerator +- Generated Matcher is now prefixed based on PoolAttribute (e.g. UIMatcher) +- Generating ToString() for matchers to print component name instead of index +- IndicesLookupGenerator generates indices ordered alphabetically +- Added TypeGenerator to streamline string generation from types +- Added support for nested classes + +#### Other +- Added Properties and CodeGeneratorConfig to serialize Entitas preferences to file +- Removed warning in AbstractCompoundMatcher +- buildPackage.sh only builds when all tests are passing +- buildPackage.sh deletes meta files before creating zip archive + + +# 0.11.0 + +#### Reminder +- Entitas 0.10.0 included lots of renaming. Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) if you are on < v0.10.0 + +#### Entitas +- Added AllOfCompoundMatcher +- Added AnyOfMatcher +- Added AnyOfCompoundMatcher +- Added NoneOfMatcher +- Added NoneOfCompoundMatcher +- Updated Entitas to handle any implementation of IMatcher +- Fixed dispatching OnComponentAdded when replacing a non existing component with null +- Optimizations + +#### Visual Debugging +- Added support for custom type drawers `ICustomTypeDrawer` +- Added component folding and pooled entities count +- Added groups to PoolDebugEditor + +![Entitas.Unity.VisualDebugging-Groups](https://cloud.githubusercontent.com/assets/233700/6547980/e342b3fe-c5e9-11e4-8caa-77662a14679b.png) +- Added support for IList + +![Entitas.Unity.VisualDebugging-IList](https://cloud.githubusercontent.com/assets/233700/6547984/eecc3e3e-c5e9-11e4-98bb-700a84047abe.png) +- UI improvements + +#### Code Generator +- Fixed typeShortcuts to use type.FullName to support UnityEngine.Object (conflicted with System.Object) +- Added EntitasCodeGeneratorMenuItem + +#### Other +- Moved and renamed some folders +- Added buildPackage.sh which creates a bin/Entitas.zip with all necessary source files + + +# 0.10.0 + +#### Important +- Entitas 0.10.0 includes lots of renaming. Please follow the [Entitas upgrade guide](https://github.com/sschmid/Entitas-CSharp/blob/master/EntitasUpgradeGuide.md) + +#### Entitas +- Added empty ISystem and IExecuteSystem for more flexibility +- Added public creationIndex to Entity +- Observer is now on group not on pool +- Removed WillBeRemovedSystem and observer +- Added CreateSystem to PoolExtension +- Added fast entities count call to Pool +- Added creationIndex to entity.ToString() +- pool.CreateEntity() and pool.DestroyEntity() are now virtual + +#### Visual Debugging +- Added VisualDebugging + +#### Code Generator +- Supports enums nested in components +- Added option to [DontGenerate] to ignore generating index, too diff --git a/Assets/Plugins/Entitas/CHANGELOG.md.meta b/Assets/Plugins/Entitas/CHANGELOG.md.meta new file mode 100644 index 0000000..5e8231d --- /dev/null +++ b/Assets/Plugins/Entitas/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 00ae8a4e3a8088547a20786bf0efcc86 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor.meta b/Assets/Plugins/Entitas/Editor.meta new file mode 100644 index 0000000..1c8007b --- /dev/null +++ b/Assets/Plugins/Entitas/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2a3c3e3882416e244b6a412e9b7336b4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll b/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll new file mode 100644 index 0000000..8c1e1b7 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll.meta b/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll.meta new file mode 100644 index 0000000..a48108d --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Entitas.Migration.Unity.Editor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: a682205366e2916488e1710a1d247eb9 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll b/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll new file mode 100644 index 0000000..29652f7 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll.meta b/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll.meta new file mode 100644 index 0000000..a9cb82d --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Entitas.Migration.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 3cf1f755067df3940916718b319b500a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll b/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll new file mode 100644 index 0000000..067a093 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll.meta b/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll.meta new file mode 100644 index 0000000..bc2e66f --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Entitas.Unity.Editor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: e6cecfe638be65a45889fc95a6dc564d +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll b/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll new file mode 100644 index 0000000..407deec Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll.meta b/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll.meta new file mode 100644 index 0000000..3dff9ff --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Entitas.VisualDebugging.Unity.Editor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 7fe80afda444a9946bb841f447486a45 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images.meta b/Assets/Plugins/Entitas/Editor/Images.meta new file mode 100644 index 0000000..c5da2b7 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf379287a1828df4cb5cb89ef1962dbc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png new file mode 100644 index 0000000..5121142 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png.meta new file mode 100644 index 0000000..f45048a --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasContextErrorHierarchyIcon.png.meta @@ -0,0 +1,134 @@ +fileFormatVersion: 2 +guid: 35e2fad360fea426684933179da777df +labels: +- EntitasContextErrorHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png new file mode 100644 index 0000000..c26c2d0 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png.meta new file mode 100644 index 0000000..2c07b80 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasContextHierarchyIcon.png.meta @@ -0,0 +1,134 @@ +fileFormatVersion: 2 +guid: e23ad41464ef945d784cdb90d844e6c4 +labels: +- EntitasContextHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png new file mode 100644 index 0000000..5869963 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png.meta new file mode 100644 index 0000000..9d18e36 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityErrorHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 06bc0e5b0b5124fca8f5d7dde1d012b0 +labels: +- EntitasEntityErrorHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png new file mode 100644 index 0000000..f547db9 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png.meta new file mode 100644 index 0000000..2b5cafb --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 27b806265ee874b86aa2d28aba93ace2 +labels: +- EntitasEntityHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png new file mode 100644 index 0000000..4730dff Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png.meta new file mode 100644 index 0000000..769808e --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 9647a20347ff0494682ccccc9f1bc18d +labels: +- EntitasEntityLinkHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png new file mode 100644 index 0000000..2ce3fe3 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png.meta new file mode 100644 index 0000000..b123d2d --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasEntityLinkWarnHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 8efbceefe59cd4553baf36a0ef025dc1 +labels: +- EntitasEntityLinkWarnHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png b/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png new file mode 100644 index 0000000..c3a6a24 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png.meta new file mode 100644 index 0000000..a93efd2 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasHeader.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 65fb57b88da1f40c59682763366ab260 +labels: +- EntitasHeader +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png new file mode 100644 index 0000000..dc76185 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png.meta new file mode 100644 index 0000000..7ffc050 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 0ee737a83aa9b4b56b2058b2b651ff0a +labels: +- EntitasSystemsHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png new file mode 100644 index 0000000..6dd2f31 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png differ diff --git a/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png.meta b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png.meta new file mode 100644 index 0000000..b2d2338 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Images/EntitasSystemsWarnHierarchyIcon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 8fecc08fe51ec4ba990bfd58e4ed14b5 +labels: +- EntitasSystemsWarnHierarchyIcon +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: -1 + mipBias: -100 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: iPhone + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Android + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Plugins.meta b/Assets/Plugins/Entitas/Editor/Plugins.meta new file mode 100644 index 0000000..09d33e1 --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 24867a2e7b4c7194b87342e3dada0a74 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll new file mode 100644 index 0000000..d58cf51 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll.meta b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll.meta new file mode 100644 index 0000000..8dc522b --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.CodeGeneration.Plugins.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: d49f036a11b59dc44b93c343faf20331 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll new file mode 100644 index 0000000..3e48f58 Binary files /dev/null and b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll differ diff --git a/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll.meta b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll.meta new file mode 100644 index 0000000..fa770fc --- /dev/null +++ b/Assets/Plugins/Entitas/Editor/Plugins/Entitas.VisualDebugging.CodeGeneration.Plugins.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 23e0256869769d74f9c11b6c582d67db +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll b/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll new file mode 100644 index 0000000..127006b Binary files /dev/null and b/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll differ diff --git a/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll.meta b/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll.meta new file mode 100644 index 0000000..88a52a5 --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.CodeGeneration.Attributes.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 29176174d3b6a5e419407ecf91fc7772 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Entitas.Unity.dll b/Assets/Plugins/Entitas/Entitas.Unity.dll new file mode 100644 index 0000000..b2e41ec Binary files /dev/null and b/Assets/Plugins/Entitas/Entitas.Unity.dll differ diff --git a/Assets/Plugins/Entitas/Entitas.Unity.dll.meta b/Assets/Plugins/Entitas/Entitas.Unity.dll.meta new file mode 100644 index 0000000..7795b5b --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.Unity.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 3326eba764662ea4b8e1b7fb33b61dc3 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll b/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll new file mode 100644 index 0000000..68e0de0 Binary files /dev/null and b/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll differ diff --git a/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll.meta b/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll.meta new file mode 100644 index 0000000..bb611a1 --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.VisualDebugging.Unity.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 7850a6d4b7295b748974488a0e220ad4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Entitas.dll b/Assets/Plugins/Entitas/Entitas.dll new file mode 100644 index 0000000..c17a248 Binary files /dev/null and b/Assets/Plugins/Entitas/Entitas.dll differ diff --git a/Assets/Plugins/Entitas/Entitas.dll.meta b/Assets/Plugins/Entitas/Entitas.dll.meta new file mode 100644 index 0000000..7e2420d --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 2733dcb2f616a38459abbda54e2b0106 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/Entitas.xml b/Assets/Plugins/Entitas/Entitas.xml new file mode 100644 index 0000000..51d9f8f --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.xml @@ -0,0 +1,538 @@ + + + + Entitas + + + + Use context.CreateEntity() to create a new entity and + entity.Destroy() to destroy it. + You can add, replace and remove IComponent to an entity. + + + Occurs when a component gets added. + All event handlers will be removed when + the entity gets destroyed by the context. + + + Occurs when a component gets removed. + All event handlers will be removed when + the entity gets destroyed by the context. + + + Occurs when a component gets replaced. + All event handlers will be removed when + the entity gets destroyed by the context. + + + Occurs when an entity gets released and is not retained anymore. + All event handlers will be removed when + the entity gets destroyed by the context. + + + Occurs when calling entity.Destroy(). + All event handlers will be removed when + the entity gets destroyed by the context. + + + The total amount of components an entity can possibly have. + + + Each entity has its own unique creationIndex which will be set by + the context when you create the entity. + + + The context manages the state of an entity. + Active entities are enabled, destroyed entities are not. + + + componentPools is set by the context which created the entity and + is used to reuse removed components. + Removed components will be pushed to the componentPool. + Use entity.CreateComponent(index, type) to get a new or + reusable component from the componentPool. + Use entity.GetComponentPool(index) to get a componentPool for + a specific component index. + + + The contextInfo is set by the context which created the entity and + contains information about the context. + It's used to provide better error messages. + + + Automatic Entity Reference Counting (AERC) + is used internally to prevent pooling retained entities. + If you use retain manually you also have to + release it manually at some point. + + + Adds a component at the specified index. + You can only have one component at an index. + Each component type must have its own constant index. + The prefered way is to use the + generated methods from the code generator. + + + Removes a component at the specified index. + You can only remove a component at an index if it exists. + The prefered way is to use the + generated methods from the code generator. + + + Replaces an existing component at the specified index + or adds it if it doesn't exist yet. + The prefered way is to use the + generated methods from the code generator. + + + Returns a component at the specified index. + You can only get a component at an index if it exists. + The prefered way is to use the + generated methods from the code generator. + + + Returns all added components. + + + Returns all indices of added components. + + + Determines whether this entity has a component + at the specified index. + + + Determines whether this entity has components + at all the specified indices. + + + Determines whether this entity has a component + at any of the specified indices. + + + Removes all components. + + + Returns the componentPool for the specified component index. + componentPools is set by the context which created the entity and + is used to reuse removed components. + Removed components will be pushed to the componentPool. + Use entity.CreateComponent(index, type) to get a new or + reusable component from the componentPool. + + + Returns a new or reusable component from the componentPool + for the specified component index. + + + Returns a new or reusable component from the componentPool + for the specified component index. + + + Returns the number of objects that retain this entity. + + + Retains the entity. An owner can only retain the same entity once. + Retain/Release is part of AERC (Automatic Entity Reference Counting) + and is used internally to prevent pooling retained entities. + If you use retain manually you also have to + release it manually at some point. + + + Releases the entity. An owner can only release an entity + if it retains it. + Retain/Release is part of AERC (Automatic Entity Reference Counting) + and is used internally to prevent pooling retained entities. + If you use retain manually you also have to + release it manually at some point. + + + Returns a cached string to describe the entity + with the following format: + Entity_{creationIndex}(*{retainCount})({list of components}) + + + Use context.GetGroup(matcher) to get a group of entities which match + the specified matcher. Calling context.GetGroup(matcher) with the + same matcher will always return the same instance of the group. + The created group is managed by the context and will always be up to date. + It will automatically add entities that match the matcher or + remove entities as soon as they don't match the matcher anymore. + + + Occurs when an entity gets added. + + + Occurs when an entity gets removed. + + + Occurs when a component of an entity in the group gets replaced. + + + Returns the number of entities in the group. + + + Returns the matcher which was used to create this group. + + + Use context.GetGroup(matcher) to get a group of entities which match + the specified matcher. + + + This is used by the context to manage the group. + + + This is used by the context to manage the group. + + + This is used by the context to manage the group. + + + Removes all event handlers from this group. + Keep in mind that this will break reactive systems and + entity indices which rely on this group. + + + Determines whether this group has the specified entity. + + + Returns all entities which are currently in this group. + + + Fills the buffer with all entities which are currently in this group. + + + Returns the only entity in this group. It will return null + if the group is empty. It will throw an exception if the group + has more than one entity. + + + A context manages the lifecycle of entities and groups. + You can create and destroy entities and get groups of entities. + The prefered way to create a context is to use the generated methods + from the code generator, e.g. var context = new GameContext(); + + + Occurs when an entity gets created. + + + Occurs when an entity will be destroyed. + + + Occurs when an entity got destroyed. + + + Occurs when a group gets created for the first time. + + + The total amount of components an entity can possibly have. + This value is generated by the code generator, + e.g ComponentLookup.TotalComponents. + + + Returns all componentPools. componentPools is used to reuse + removed components. + Removed components will be pushed to the componentPool. + Use entity.CreateComponent(index, type) to get a new or reusable + component from the componentPool. + + + The contextInfo contains information about the context. + It's used to provide better error messages. + + + Returns the number of entities in the context. + + + Returns the number of entities in the internal ObjectPool + for entities which can be reused. + + + Returns the number of entities that are currently retained by + other objects (e.g. Group, Collector, ReactiveSystem). + + + The prefered way to create a context is to use the generated methods + from the code generator, e.g. var context = new GameContext(); + + + The prefered way to create a context is to use the generated methods + from the code generator, e.g. var context = new GameContext(); + + + Creates a new entity or gets a reusable entity from the + internal ObjectPool for entities. + + + Destroys all entities in the context. + Throws an exception if there are still retained entities. + + + Determines whether the context has the specified entity. + + + Returns all entities which are currently in the context. + + + Returns a group for the specified matcher. + Calling context.GetGroup(matcher) with the same matcher will always + return the same instance of the group. + + + Adds the IEntityIndex for the specified name. + There can only be one IEntityIndex per name. + + + Gets the IEntityIndex for the specified name. + + + Resets the creationIndex back to 0. + + + Clears the componentPool at the specified index. + + + Clears all componentPools. + + + Resets the context (destroys all entities and + resets creationIndex back to 0). + + + Removes all event handlers + OnEntityCreated, OnEntityWillBeDestroyed, + OnEntityDestroyed and OnGroupCreated + + + A JobSystem calls Execute(entities) with subsets of entities + and distributes the workload over the specified amount of threads. + Don't use the generated methods like AddXyz() and ReplaceXyz() when + writing multi-threaded code in Entitas. + + + Systems provide a convenient way to group systems. + You can add IInitializeSystem, IExecuteSystem, ICleanupSystem, + ITearDownSystem, ReactiveSystem and other nested Systems instances. + All systems will be initialized and executed based on the order + you added them. + + + Creates a new Systems instance. + + + Adds the system instance to the systems list. + + + Calls Initialize() on all IInitializeSystem and other + nested Systems instances in the order you added them. + + + Calls Execute() on all IExecuteSystem and other + nested Systems instances in the order you added them. + + + Calls Cleanup() on all ICleanupSystem and other + nested Systems instances in the order you added them. + + + Calls TearDown() on all ITearDownSystem and other + nested Systems instances in the order you added them. + + + Activates all ReactiveSystems in the systems list. + + + Deactivates all ReactiveSystems in the systems list. + This will also clear all ReactiveSystems. + This is useful when you want to soft-restart your application and + want to reuse your existing system instances. + + + Clears all ReactiveSystems in the systems list. + + + A ReactiveSystem calls Execute(entities) if there were changes based on + the specified Collector and will only pass in changed entities. + A common use-case is to react to changes, e.g. a change of the position + of an entity to update the gameObject.transform.position + of the related gameObject. + + + Specify the collector that will trigger the ReactiveSystem. + + + This will exclude all entities which don't pass the filter. + + + Activates the ReactiveSystem and starts observing changes + based on the specified Collector. + ReactiveSystem are activated by default. + + + Deactivates the ReactiveSystem. + No changes will be tracked while deactivated. + This will also clear the ReactiveSystem. + ReactiveSystem are activated by default. + + + Clears all accumulated changes. + + + Will call Execute(entities) with changed entities + if there are any. Otherwise it will not call Execute(entities). + + + Returns all entities matching the specified matcher. + + + Creates a new entity and adds copies of all + specified components to it. + If replaceExisting is true it will replace exisintg components. + + + Creates a Collector for this group. + + + A Collector can observe one or more groups from the same context + and collects changed entities based on the specified groupEvent. + + + Returns all collected entities. + Call collector.ClearCollectedEntities() + once you processed all entities. + + + Returns the number of all collected entities. + + + Creates a Collector and will collect changed entities + based on the specified groupEvent. + + + Creates a Collector and will collect changed entities + based on the specified groupEvents. + + + Activates the Collector and will start collecting + changed entities. Collectors are activated by default. + + + Deactivates the Collector. + This will also clear all collected entities. + Collectors are activated by default. + + + Returns all collected entities and casts them. + Call collector.ClearCollectedEntities() + once you processed all entities. + + + Clears all collected entities. + + + Returns the only entity in the collection. + It will throw an exception if the collection doesn't have + exactly one entity. + + + Returns the only entity in the collection. + It will throw an exception if the collection doesn't have + exactly one entity. + + + Adds copies of all specified components to the target entity. + If replaceExisting is true it will replace exisintg components. + + + Automatic Entity Reference Counting (AERC) + is used internally to prevent pooling retained entities. + If you use retain manually you also have to + release it manually at some point. + UnsafeAERC doesn't check if the entity has already been + retained or released. It's faster, but you lose the information + about the owners. + + + Automatic Entity Reference Counting (AERC) + is used internally to prevent pooling retained entities. + If you use retain manually you also have to + release it manually at some point. + SafeAERC checks if the entity has already been + retained or released. It's slower, but you keep the information + about the owners. + + + Base exception used by Entitas. + + + Implement this interface if you want to create a component which + you can add to an entity. + Optionally, you can add these attributes: + [Unique]: the code generator will generate additional methods for + the context to ensure that only one entity with this component exists. + E.g. context.isAnimating = true or context.SetResources(); + [MyContextName, MyOtherContextName]: You can make this component to be + available only in the specified contexts. + The code generator can generate these attributes for you. + More available Attributes can be found in Entitas.CodeGeneration.Attributes/Attributes. + + + Implement this interface if you want to create a system which should + execute cleanup logic after execution. + + + Implement this interface if you want to create a system which should be + executed every frame. + + + Implement this interface if you want to create a system which should be + initialized once in the beginning. + + + This is the base interface for all systems. + It's not meant to be implemented. + Use IInitializeSystem, IExecuteSystem, + ICleanupSystem or ITearDownSystem. + + + Implement this interface if you want to create a system which should + tear down once in the end. + + + Creates a Collector. + + + Creates a Collector. + + + A ReactiveSystem calls Execute(entities) if there were changes based on + the specified Collector and will only pass in changed entities. + A common use-case is to react to changes, e.g. a change of the position + of an entity to update the gameObject.transform.position + of the related gameObject. + + + Specify the collector that will trigger the ReactiveSystem. + + + This will exclude all entities which don't pass the filter. + + + Activates the ReactiveSystem and starts observing changes + based on the specified Collector. + ReactiveSystem are activated by default. + + + Deactivates the ReactiveSystem. + No changes will be tracked while deactivated. + This will also clear the ReactiveSystem. + ReactiveSystem are activated by default. + + + Clears all accumulated changes. + + + Will call Execute(entities) with changed entities + if there are any. Otherwise it will not call Execute(entities). + + + diff --git a/Assets/Plugins/Entitas/Entitas.xml.meta b/Assets/Plugins/Entitas/Entitas.xml.meta new file mode 100644 index 0000000..5c8a4d4 --- /dev/null +++ b/Assets/Plugins/Entitas/Entitas.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8e672f63cd68c5c449c21e1c3c4158e4 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/EntitasUpgradeGuide.md b/Assets/Plugins/Entitas/EntitasUpgradeGuide.md new file mode 100644 index 0000000..8919b18 --- /dev/null +++ b/Assets/Plugins/Entitas/EntitasUpgradeGuide.md @@ -0,0 +1,653 @@ +Entitas Upgrade Guide +===================== + +Entitas provides automated migration tools to help upgrading to new versions. +You can apply automatic migrations in Unity by opening the Entitas Migration Window +`Tools > Entitas > Migrate...` + +This document contains checklists for every release with breaking changes. + +Entitas 0.47.2 upgrade guide +============================ + +#### Breaking changes + +Apply Migration 0.47.2 to automatically rename the changed keys your properties files. + +The following keys changed from: + +- CodeGenerator.SearchPaths +- CodeGenerator.Plugins +- CodeGenerator.PreProcessors +- CodeGenerator.DataProviders +- CodeGenerator.CodeGenerators +- CodeGenerator.PostProcessors +- CodeGenerator.CLI.Ignore.UnusedKeys or Ignore.Keys + +to: + +- Jenny.SearchPaths +- Jenny.Plugins +- Jenny.PreProcessors +- Jenny.DataProviders +- Jenny.CodeGenerators +- Jenny.PostProcessors +- Jenny.Ignore.Keys + +--- + +Entitas 0.46.0 upgrade guide +============================ + +#### Breaking changes + +Removed methods marked obsolete in 0.42.0 from April 2017 +- `context.CreateCollector(IMatcher matcher, GroupEvent groupEvent)` +- `new Context(int totalComponents, int startCreationIndex, ContextInfo contextInfo)` +- `context.DestroyEntity(TEnity entity)` + +#### After you installed + +First, edit the file `Generated/Feature.cs` and comment or delete the lines with compiler errors. + +Then, run auto-import to use the new DesperateDevs.CodeGeneration.Plugins and generate. + +Entitas.properties can be named differently now. By default it will be called +Preferences.properties. Additionally, you can delete User.properties or rename it +to Xyz.userproperties. If this file doesn't exist, it will automatically be generated for you. +You can have multiple properties and userproperties files now, e.g. +Preferences.properties and Roslyn.properties. In Unity it will automatically find and use +the first file. When using the Code Generator CLI (called Jenny now) you can explicitly +specify files like this + +``` +// will find and use the first file +$ jenny gen + +// specify a file +$ jenny gen Roslyn.properties + +// optionally specify an other userproperties +jenny gen Roslyn.properties My.userproperties +``` + +--- + +Entitas 0.45.0 upgrade guide +============================ + +#### Breaking changes + +Use the command line tool `MigrationAssistant.exe` and apply Migration 0.45.0 to +automatically rename the changed keys in Entitas.properties + +`MigrationAssistant.exe 0.45.0 path/to/project` + +The following keys in Entitas.properties changed from: + +- Entitas.CodeGeneration.CodeGenerator.SearchPaths +- Entitas.CodeGeneration.CodeGenerator.Plugins +- Entitas.CodeGeneration.CodeGenerator.DataProviders +- Entitas.CodeGeneration.CodeGenerator.CodeGenerators +- Entitas.CodeGeneration.CodeGenerator.PostProcessors +- Entitas.CodeGeneration.CodeGenerator.CLI.Ignore.UnusedKeys + +to: + +- CodeGenerator.SearchPaths +- CodeGenerator.Plugins +- CodeGenerator.DataProviders +- CodeGenerator.CodeGenerators +- CodeGenerator.PostProcessors +- CodeGenerator.CLI.Ignore.UnusedKeys + +The default plugins are now in folder called `Entitas` instead of `Default`. Please update +the searchPaths in Entitas.properties. +`Entitas.exe` is now uppercase with capital E + +--- + +Entitas 0.42.0 upgrade guide +============================ + +#### Breaking changes +- Removed Entitas.Blueprints.Unity.* +- Changed ReactiveSystem.GetTrigger method signature +- Marked obsolete: `context.DestroyEntity(entity)`. Use `entity.Destroy()` instead +- Marked obsolete: `context.CreateCollector(matcher, event)`, use new `context.CreateCollector(triggerOnEvent)` when you need `.Removed` or `.AddedOrRemoved` (e.g. `GameMatcher.View.Removed()`) + +#### After you installed +- Removed Entitas.Blueprints.Unity.* + - Remove all Entitas.Blueprints.Unity.* related code + - Remove BinaryBlueprints from your project. Consider using extension methods as described here instead https://github.com/sschmid/Entitas-CSharp/issues/390 + - Remove from Entitas.properties: + - Entitas.Blueprints.CodeGeneration.Plugins + - Entitas.Blueprints.CodeGeneration.Plugins.BlueprintDataProvider + - Entitas.Blueprints.CodeGeneration.Plugins.BlueprintsGenerator + +- Changed ReactiveSystem.GetTrigger() method signature + - find and replace `protected override Collector` -> `protected override ICollector` + +- Generate + +- Marked obsolete: `context.DestroyEntity(entity)`. Use `entity.Destroy()` instead +- Marked obsolete: `context.CreateCollector(matcher, event)`, use new `context.CreateCollector(triggerOnEvent)` when you need `.Removed` or `.AddedOrRemoved` (e.g. `GameMatcher.View.Removed()`) + +--- + +Entitas 0.41.0 upgrade guide +============================ + +#### Breaking changes +In order to deploy Entitas as Dlls which enables 3rd party Addons and the extendable command line code generator the projects have been restructured. This restructuring has an impact on namespaces. + +#### Before you install +- You're fine - nothing to do for you :heart: + +#### After you installed +- Apply Migrations 0.41.0-1 +- Apply Migrations 0.41.0-2 +- Apply Migrations 0.41.0-3 + +These migrations should update most of the namespaces. Depending on which features of Entitas you have used there might be a chance that not all namespaces have been updated. In this case please fix the remaining namespaces manually. + +Entitas.properties keys have been updated to support the latest code generator. Please open Entitas.properties in your project root and make sure the keys are updated. Here's an example from Match One + +``` +Entitas.CodeGeneration.Project = Assembly-CSharp.csproj +Entitas.CodeGeneration.SearchPaths = Assets/Libraries/Entitas, Assets/Libraries/Entitas/Editor, /Applications/Unity/Unity.app/Contents/Managed +Entitas.CodeGeneration.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll +Entitas.CodeGeneration.Plugins = Entitas.CodeGeneration.Plugins, Entitas.CodeGeneration.Unity.Editor, Entitas.VisualDebugging.CodeGeneration.Plugins, Entitas.Blueprints.CodeGeneration.Plugins +Entitas.CodeGeneration.DataProviders = Entitas.Blueprints.CodeGeneration.Plugins.BlueprintDataProvider, Entitas.CodeGeneration.Plugins.ComponentDataProvider, Entitas.CodeGeneration.Plugins.ContextDataProvider, Entitas.CodeGeneration.Plugins.EntityIndexDataProvider +Entitas.CodeGeneration.CodeGenerators = Entitas.Blueprints.CodeGeneration.Plugins.BlueprintsGenerator, Entitas.CodeGeneration.Plugins.ComponentContextGenerator, Entitas.CodeGeneration.Plugins.ComponentEntityGenerator, Entitas.CodeGeneration.Plugins.ComponentGenerator, Entitas.CodeGeneration.Plugins.ComponentsLookupGenerator, Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, Entitas.CodeGeneration.Plugins.ContextGenerator, Entitas.CodeGeneration.Plugins.ContextsGenerator, Entitas.CodeGeneration.Plugins.EntityGenerator, Entitas.CodeGeneration.Plugins.EntityIndexGenerator, Entitas.CodeGeneration.Plugins.MatcherGenerator, Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator +Entitas.CodeGeneration.PostProcessors = Entitas.CodeGeneration.Plugins.AddFileHeaderPostProcessor, Entitas.CodeGeneration.Plugins.CleanTargetDirectoryPostProcessor, Entitas.CodeGeneration.Plugins.MergeFilesPostProcessor, Entitas.CodeGeneration.Plugins.NewLinePostProcessor, Entitas.CodeGeneration.Plugins.WriteToDiskPostProcessor, Entitas.CodeGeneration.Plugins.ConsoleWriteLinePostProcessor, Entitas.CodeGeneration.Unity.Editor.DebugLogPostProcessor +Entitas.CodeGeneration.TargetDirectory = Assets/Sources/ +Entitas.CodeGeneration.Contexts = Game, GameState, Input +Entitas.VisualDebugging.Unity.SystemWarningThreshold = 8 +Entitas.VisualDebugging.Unity.DefaultInstanceCreatorFolderPath = Assets/Editor/DefaultInstanceCreator/ +Entitas.VisualDebugging.Unity.TypeDrawerFolderPath = Assets/Editor/TypeDrawer/ +``` + +Explanation: +- Entitas.CodeGeneration.Project: Relative path to your project.csproj (when using Unity use `Assembly-CSharp.csproj`) +- Entitas.CodeGeneration.SearchPaths: The new code generator can be extended with 3rd party plugins. Specify all folders where plugin dlls can be found. Plugins may depend on UnityEngine or UnityEditor, if so please specify where those dlls can be found (Unity default on Mac: `/Applications/Unity/Unity.app/Contents/Managed` +- Entitas.CodeGeneration.Assemblies: One or more Dlls that contain your components +- Entitas.CodeGeneration.Plugins: One or more Code Generator Plugin Dlls or namespaces + +If all set up correctly DataProviders, CodeGenerators and PostProcessors can be set in Unity. + +The command line code generator currently doesn't support the following plugins: +- Entitas.Blueprints.CodeGeneration.Plugins (contains Blueprint DataProvider and CodeGenerator) +- Entitas.CodeGeneration.Unity.Editor (contains DebugLogPostProcessor) + +because they use Unity specific api. They will work as expected when generating from within Unity but don't work on the command line. + +To test the config for potential problems, please unzip Entitas-CodeGenerator.zip in the root folder of your project. + +--- + +### Note for Windows users +- Right-click Entitas-CodeGenerator.zip, open properties +- Check "Unblock" +- Hit Apply +- unzip + +--- + +``` +// skip mono on Windows +$ mono ./CodeGenerator/entitas.exe +Entitas Code Generator version 0.41.0 +usage: entitas new [-f] - Creates new Entitas.properties config with default values + entitas edit - Opens Entitas.properties config + entitas doctor - Checks the config for potential problems + entitas status - Lists available and unavailable plugins + entitas fix - Adds missing or removes unused keys interactively + entitas scan - Scans and prints available types found in specified assemblies + entitas dry - Simulates generating files without writing to disk + entitas gen - Generates files based on Entitas.properties + [-v] - verbose output + [-s] - silent output (errors only) +``` + +To check the config for potential problems please run +``` +$ mono ./CodeGenerator/entitas.exe doctor +``` + +The `doctor` command will show you the status and potential problems. Sometime you might get a warning like this: + +``` +- Could not resolve xyz.dll +``` + +This is just a warning. If no error is shown after running the `doctor` command, you can ignore those. All code generator plugins must be resolvable in order to be used. Use the `status` command to see available and unavailable plugins. This command helps you manage the plugins. Add or remove DataProviders, CodeGenerators or PostProcessors and check with `status` until you're happy. As usual, you can also use the Entitas Preferences Window in Unity to set up everything. + +If there are nor problems use the `gen` command to generate or use the green generate button in Unity as usual. + +--- + +Entitas 0.37.0 upgrade guide +============================ + +#### Breaking changes +Entitas went type-safe! This was a huge task and I'm happy to finally share this with you guys! +This feature makes Entitas safer and more managable in growing code bases and will eliminate certain kind of bugs. +This change breaks existing projects! It is possible to manually migrate existing projects but there is no special workflow +other than manually use find / replace to fix all compile errors. I use Entitas 0.37.0 in my current project (500+ systems) +and was able to migrate within less than two days. If you have less systems and components you should be able to migrate within one day. + +Reminder: If you're updating from versions < 0.36.0 you should update to 0.36.0 first. Be aware that existing Blueprints(Beta) are breaking +because of the renaming from `Pool` to `Context`. Existing Binary Blueprints have to be manually updated. + +If you're not sure if you should update you can wait another week. I plan to make a video to show how to upgrade existing projects. +After this you should be able to decide if you want to update or not. + +#### Before you install +- Rename `SingleEntityAttribute` to `UniqueAttribute` +- Change namespace of all attributes in CodeGenerator/Attributes to `Entitas.CodeGenerator.Api` +- Find / replace `using Entitas.CodeGenerator` to `using Entitas.CodeGenerator.Api` in all generated context attributes +- Find / replace `using Entitas.CodeGenerator;` to `using Entitas.CodeGenerator.Api;` in all generated components + +#### After you installed + +After installing Entitas 0.37.0 you most likely end up having lots of compiler errors. The 2 biggest issues are: +- Generated components +- Systems + +There migh also be other issues depending how you used Entitas before, but fixing the generated components and the systems +might already do most of the work. + +##### Problem 1 (Components): +The old generated components extend Entitas.Entity by using `partial class`. +The new version inherits Entitas.Entity to have a new entity type and to get rid of `partial class` to enable +having Entitas as a precompiled dll. + +##### Solution 1 (Components) +The goal is to update the generated components. I see 3 possible workflows to fix them: +1. Delete all components and generated components and use the EntitasLang DSL https://github.com/mzaks/ECS-Lang +2. Temporarily move all the logic (systems) out of your Unity project and delete the generated components. +After this there shouldn't be any compile errors anymore (if so, temporarily move them out if your Unity project). +Now you should be able to re-generate. After that, move all the files back to your Unity project. +3. Manually use find / replace in the generated components folder to migrate the components + +##### Problem 2 (Systems) +All reactive systems need to be updated to be type-safe. + +##### Solution 2 (Systems) +Manually use find / replace to migrate e.g. method signatures and other issues +Take a look at [Match-One AnimatePositionSystem.cs](https://github.com/sschmid/Match-One/blob/develop/Assets/Sources/Logic/View/Systems/AnimatePositionSystem.cs) +to see how the new reactive systems look like. + +##### Other issues +There might be other issues related to the type-safety. Rule of thumb: +- Every occurrences of `Entity` must be typed now, e.g. `GameEntity` +- Every occurrences of `Group` must be typed now, e.g. `IGroup` +- Every occurrences of `Context` must be typed now, e.g. `IContext` or `GameContext` if possible +- Every occurrences of `Collector` must be typed now, e.g. `Collector` +- Every occurrences of `Matcher` must be typed now, e.g. `Matcher.AllOf(...)` + +I recommend using find / replace on ceratin folders to fix those issues efficiently. + +--- + +Entitas 0.36.0 upgrade guide +============================ + +#### Breaking changes +The term `Pool` has been replaced with `Context`. This affects all classes that +contain the word pool. +`EntityCollector` has been renamed to `Collector` +`GroupEventType` has been renamed to `GroupEvent` + + +#### Before you install +- Rename `Pools.CreatePool()` to `Pools.CreateContext` +- Rename `Pool` to `Context` +- Rename `Pools` to `Contexts` +- Rename `Pools.SetAllPools()` to `Pools.SetAllContexts()` +- Rename `PoolAttribute` to `ContextAttribute` +- Rename `EntityCollector` to `Collector` +- Rename `GroupEventType` to `GroupEvent` +- Rename `GroupEventType.OnEntityAdded` to `GroupEvent.Added` +- Rename `GroupEventType.OnEntityRemoved` to `GroupEvent.Removed` +- Rename `GroupEventType.OnEntityAddedOrRemoved` to `GroupEvent.AddedOrRemoved` + +#### After you installed +- Use the command line tool `MigrationAssistant.exe` and apply Migration 0.36.0-2 +- Manually migrate all systems and fix compiler errors +- apply Migration 0.36.0-1 +- Ensure all code generator are selected and generate + +--- + +Entitas 0.35.0 upgrade guide +============================ + +#### Breaking changes +`IMatcher.Where()` has been removed. See #194 + +#### Before you install +- You're fine - nothing to do for you :heart: + +#### After you installed +- Fix all the errors where you used `matcher.Where()` + +--- + +Entitas 0.34.0 upgrade guide +============================ + +#### Breaking changes +`GroupObserver` has been renamed to `EntityCollector`. See #168 + +#### Before you install +- Rename `GroupObserver` to `EntityCollector` +- Rename `.CreateGroupObserver()` to `.CreateEntityCollector()` +- Rename `IGroupObserverSystem` to `IEntityCollectorSystem` +- Find & Replace `public EntityCollector groupObserver` with `public EntityCollector entityCollector` + +#### After you installed +- You're fine - nothing to do for you :heart: + +--- + +Entitas 0.33.0 upgrade guide +============================ + +#### Breaking changes +`IDeinitializeSystem` has been renamed to `ITearDownSystem`. See #164 + +#### Before you install +- Manually rename `IDeinitializeSystem` to `ITearDownSystem` + +#### After you installed +- You're fine - nothing to do for you :heart: + +--- + +Entitas 0.32.0 upgrade guide +============================ + +Use the command line tool `MigrationAssistant.exe` to automatically fix compile errors. +Entitas 0.32.0 introduces a new Pools class. Using the new PoolsGenerator will require +to update your existing project manually. You can still use the old Pools class in your +existing project if you want. If so, please use the OldPoolsGenerator instead of the new one. + +--- + +Entitas 0.30.0 upgrade guide +============================ + +Some code generators got renamed. Apply Migration 0.30.0 + +--- + +Entitas 0.29.0 upgrade guide +============================ + +Marked old PoolMetaData constructor obsolete. If you encounter compile errors +please apply Migration 0.26.0, open C# project and generate again. + +--- + +Entitas 0.28.0 upgrade guide +============================ + +If you're using Entitas with Unity, please open the Entitas preferences and make +sure that all your desired code generators are activated. +Due to some code generator renamings the ComponentIndicesGenerators inactive. + +The SystemsGenerator has been removed. Please use `pool.CreateSystem()` instead. + +--- + +Entitas 0.27.0 upgrade guide +============================ + +If you're using Entitas with Unity, please open the Entitas preferences and make +sure that all your desired code generators are activated. +Due to some code generator renamings the ComponentLookupGenerator and +the ComponentsGenerator are inactive. Activate them (if desired) and generate. + +--- + +Entitas 0.26.0 upgrade guide +============================ + +Use the command line tool `MigrationAssistant.exe` to automatically fix compile errors. +After that generate again. + +--- + +Entitas 0.24.0 upgrade guide +============================ + +To fix the compile errors after updating to Entitas 0.24.0, delete in `Pools.cs` + +```csharp +#if (UNITY_EDITOR) +var poolObserver = new Entitas.Unity.VisualDebugging.PoolObserver(_pool, ComponentIds.componentNames, ComponentIds.componentTypes, "Pool"); +UnityEngine.Object.DontDestroyOnLoad(poolObserver.entitiesContainer); +#endif +``` + +and generate again. + +--- + +Entitas 0.23.0 upgrade guide +============================ + +Entitas 0.23.0 changed and applied naming conventions. +Before updating to this version, follow these steps to prepare your project: + +#### Rename + + Pool.Count -> Pool.count + Group.Count -> Group.count + Properties.count -> Properties.count + +#### Find/Replace in generated folder + + ": AllOfMatcher " -> "" + ": base(new [] { index }) " -> "" + "static AllOfMatcher _matcher" -> "static IMatcher _matcher" + "public static AllOfMatcher" -> "public static IMatcher" + "new Matcher" -> "Matcher.AllOf" + +#### Delete + +In generated ...ComponentIds + + namespace Entitas { + public partial class XYZMatcher { + public Matcher(int index) { + } + + public override string ToString() { + return ComponentIds.IdToString(indices[0]); + } + } + } + +--- + +Entitas 0.22.0 upgrade guide +============================ + +Entitas 0.22.0 changed IReactiveSystem and IMultiReactiveSystem and renamed IStartSystem.Start to IInitializeSystem.Initialize. + +Use the command line tool `MigrationAssistant.exe` to automatically migrate IReactiveSystem. + +--- + +Entitas 0.19.0 upgrade guide +============================ + +Entitas 0.19.0 introduces a few breaking changes: + +Added new e.OnComponentReplaced and removed all *WillBeRemoved events. + +If you used `group.OnEntityWillBeRemoved`, you could replace it either with +```cs +_group.OnEntityRemoved += (group, entity, index, component) => { //... }; +``` +or with +```cs +_group.OnEntityUpdated += (group, entity, index, previousComponent, newComponent) => { // ...}; +``` +If your generated component extensions are not compiling, find/replace `WillRemoveComponent` with `//WillRemoveComponent` +to temporarily ignore the errors. + +IReactiveSystem.Execute takes List instead of Entity[]. Use the command line tool `MigrationAssistant.exe` to automatically migrate. + +``` +$ mono MigrationAssistant.exe +usage: +[-l] - print all available versions +[version] [path] - apply migration of version [version] to source files located at [path] + +$ mono MigrationAssistant.exe -l +0.18.0 - Migrates IReactiveSystem API +0.19.0 - Migrates IReactiveSystem.Execute + +// Example from Math-One example project, where all the systems are located in the Features folder +$ mono MigrationAssistant.exe 0.19.0 /Path/To/Project/Assets/Sources/Features +``` + +--- + +Entitas 0.18.0 upgrade guide +============================ + +Entitas 0.18.0 changes IReactiveSystem. To upgrade your source files, follow these steps +- Install Entitas 0.18.0 (which will result in compiler errors) +- Use the command line tool `MigrationAssistant.exe` to automatically migrate + +``` +$ mono MigrationAssistant.exe +usage: +[-l] - print all available versions +[version] [path] - apply migration of version [version] to source files located at [path] + +$ mono MigrationAssistant.exe -l +0.18.0 - Migrates IReactiveSystem API + +// Example from Math-One example project, where all the systems are located in the Features folder +$ mono MigrationAssistant.exe 0.18.0 /Path/To/Project/Assets/Sources/Features +``` + +--- + +Entitas 0.12.0 upgrade guide +============================ + +Entitas 0.12.0 generates prefixed matchers based on the PoolAttribute and introduces some +API changes. In your existing project with a Entitas version < 0.12.0 manually rename the +following classes and methods. + +## Before installing Entitas 0.12.0 + +#### Rename + + pool.CreateSystem() -> pool.CreateExecuteSystem() + +Now that you're prepared for integrating the latest version, delete your existing version +of Entitas, EntitasCodeGenerator and EntitasUnity. + +#### Delete + + Entitas + EntitasCodeGenerator + EntitasUnity + +## Install Entitas 0.12.0 + +#### Setup Entitas Preferences + + Open the Unity preference panel and select Entitas. Check and update the path to the folder where + the code generator will save all generated files. If you are using the PoolAttribute in your components, + add all custom pool names used in your application. Make sure that all existing custom PoolAttributes call + the base constructor with the same name as the class (without 'Attribute'). + If you are not using the PoolAttribute in your components, you can skip this process. + +```cs +using Entitas.CodeGenerator; + +public class CoreGameAttribute : PoolAttribute { + public CoreGameAttribute() : base("CoreGame") { + } +} +``` + +#### Code Generator + + Use the code generator and generate + +#### Update API + + Click the MenuItem "Entitas/Update API". All occurrences of the old Matcher will be updated + to the new version, which is prefixed based on the PoolAttribute. + +#### Delete + + Delete all custom PoolAttributes + +--- + +Entitas 0.10.0 upgrade guide +============================ + +Beside features, Entitas 0.10.0 includes lots of renaming. If your current Entitas +version is < 0.10.0, you might want to follow the next few simple renaming steps, +to speed up the integration of the latest version of Entitas. +In your existing project with a Entitas version < 0.10.0 manually rename the following +classes and methods. + +## Before installing Entitas 0.10.0 + +#### Rename + + EntityRepository -> Pool + EntityRepository.GetCollection() -> Pool.GetGroup() + + EntityCollection -> Group + EntityCollection.EntityCollectionChange -> Group.GroupChanged + + EntityRepositoryObserver -> GroupObserver + EntityRepositoryObserver.EntityCollectionEventType -> GroupObserver.GroupEventType + + IEntityMatcher -> IMatcher + IEntitySystem -> IExecuteSystem + AllOfEntityMatcher -> AllOfMatcher + EntityRepositoryAttribute -> PoolAttribute + IReactiveSubEntitySystem -> IReactiveSystem + ReactiveEntitySystem -> ReactiveSystem + +#### Delete + + EntityWillBeRemovedEntityRepositoryObserver -> DELETE + IReactiveSubEntityWillBeRemovedSystem -> DELETE + ReactiveEntityWillBeRemovedSystem -> DELETE + +Now that you're prepared for integrating the latest version, delete your existing version +of Entitas, EntitasCodeGenerator and ToolKit. + +#### Delete + + Entitas + EntitasCodeGenerator + ToolKit (unless you use classes from ToolKit. The new version of Entitas doesn't depend on ToolKit anymore) + + +## Install Entitas 0.10.0 + +#### Fix remaining issues + + IReactiveSubEntityWillBeRemovedSystem + - Consider implementing ISystem & ISetPool and use group.OnEntityWillBeRemoved += foobar; + +#### Code Generator + + Use the code generator and generate diff --git a/Assets/Plugins/Entitas/EntitasUpgradeGuide.md.meta b/Assets/Plugins/Entitas/EntitasUpgradeGuide.md.meta new file mode 100644 index 0000000..4936369 --- /dev/null +++ b/Assets/Plugins/Entitas/EntitasUpgradeGuide.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 215bbb6ffba38d64ea0e2821628dd20d +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/LICENSE.txt b/Assets/Plugins/Entitas/LICENSE.txt new file mode 100644 index 0000000..97175fb --- /dev/null +++ b/Assets/Plugins/Entitas/LICENSE.txt @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2014 - 2018 Simon Schmid + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Assets/Plugins/Entitas/LICENSE.txt.meta b/Assets/Plugins/Entitas/LICENSE.txt.meta new file mode 100644 index 0000000..bda16dd --- /dev/null +++ b/Assets/Plugins/Entitas/LICENSE.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4dbed025e0f8f3d40ac1843618048915 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Entitas/README.md b/Assets/Plugins/Entitas/README.md new file mode 100644 index 0000000..f61bad5 --- /dev/null +++ b/Assets/Plugins/Entitas/README.md @@ -0,0 +1,202 @@ +

+ Entitas +

+ +

+ + Join the chat at https://gitter.im/sschmid/Entitas-CSharp + + Twitter Follow Me + + Twitter Follow Me + + Build Status + + Latest release +

+ +

+ Entitas is free, but powered by + + your donations + +

+ +Entitas - The Entity Component System Framework for C# and Unity +================================================================ + +Entitas is a super fast Entity Component System Framework (ECS) specifically made for C# and Unity. Internal caching and blazing fast component access makes it second to none. Several design decisions have been made to work optimal in a garbage collected environment and to go easy on the garbage collector. Entitas comes with an optional code generator which radically reduces the amount of code you have to write and [makes your code read like well written prose.][clean-coders] + +

+ + CSharp + + Unity3d + + Unite Europe 2015 + + Unite Europe 2016 + + Wooga + + Gram Games.png +

+ +--- + +### **[» Download](#download-entitas)** +### **[» Documentation][documentation]** +### **[» Ask a question][issues-new]** +### **[» Wiki and example projects][wiki]** +### **[» #madeWithEntitas][wiki-games-and-examples]** + +--- + +Video Tutorials & Unity Unite Talks +================= + +| Entitas ECS Unity Tutorial | Entitas ECS Unity Tutorial | Entity system architecture with Unity | ECS architecture with Unity by example | +|:---------------------------------:|:---------------------------------:|:--------------------------------------------------------------------:|:--------------------------------------------------------------------:| +| [![Shmup1][shmup1-thumb]][shmup1] | [![Shmup2][shmup2-thumb]][shmup2] | [![Unite 15][unite15-thumb]][unite15] | [![Unite 16][unite16-thumb]][unite16] | +| Setup & Basics | Git & Unit Tests | [» Open the slides on SlideShare: Unite Europe 2015][unite15-slides] | [» Open the slides on SlideShare: Unite Europe 2016][unite16-slides] | + + +First glimpse +============= + +The optional [code generator][wiki-code-generator] lets you write code that is super fast, safe and literally screams its intent. + +```csharp +public static GameEntity CreateRedGem(this GameContext context, Vector3 position) { + var entity = context.CreateEntity(); + entity.isGameBoardElement = true; + entity.isMovable = true; + entity.AddPosition(position); + entity.AddAsset("RedGem"); + entity.isInteractive = true; + return entity; +} +``` + +```csharp +var entities = context.GetEntities(Matcher.AllOf(GameMatcher.Position, GameMatcher.Velocity)); +foreach(var e in entities) { + var pos = e.position; + var vel = e.velocity; + e.ReplacePosition(pos.value + vel.value); +} +``` + + +Overview +======== + +Entitas is fast, light and gets rid of unnecessary complexity. There are less than a handful classes you have to know to rocket start your game or application: + +- Entity +- Context +- Group +- Entity Collector + +[Read more...][wiki-overview] + + +Code Generator +============== + +The Code Generator generates classes and methods for you, so you can focus on getting the job done. It radically reduces the amount of code you have to write and improves readability by a huge magnitude. It makes your code less error-prone while ensuring best performance. I strongly recommend using it! + +[Read more...][wiki-code-generator] + + +Unity integration +================= + +The optional Unity module integrates Entitas nicely into Unity and provides powerful editor extensions to inspect and debug contexts, groups, entities, components and systems. + +[Read more...][wiki-unity-integration] + +

+ Entitas.Unity MenuItems
+ Entitas.Unity.VisualDebugging Entity + Entitas.Unity.VisualDebugging Systems +

+ + +Entitas deep dive +================= + +[Read the wiki][wiki] or checkout the [example projects][wiki-example-projects] to see Entitas in action. These example projects illustrate how systems, groups, collectors and entities all play together seamlessly. + + +Download Entitas +================ + +Each release is published with zip files containing all source files you need. + +[Show releases][releases] + + +Thanks to +========= + +Big shout out to [@mzaks][github-mzaks], [@cloudjubei][github-cloudjubei] and [@devboy][github-devboy] for endless hours of discussion and helping making Entitas awesome! + + +Maintainer(s) +============= + +- [@sschmid][github-sschmid] | [@s_schmid][twitter-sschmid] | [@entitas_csharp][twitter-entitas_csharp] + + +Different language? +=================== + +Entitas is available in +- [C#](https://github.com/sschmid/Entitas-CSharp) +- [Swift](https://github.com/mzaks/Entitas-Swift) +- [C++](https://github.com/JuDelCo/Entitas-Cpp) +- [Objective-C](https://github.com/wooga/entitas) +- [Java](https://github.com/Rubentxu/entitas-java) +- [Python](https://github.com/Aenyhm/entitas-python) +- [Scala](https://github.com/darkoverlordofdata/entitas-scala) +- [Go](https://github.com/wooga/go-entitas) +- [F#](https://github.com/darkoverlordofdata/entitas-fsharp) +- [TypeScript](https://github.com/darkoverlordofdata/entitas-ts) +- [Kotlin](https://github.com/darkoverlordofdata/entitas-kotlin) +- [Haskell](https://github.com/mhaemmerle/entitas-haskell) +- [Erlang](https://github.com/mhaemmerle/entitas_erl) +- [Clojure](https://github.com/mhaemmerle/entitas-clj) + + +[clean-coders]: https://cleancoders.com "Clean Coders" + +[documentation]: http://sschmid.github.io/Entitas-CSharp/ "Entitas Documentation" +[wiki]: https://github.com/sschmid/Entitas-CSharp/wiki "Entitas Wiki" +[wiki-code-generator]: https://github.com/sschmid/Entitas-CSharp/wiki/Code-Generator "Wiki - Code Generator" +[wiki-overview]: https://github.com/sschmid/Entitas-CSharp/wiki/Overview "Wiki - Overview" +[wiki-unity-integration]: https://github.com/sschmid/Entitas-CSharp/wiki/Unity-integration "Wiki - Unity Integration" +[wiki-example-projects]: https://github.com/sschmid/Entitas-CSharp/wiki/Example-projects "Wiki - Example Projects" +[wiki-games-and-examples]: https://github.com/sschmid/Entitas-CSharp/wiki/Made-With-Entitas "Wiki - #madeWithEntitas" + +[shmup1-thumb]: https://raw.githubusercontent.com/sschmid/Entitas-CSharp/master/Readme/Images/Entitas-Shmup-Part-1.jpg "Video: Entitas - Shmup - Part 1" +[shmup1]: https://www.youtube.com/watch?v=L-18XRTarOM "Video: Entitas - Shmup - Part 1" +[shmup2-thumb]: https://raw.githubusercontent.com/sschmid/Entitas-CSharp/master/Readme/Images/Entitas-Shmup-Part-2.jpg "Video: Entitas - Shmup - Part 2" +[shmup2]: https://www.youtube.com/watch?v=DZpvUnj2dGI "Video: Entitas - Shmup - Part 2" +[unite15-thumb]: https://raw.githubusercontent.com/sschmid/Entitas-CSharp/master/Readme/Images/UniteEurope2015-Video.png "Video: Watch the Entitas Talk at Unite Europe 2015" +[unite15]: https://www.youtube.com/watch?v=Re5kGtxTW6E "Video: Watch the Entitas Talk at Unite Europe 2015" +[unite15-slides]: http://www.slideshare.net/sschmid/uniteeurope-2015 "SlideShare: Unite Europe 2015" +[unite16-thumb]: https://raw.githubusercontent.com/sschmid/Entitas-CSharp/master/Readme/Images/UniteEurope2016-Video.png "Video: Watch the Entitas Talk at Unite Europe 2016" +[unite16]: https://www.youtube.com/watch?v=Phx7IJ3XUzg "Video: Watch the Entitas Talk at Unite Europe 2016" +[unite16-slides]: http://www.slideshare.net/sschmid/uniteeurope-2016 "SlideShare: Unite Europe 2016" + +[releases]: https://github.com/sschmid/Entitas-CSharp/releases "Releases" +[issues-new]: https://github.com/sschmid/Entitas-CSharp/issues/new "New issue" + +[twitter-sschmid]: https://twitter.com/s_schmid "s_schmid on Twitter" +[twitter-entitas_csharp]: https://twitter.com/entitas_csharp "entitas_csharp on Twitter" + +[github-sschmid]: https://github.com/sschmid "@sschmid" +[github-mzaks]: https://github.com/mzaks "@mzaks" +[github-cloudjubei]: https://github.com/cloudjubei "@cloudjubei" +[github-devboy]: https://github.com/devboy "@devboy" diff --git a/Assets/Plugins/Entitas/README.md.meta b/Assets/Plugins/Entitas/README.md.meta new file mode 100644 index 0000000..38940fa --- /dev/null +++ b/Assets/Plugins/Entitas/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 59e907356184a344d9e1402d1c2a33a1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Generators.dll b/Assets/Plugins/Generators.dll new file mode 100644 index 0000000..71c89de Binary files /dev/null and b/Assets/Plugins/Generators.dll differ diff --git a/Assets/Plugins/Generators.dll.meta b/Assets/Plugins/Generators.dll.meta new file mode 100644 index 0000000..c5b10b0 --- /dev/null +++ b/Assets/Plugins/Generators.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 7b096a7023b1a654fbde83161695f15d +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack.meta b/Assets/Plugins/NetStack.meta new file mode 100644 index 0000000..becd6e2 --- /dev/null +++ b/Assets/Plugins/NetStack.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6aecf72e86861334386d9c8b5673bd02 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Compression.meta b/Assets/Plugins/NetStack/NetStack.Compression.meta new file mode 100644 index 0000000..bbb005a --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e37f991919e66724ca83bbbe8dae2588 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs b/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs new file mode 100644 index 0000000..44d98bc --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2018 Stanislav Denisov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.CompilerServices; + +#if !(ENABLE_MONO || ENABLE_IL2CPP) + using System.Numerics; +#else + using UnityEngine; +#endif + +namespace NetStack.Compression { + public struct CompressedVector2 { + public uint x; + public uint y; + + public CompressedVector2(uint x, uint y) { + this.x = x; + this.y = y; + } + } + + public struct CompressedVector3 { + public uint x; + public uint y; + public uint z; + + public CompressedVector3(uint x, uint y, uint z) { + this.x = x; + this.y = y; + this.z = z; + } + } + + public struct CompressedVector4 { + public uint x; + public uint y; + public uint z; + public uint w; + + public CompressedVector4(uint x, uint y, uint z, uint w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + } + + public static class DeBruijn { + public static readonly int[] Lookup = new int[32] { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 + }; + } + + public class BoundedRange { + private readonly float minValue; + private readonly float maxValue; + private readonly float precision; + private readonly int requiredBits; + private readonly uint mask; + + public BoundedRange(float minValue, float maxValue, float precision) { + this.minValue = minValue; + this.maxValue = maxValue; + this.precision = precision; + + requiredBits = Log2((uint)((maxValue - minValue) * (1.0f / precision) + 0.5f)) + 1; + mask = (uint)((1L << requiredBits) - 1); + } + + private int Log2(uint value) { + value |= value >> 1; + value |= value >> 2; + value |= value >> 4; + value |= value >> 8; + value |= value >> 16; + + return DeBruijn.Lookup[(value * 0x07C4ACDDU) >> 27]; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public uint Compress(float value) { + if (value < minValue) + value = minValue; + else if (value > maxValue) + value = maxValue; + + return (uint)((float)((value - minValue) * (1f / precision)) + 0.5f) & mask; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public float Decompress(uint data) { + float adjusted = ((float)data * precision) + minValue; + + if (adjusted < minValue) + adjusted = minValue; + else if (adjusted > maxValue) + adjusted = maxValue; + + return adjusted; + } + + public static CompressedVector2 Compress(Vector2 vector2, BoundedRange[] boundedRange) { + CompressedVector2 data = default(CompressedVector2); + + #if ENABLE_MONO || ENABLE_IL2CPP + data.x = boundedRange[0].Compress(vector2.x); + data.y = boundedRange[1].Compress(vector2.y); + #else + data.x = boundedRange[0].Compress(vector2.X); + data.y = boundedRange[1].Compress(vector2.Y); + #endif + + return data; + } + + public static CompressedVector3 Compress(Vector3 vector3, BoundedRange[] boundedRange) { + CompressedVector3 data = default(CompressedVector3); + + #if ENABLE_MONO || ENABLE_IL2CPP + data.x = boundedRange[0].Compress(vector3.x); + data.y = boundedRange[1].Compress(vector3.y); + data.z = boundedRange[2].Compress(vector3.z); + #else + data.x = boundedRange[0].Compress(vector3.X); + data.y = boundedRange[1].Compress(vector3.Y); + data.z = boundedRange[2].Compress(vector3.Z); + #endif + + return data; + } + + public static CompressedVector4 Compress(Vector4 vector4, BoundedRange[] boundedRange) { + CompressedVector4 data = default(CompressedVector4); + + #if ENABLE_MONO || ENABLE_IL2CPP + data.x = boundedRange[0].Compress(vector4.x); + data.y = boundedRange[1].Compress(vector4.y); + data.z = boundedRange[2].Compress(vector4.z); + data.w = boundedRange[3].Compress(vector4.w); + #else + data.x = boundedRange[0].Compress(vector4.X); + data.y = boundedRange[1].Compress(vector4.Y); + data.z = boundedRange[2].Compress(vector4.Z); + data.w = boundedRange[3].Compress(vector4.W); + #endif + + return data; + } + + public static Vector2 Decompress(CompressedVector2 data, BoundedRange[] boundedRange) { + return new Vector2(boundedRange[0].Decompress(data.x), boundedRange[1].Decompress(data.y)); + } + + public static Vector3 Decompress(CompressedVector3 data, BoundedRange[] boundedRange) { + return new Vector3(boundedRange[0].Decompress(data.x), boundedRange[1].Decompress(data.y), boundedRange[2].Decompress(data.z)); + } + + public static Vector4 Decompress(CompressedVector4 data, BoundedRange[] boundedRange) { + return new Vector4(boundedRange[0].Decompress(data.x), boundedRange[1].Decompress(data.y), boundedRange[2].Decompress(data.z), boundedRange[3].Decompress(data.w)); + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs.meta b/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs.meta new file mode 100644 index 0000000..1e5a170 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/BoundedRange.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d395432689331dd4f883b3afe69c6e2b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs b/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs new file mode 100644 index 0000000..8344d60 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2018 Stanislav Denisov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace NetStack.Compression { + public static class HalfPrecision { + [StructLayout(LayoutKind.Explicit)] + private struct Values { + [FieldOffset(0)] + public float f; + [FieldOffset(0)] + public int i; + [FieldOffset(0)] + public uint u; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public static ushort Compress(float value) { + var values = new Values { + f = value + }; + + return Compress(values.i); + } + + public static ushort Compress(int value) { + int s = (value >> 16) & 0x00008000; + int e = ((value >> 23) & 0X000000FF) - (127 - 15); + int m = value & 0X007FFFFF; + + if (e <= 0) { + if (e < -10) + return (ushort)s; + + m = m | 0x00800000; + + int t = 14 - e; + int a = (1 << (t - 1)) - 1; + int b = (m >> t) & 1; + + m = (m + a + b) >> t; + + return (ushort)(s | m); + } + + if (e == 0XFF - (127 - 15)) { + if (m == 0) + return (ushort)(s | 0X7C00); + + m >>= 13; + + return (ushort)(s | 0X7C00 | m | ((m == 0) ? 1 : 0)); + } + + m = m + 0X00000FFF + ((m >> 13) & 1); + + if ((m & 0x00800000) != 0) { + m = 0; + e++; + } + + if (e > 30) + return (ushort)(s | 0X7C00); + + return (ushort)(s | (e << 10) | (m >> 13)); + } + + public static float Decompress(ushort value) { + uint result; + uint mantissa = (uint)(value & 1023); + uint exponent = 0XFFFFFFF2; + + if ((value & -33792) == 0) { + if (mantissa != 0) { + while ((mantissa & 1024) == 0) { + exponent--; + mantissa = mantissa << 1; + } + + mantissa &= 0XFFFFFBFF; + result = ((uint)((((uint)value & 0x8000) << 16) | ((exponent + 127) << 23))) | (mantissa << 13); + } else { + result = (uint)((value & 0x8000) << 16); + } + } else { + result = ((((uint)value & 0x8000) << 16) | ((((((uint)value >> 10) & 0X1F) - 15) + 127) << 23)) | (mantissa << 13); + } + + var values = new Values { + u = result + }; + + return values.f; + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs.meta b/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs.meta new file mode 100644 index 0000000..4a4d825 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/HalfPrecision.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2b93a7b07069f334e9a659a3443fde6b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs b/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs new file mode 100644 index 0000000..84d9cb5 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2018 Stanislav Denisov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; + +#if !(ENABLE_MONO || ENABLE_IL2CPP) + using System.Numerics; +#else + using UnityEngine; +#endif + +namespace NetStack.Compression { + public struct CompressedQuaternion { + public byte m; + public short a; + public short b; + public short c; + + public CompressedQuaternion(byte m, short a, short b, short c) { + this.m = m; + this.a = a; + this.b = b; + this.c = c; + } + } + + public static class SmallestThree { + private const float floatPrecision = 10000f; + + public static CompressedQuaternion Compress(Quaternion quaternion) { + CompressedQuaternion data = default(CompressedQuaternion); + byte m = 0; + float maxValue = float.MinValue; + float sign = 1f; + + for (int i = 0; i <= 3; i++) { + float element = 0f; + float abs = 0f; + + switch (i) { + #if ENABLE_MONO || ENABLE_IL2CPP + case 0: + element = quaternion.x; + + break; + + case 1: + element = quaternion.y; + + break; + + case 2: + element = quaternion.z; + + break; + + case 3: + element = quaternion.w; + + break; + #else + case 0: + element = quaternion.X; + + break; + + case 1: + element = quaternion.Y; + + break; + + case 2: + element = quaternion.Z; + + break; + + case 3: + element = quaternion.W; + + break; + #endif + } + + abs = Math.Abs(element); + + if (abs > maxValue) { + sign = (element < 0) ? -1 : 1; + m = (byte)i; + maxValue = abs; + } + } + + if (Math.Abs(1f - maxValue) < Math.Max(0.000001f * Math.Max(Math.Abs(maxValue), Math.Abs(1f)), Single.Epsilon * 8)) { + data.m = (byte)(m + 4); + + return data; + } + + short a = 0; + short b = 0; + short c = 0; + + #if ENABLE_MONO || ENABLE_IL2CPP + if (m == 0) { + a = (short)(quaternion.y * sign * floatPrecision); + b = (short)(quaternion.z * sign * floatPrecision); + c = (short)(quaternion.w * sign * floatPrecision); + } else if (m == 1) { + a = (short)(quaternion.x * sign * floatPrecision); + b = (short)(quaternion.z * sign * floatPrecision); + c = (short)(quaternion.w * sign * floatPrecision); + } else if (m == 2) { + a = (short)(quaternion.x * sign * floatPrecision); + b = (short)(quaternion.y * sign * floatPrecision); + c = (short)(quaternion.w * sign * floatPrecision); + } else { + a = (short)(quaternion.x * sign * floatPrecision); + b = (short)(quaternion.y * sign * floatPrecision); + c = (short)(quaternion.z * sign * floatPrecision); + } + #else + if (m == 0) { + a = (short)(quaternion.Y * sign * floatPrecision); + b = (short)(quaternion.Z * sign * floatPrecision); + c = (short)(quaternion.W * sign * floatPrecision); + } else if (m == 1) { + a = (short)(quaternion.X * sign * floatPrecision); + b = (short)(quaternion.Z * sign * floatPrecision); + c = (short)(quaternion.W * sign * floatPrecision); + } else if (m == 2) { + a = (short)(quaternion.X * sign * floatPrecision); + b = (short)(quaternion.Y * sign * floatPrecision); + c = (short)(quaternion.W * sign * floatPrecision); + } else { + a = (short)(quaternion.X * sign * floatPrecision); + b = (short)(quaternion.Y * sign * floatPrecision); + c = (short)(quaternion.Z * sign * floatPrecision); + } + #endif + + data.m = m; + data.a = a; + data.b = b; + data.c = c; + + return data; + } + + public static Quaternion Decompress(CompressedQuaternion data) { + byte m = data.m; + + if (m >= 4 && m <= 7) { + float x = (m == 4) ? 1f : 0f; + float y = (m == 5) ? 1f : 0f; + float z = (m == 6) ? 1f : 0f; + float w = (m == 7) ? 1f : 0f; + + return new Quaternion(x, y, z, w); + } + + float a = (float)data.a / floatPrecision; + float b = (float)data.b / floatPrecision; + float c = (float)data.c / floatPrecision; + float d = (float)Math.Sqrt(1f - ((a * a) + (b * b) + (c * c))); + + if (m == 0) + return new Quaternion(d, a, b, c); + else if (m == 1) + return new Quaternion(a, d, b, c); + else if (m == 2) + return new Quaternion(a, b, d, c); + + return new Quaternion(a, b, c, d); + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs.meta b/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs.meta new file mode 100644 index 0000000..7a0a769 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Compression/SmallestThree.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aedeaaa9b9d42254a934cce0a3f5e8c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Serialization.meta b/Assets/Plugins/NetStack/NetStack.Serialization.meta new file mode 100644 index 0000000..bb2232c --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Serialization.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bd461e76132dc874385ba95301de58eb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs b/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs new file mode 100644 index 0000000..72a928a --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2018 Stanislav Denisov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Copyright (c) 2018 Alexander Shoulson + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +using System; +using System.Runtime.CompilerServices; +using System.Text; + +namespace NetStack.Serialization { + public class BitBuffer { + private const int defaultCapacity = 8; + private const int stringLengthMax = 512; + private const int stringLengthBits = 9; + private const int bitsASCII = 7; + private const int growFactor = 2; + private const int minGrow = 1; + private int readPosition; + private int nextPosition; + private uint[] chunks; + + public BitBuffer(int capacity = defaultCapacity) { + readPosition = 0; + nextPosition = 0; + chunks = new uint[capacity]; + } + + public int Length { + get { + return ((nextPosition - 1) >> 3) + 1; + } + } + + public bool IsFinished { + get { + return nextPosition == readPosition; + } + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public void Clear() { + readPosition = 0; + nextPosition = 0; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public void Add(int numBits, uint value) { + if (numBits < 0) + throw new ArgumentOutOfRangeException("Pushing negative bits"); + + if (numBits > 32) + throw new ArgumentOutOfRangeException("Pushing too many bits"); + + int index = nextPosition >> 5; + int used = nextPosition & 0x0000001F; + + if ((index + 1) >= chunks.Length) + ExpandArray(); + + ulong chunkMask = ((1UL << used) - 1); + ulong scratch = chunks[index] & chunkMask; + ulong result = scratch | ((ulong)value << used); + + chunks[index] = (uint)result; + chunks[index + 1] = (uint)(result >> 32); + nextPosition += numBits; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public uint Read(int numBits) { + uint result = Peek(numBits); + + readPosition += numBits; + + return result; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public uint Peek(int numBits) { + if (numBits < 0) + throw new ArgumentOutOfRangeException("Pushing negative bits"); + + if (numBits > 32) + throw new ArgumentOutOfRangeException("Pushing too many bits"); + + int index = readPosition >> 5; + int used = readPosition & 0x0000001F; + + ulong chunkMask = ((1UL << numBits) - 1) << used; + ulong scratch = (ulong)chunks[index]; + + if ((index + 1) < chunks.Length) + scratch |= (ulong)chunks[index + 1] << 32; + + ulong result = (scratch & chunkMask) >> used; + + return (uint)result; + } + + public int ToArray(byte[] data, int offset) { + Add(1, 1); + + int numChunks = (nextPosition >> 5) + 1; + int length = data.Length; + + for (int i = 0; i < numChunks; i++) { + int dataIdx = i * 4 + offset; + uint chunk = chunks[i]; + + if (dataIdx < length) + data[dataIdx] = (byte)(chunk); + + if (dataIdx + 1 < length) + data[dataIdx + 1] = (byte)(chunk >> 8); + + if (dataIdx + 2 < length) + data[dataIdx + 2] = (byte)(chunk >> 16); + + if (dataIdx + 3 < length) + data[dataIdx + 3] = (byte)(chunk >> 24); + } + + return Length; + } + + public void FromArray(byte[] data, int offset, int length) { + int numChunks = (length / 4) + 1; + + if (chunks.Length < numChunks) + chunks = new uint[numChunks]; + + for (int i = 0; i < numChunks; i++) { + int dataIdx = i * 4 + offset; + uint chunk = 0; + + if (dataIdx < length) + chunk = (uint)data[dataIdx]; + + if (dataIdx + 1 < length) + chunk = chunk | (uint)data[dataIdx + 1] << 8; + + if (dataIdx + 2 < length) + chunk = chunk | (uint)data[dataIdx + 2] << 16; + + if (dataIdx + 3 < length) + chunk = chunk | (uint)data[dataIdx + 3] << 24; + + chunks[i] = chunk; + } + + int positionInByte = FindHighestBitPosition(data[length - 1]); + + nextPosition = ((length - 1) * 8) + (positionInByte - 1); + readPosition = 0; + } + + #if NETSTACK_SPAN + public int ToSpan(ref Span data) { + Add(1, 1); + + int numChunks = (nextPosition >> 5) + 1; + int length = data.Length; + + for (int i = 0; i < numChunks; i++) { + int dataIdx = i * 4; + uint chunk = chunks[i]; + + if (dataIdx < length) + data[dataIdx] = (byte)(chunk); + + if (dataIdx + 1 < length) + data[dataIdx + 1] = (byte)(chunk >> 8); + + if (dataIdx + 2 < length) + data[dataIdx + 2] = (byte)(chunk >> 16); + + if (dataIdx + 3 < length) + data[dataIdx + 3] = (byte)(chunk >> 24); + } + + return Length; + } + + public void FromSpan(ref ReadOnlySpan data, int length) { + int numChunks = (length / 4) + 1; + + if (chunks.Length < numChunks) + chunks = new uint[numChunks]; + + for (int i = 0; i < numChunks; i++) { + int dataIdx = i * 4; + uint chunk = 0; + + if (dataIdx < length) + chunk = (uint)data[dataIdx]; + + if (dataIdx + 1 < length) + chunk = chunk | (uint)data[dataIdx + 1] << 8; + + if (dataIdx + 2 < length) + chunk = chunk | (uint)data[dataIdx + 2] << 16; + + if (dataIdx + 3 < length) + chunk = chunk | (uint)data[dataIdx + 3] << 24; + + chunks[i] = chunk; + } + + int positionInByte = FindHighestBitPosition(data[length - 1]); + + nextPosition = ((length - 1) * 8) + (positionInByte - 1); + readPosition = 0; + } + #endif + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddBool(bool value) { + Add(1, value ? 1U : 0U); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public bool ReadBool() { + return Read(1) > 0; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public bool PeekBool() { + return Peek(1) > 0; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddByte(byte value) { + Add(8, value); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public byte ReadByte() { + return (byte)Read(8); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public byte PeekByte() { + return (byte)Peek(8); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddShort(short value) { + AddInt(value); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public short ReadShort() { + return (short)ReadInt(); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public short PeekShort() { + return (short)PeekInt(); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddUShort(ushort value) { + AddUInt(value); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public ushort ReadUShort() { + return (ushort)ReadUInt(); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public ushort PeekUShort() { + return (ushort)PeekUInt(); + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddInt(int value) { + uint zigzag = (uint)((value << 1) ^ (value >> 31)); + + AddUInt(zigzag); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public int ReadInt() { + uint value = ReadUInt(); + int zagzig = (int)((value >> 1) ^ (-(int)(value & 1))); + + return zagzig; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public int PeekInt() { + uint value = PeekUInt(); + int zagzig = (int)((value >> 1) ^ (-(int)(value & 1))); + + return zagzig; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddUInt(uint value) { + uint buffer = 0x0u; + + do { + buffer = value & 0x7Fu; + value >>= 7; + + if (value > 0) + buffer |= 0x80u; + + Add(8, buffer); + } + + while (value > 0); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public uint ReadUInt() { + uint buffer = 0x0u; + uint value = 0x0u; + int shift = 0; + + do { + buffer = Read(8); + + value |= (buffer & 0x7Fu) << shift; + shift += 7; + } + + while ((buffer & 0x80u) > 0); + + return value; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public uint PeekUInt() { + int tempPosition = readPosition; + uint value = ReadUInt(); + + readPosition = tempPosition; + + return value; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddLong(long value) { + AddInt((int)(value & uint.MaxValue)); + AddInt((int)(value >> 32)); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public long ReadLong() { + int low = ReadInt(); + int high = ReadInt(); + long value = high; + + return value << 32 | (uint)low; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public long PeekLong() { + int tempPosition = readPosition; + long value = ReadLong(); + + readPosition = tempPosition; + + return value; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddULong(ulong value) { + AddUInt((uint)(value & uint.MaxValue)); + AddUInt((uint)(value >> 32)); + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public ulong ReadULong() { + uint low = ReadUInt(); + uint high = ReadUInt(); + + return (ulong)high << 32 | low; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public ulong PeekULong() { + int tempPosition = readPosition; + ulong value = ReadULong(); + + readPosition = tempPosition; + + return value; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public BitBuffer AddString(string value) { + if (value == null) + throw new ArgumentNullException("value"); + + uint length = (uint)value.Length; + + if (length > stringLengthMax) + length = (uint)stringLengthMax; + + Add(stringLengthBits, length); + + for (int i = 0; i < length; i++) { + Add(bitsASCII, ToASCII(value[i])); + } + + return this; + } + + #if NETSTACK_INLINING + [MethodImpl(256)] + #endif + public string ReadString() { + StringBuilder builder = new StringBuilder(); + uint length = Read(stringLengthBits); + + for (int i = 0; i < length; i++) { + builder.Append((char)Read(bitsASCII)); + } + + return builder.ToString(); + } + + public override string ToString() { + StringBuilder builder = new StringBuilder(); + + for (int i = chunks.Length - 1; i >= 0; i--) { + builder.Append(Convert.ToString(chunks[i], 2).PadLeft(32, '0')); + } + + StringBuilder spaced = new StringBuilder(); + + for (int i = 0; i < builder.Length; i++) { + spaced.Append(builder[i]); + + if (((i + 1) % 8) == 0) + spaced.Append(" "); + } + + return spaced.ToString(); + } + + private void ExpandArray() { + int newCapacity = (chunks.Length * growFactor) + minGrow; + uint[] newChunks = new uint[newCapacity]; + + Array.Copy(chunks, newChunks, chunks.Length); + chunks = newChunks; + } + + private static int FindHighestBitPosition(byte data) { + int shiftCount = 0; + + while (data > 0) { + data >>= 1; + shiftCount++; + } + + return shiftCount; + } + + private static byte ToASCII(char character) { + byte value = 0; + + try { + value = Convert.ToByte(character); + } + + catch (OverflowException) { + throw new Exception("Cannot convert to ASCII: " + character); + } + + if (value > 127) + throw new Exception("Cannot convert to ASCII: " + character); + + return value; + } + } +} diff --git a/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs.meta b/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs.meta new file mode 100644 index 0000000..6df7271 --- /dev/null +++ b/Assets/Plugins/NetStack/NetStack.Serialization/BitBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0820c909f73d7334f8f93857a07b357b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/SpanSupport.meta b/Assets/Plugins/SpanSupport.meta new file mode 100644 index 0000000..66b11a3 --- /dev/null +++ b/Assets/Plugins/SpanSupport.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ece87778abb51134587ac5b15c84aac3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/SpanSupport/System.Buffers.dll b/Assets/Plugins/SpanSupport/System.Buffers.dll new file mode 100644 index 0000000..c517a3b Binary files /dev/null and b/Assets/Plugins/SpanSupport/System.Buffers.dll differ diff --git a/Assets/Plugins/SpanSupport/System.Buffers.dll.meta b/Assets/Plugins/SpanSupport/System.Buffers.dll.meta new file mode 100644 index 0000000..27585bf --- /dev/null +++ b/Assets/Plugins/SpanSupport/System.Buffers.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: c8e1e0ada971a584dbb2038c2b5514be +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/SpanSupport/System.Memory.dll b/Assets/Plugins/SpanSupport/System.Memory.dll new file mode 100644 index 0000000..3ba645b Binary files /dev/null and b/Assets/Plugins/SpanSupport/System.Memory.dll differ diff --git a/Assets/Plugins/SpanSupport/System.Memory.dll.meta b/Assets/Plugins/SpanSupport/System.Memory.dll.meta new file mode 100644 index 0000000..140e6bf --- /dev/null +++ b/Assets/Plugins/SpanSupport/System.Memory.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 4bfaf94ce3054c64492e06128a28e5cf +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll b/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 0000000..3156239 Binary files /dev/null and b/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll.meta b/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll.meta new file mode 100644 index 0000000..d0c90b0 --- /dev/null +++ b/Assets/Plugins/SpanSupport/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 09a7d47f51b5cc84685c35938efe0d94 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes.meta b/Assets/Scenes.meta new file mode 100644 index 0000000..afe9d07 --- /dev/null +++ b/Assets/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 564f3be33d670384cb22785aa1931e73 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity new file mode 100644 index 0000000..5f2ecc7 --- /dev/null +++ b/Assets/Scenes/SampleScene.unity @@ -0,0 +1,387 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 705507994} + m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &705507993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 705507995} + - component: {fileID: 705507994} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &705507994 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &705507995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &963194225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 963194228} + - component: {fileID: 963194227} + - component: {fileID: 963194226} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &963194226 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 +--- !u!20 &963194227 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &963194228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -5.61, y: 2.86, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1016431233 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1016431235} + - component: {fileID: 1016431234} + m_Layer: 0 + m_Name: Logger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1016431234 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1016431233} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9ab84c5d2ea6467a8a733e98051580b1, type: 3} + m_Name: + m_EditorClassIdentifier: + DrawCount: 15 + Messages: [] +--- !u!4 &1016431235 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1016431233} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2079191269 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2079191271} + - component: {fileID: 2079191270} + m_Layer: 0 + m_Name: GameController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2079191270 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2079191269} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dbbbddda32854a78aa149317fbcf6c63, type: 3} + m_Name: + m_EditorClassIdentifier: + TargetTickPerSecond: 10 + PanicStateCount: 6 + PanicCleanupTarget: 3 +--- !u!4 &2079191271 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2079191269} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -8.186773, y: 4.664304, z: -5.166054} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/SampleScene.unity.meta b/Assets/Scenes/SampleScene.unity.meta new file mode 100644 index 0000000..952bd1e --- /dev/null +++ b/Assets/Scenes/SampleScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9fc0d4010bbf28b4594072e72b8655ab +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources.meta b/Assets/Sources.meta new file mode 100644 index 0000000..20d29d6 --- /dev/null +++ b/Assets/Sources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 647a2fff7110ed1459f0868cba0c4ea4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/ClientFeature.cs b/Assets/Sources/ClientFeature.cs new file mode 100644 index 0000000..697d3cd --- /dev/null +++ b/Assets/Sources/ClientFeature.cs @@ -0,0 +1,13 @@ +using Sources.Networking.Client; + +public class ClientFeature : Feature +{ + public ClientFeature(Contexts contexts, Services services) + { + Add(new CommonGameplayFeature(contexts, services)); + Add(new ClientGameplayFeature(contexts, services)); + + Add(new ClientNetworkFeature(contexts, services)); + Add(new CommonGeneratedFeature(contexts)); + } +} \ No newline at end of file diff --git a/Assets/Sources/ClientFeature.cs.meta b/Assets/Sources/ClientFeature.cs.meta new file mode 100644 index 0000000..0a3fa51 --- /dev/null +++ b/Assets/Sources/ClientFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e581e3880d1746f482aa388309b1a28c +timeCreated: 1557775317 \ No newline at end of file diff --git a/Assets/Sources/Codegen.meta b/Assets/Sources/Codegen.meta new file mode 100644 index 0000000..93bda53 --- /dev/null +++ b/Assets/Sources/Codegen.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 474e63f3db484004999f1db68f8192b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Codegen/CodegenAttributes.meta b/Assets/Sources/Codegen/CodegenAttributes.meta new file mode 100644 index 0000000..4904059 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95b2ade0f06483246af4becf2bb48ce2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds.meta b/Assets/Sources/Codegen/CodegenAttributes/Bounds.meta new file mode 100644 index 0000000..bb9db2b --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 13d612487ae74737b0066067951208cd +timeCreated: 1558178077 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs new file mode 100644 index 0000000..89aefc2 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs @@ -0,0 +1,19 @@ +using System; + +namespace Codegen.CodegenAttributes.Bounds +{ + [AttributeUsage(AttributeTargets.Field)] + public class BoundedFloatAttribute : Attribute + { + public BoundedFloatAttribute(float min, float max, float precision) + { + Min = min; + Max = max; + Precision = precision; + } + + public float Min { get; } + public float Max { get; } + public float Precision { get; } + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs.meta new file mode 100644 index 0000000..4988eed --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedFloatAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 37e9601c26c4449787af36e8b4917941 +timeCreated: 1558177946 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs new file mode 100644 index 0000000..7fa627e --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs @@ -0,0 +1,26 @@ +using System; + +namespace Codegen.CodegenAttributes.Bounds +{ + [AttributeUsage(AttributeTargets.Field)] + public class BoundedVector2Attribute : Attribute + { + public BoundedVector2Attribute(float xMin, float xMax, float xPrecision, float yMin, float yMax, + float yPrecision) + { + XMin = xMin; + XMax = xMax; + XPrecision = xPrecision; + YMin = yMin; + YMax = yMax; + YPrecision = yPrecision; + } + + public float XMin { get; } + public float XMax { get; } + public float XPrecision { get; } + public float YMin { get; } + public float YMax { get; } + public float YPrecision { get; } + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs.meta new file mode 100644 index 0000000..815d4ba --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector2Attribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a35cc5e5d1fc43d7a7139c4091540522 +timeCreated: 1558178099 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs new file mode 100644 index 0000000..9363208 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs @@ -0,0 +1,32 @@ +using System; + +namespace Codegen.CodegenAttributes.Bounds +{ + [AttributeUsage(AttributeTargets.Field)] + public class BoundedVector3Attribute : Attribute + { + public BoundedVector3Attribute(float xMin, float xMax, float xPrecision, float yMin, float yMax, + float yPrecision, float zMin, float zMax, float zPrecision) + { + XMin = xMin; + XMax = xMax; + XPrecision = xPrecision; + YMin = yMin; + YMax = yMax; + YPrecision = yPrecision; + ZMin = zMin; + ZMax = zMax; + ZPrecision = zPrecision; + } + + public float XMin { get; } + public float XMax { get; } + public float XPrecision { get; } + public float YMin { get; } + public float YMax { get; } + public float YPrecision { get; } + public float ZMin { get; } + public float ZMax { get; } + public float ZPrecision { get; } + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs.meta new file mode 100644 index 0000000..f324c00 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/Bounds/BoundedVector3Attribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5ceca79bc9a446b88f5f6b99607cac79 +timeCreated: 1558178226 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs b/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs new file mode 100644 index 0000000..b4d4442 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace Codegen.CodegenAttributes +{ + public class CommandToClientAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs.meta new file mode 100644 index 0000000..d42d113 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/CommandToClientAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01eb0db9e5ae4287af78ac1151c7626b +timeCreated: 1557597660 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs b/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs new file mode 100644 index 0000000..7b2b391 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace Codegen.CodegenAttributes +{ + public class CommandToServerAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs.meta new file mode 100644 index 0000000..7c89365 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/CommandToServerAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 763a971e32544f068a03a13537dd6593 +timeCreated: 1557594551 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs b/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs new file mode 100644 index 0000000..cf1110d --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace Codegen.CodegenAttributes +{ + public class SerializeAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs.meta new file mode 100644 index 0000000..ef0fe61 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/SerializeAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1760a04a9aba47dfb7e0e5679e2cac1d +timeCreated: 1557592225 \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs b/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs new file mode 100644 index 0000000..d135da3 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace Codegen.CodegenAttributes +{ + public class SyncAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs.meta b/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs.meta new file mode 100644 index 0000000..8272856 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenAttributes/SyncAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 710db9c21b538894094e13ec6c549128 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Codegen/CodegenExecutor.meta b/Assets/Sources/Codegen/CodegenExecutor.meta new file mode 100644 index 0000000..2dabc97 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenExecutor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3fc09f8ca15792b4ea300e27cf9f36c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs b/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs new file mode 100644 index 0000000..2d877e2 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs @@ -0,0 +1,682 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Codegen.CodegenAttributes; +using Codegen.CodegenAttributes.Bounds; +using Generators.Compressors; +using Generators.Scheme.Command; +using Generators.Scheme.Command.Executor; +using Generators.Scheme.Command.Executor.Interface; +using Generators.Sync.Component; +using Generators.Sync.Feature; +using Generators.Sync.Systems; +using Generators.Sync.Utility; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +public class CodegenExecutor : ScriptableObject +{ +#if UNITY_EDITOR + public string OutputPath = "Generated"; + + [ContextMenu("Generate Sync Code")] + private void GenerateSyncCode() + { + #region collect + + var clearPath = Path.Combine(Application.dataPath, OutputPath, "Sync"); + if (Directory.Exists(clearPath)) + Directory.Delete(clearPath, true); + + ushort counter = 0; + var compressors = new List>(); + var components = new List>(); + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + foreach (var type in assembly.GetTypes()) + { + var syncAttributes = type.GetCustomAttributes(typeof(SyncAttribute), false); + + if (syncAttributes != null && syncAttributes.Length > 0) + { + var componentName = type.Name; + + var fields = type.GetFields(); + var fieldTypes = new List(); + var fieldNames = new List(); + var isEnums = new List(); + var isCompressed = new List(); + + foreach (var field in fields) + { + var compressed = false; + switch (field.FieldType.ToString()) + { + case "System.Single": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}", compressor.Min, + compressor.Max, compressor.Precision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector2": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector3": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Z", compressor.ZMin, + compressor.ZMax, compressor.ZPrecision)); + compressed = true; + } + } + break; + } + + isEnums.Add(field.FieldType.IsEnum); + fieldTypes.Add(field.FieldType.ToString()); + fieldNames.Add(field.Name); + isCompressed.Add(compressed); + } + + components.Add(new Tuple(componentName, counter, + fieldTypes.ToArray(), fieldNames.ToArray(), isEnums.ToArray(), isCompressed.ToArray())); + counter++; + } + else + { + var serializeAttributes = type.GetCustomAttributes(typeof(SerializeAttribute), false); + + if (serializeAttributes != null && serializeAttributes.Length > 0) + { + var componentName = type.Name; + + var fields = type.GetFields(); + var fieldTypes = new List(); + var fieldNames = new List(); + var isEnums = new List(); + var isCompressed = new List(); + + foreach (var field in fields) + { + var compressed = false; + switch (field.FieldType.ToString()) + { + case "System.Single": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}", compressor.Min, + compressor.Max, compressor.Precision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector2": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector3": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressors.Add(new Tuple( + $"{componentName.Replace("Component", "")}{field.Name}Z", compressor.ZMin, + compressor.ZMax, compressor.ZPrecision)); + compressed = true; + } + } + break; + } + + isEnums.Add(field.FieldType.IsEnum); + fieldTypes.Add(field.FieldType.ToString()); + fieldNames.Add(field.Name); + isCompressed.Add(compressed); + } + + var componentTemplate = new SyncComponentGenerator(); + var d = new Dictionary + { + {"ComponentName", componentName}, + {"ComponentId", counter}, + {"FieldTypes", fieldTypes.ToArray()}, + {"FieldNames", fieldNames.ToArray()}, + {"IsEnums", isEnums.ToArray()}, + {"IsCompressed", isCompressed.ToArray()} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + var output = componentTemplate.TransformText(); + + SaveFile("Sync/Components/", $"{componentName}.cs", output); + counter++; + } + } + } + + #endregion + + #region components + + foreach (var tuple in components) + { + var componentTemplate = new SyncComponentGenerator(); + var d = new Dictionary + { + {"ComponentName", tuple.Item1}, + {"ComponentId", tuple.Item2}, + {"FieldTypes", tuple.Item3}, + {"FieldNames", tuple.Item4}, + {"IsEnums", tuple.Item5}, + {"IsCompressed", tuple.Item6} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + var output = componentTemplate.TransformText(); + + SaveFile("Sync/Components/", $"{tuple.Item1}.cs", output); + } + + #endregion + + #region capture removed components + + foreach (var tuple in components) + { + var componentTemplate = new SyncRemovedComponentSystemGenerator(); + var d = new Dictionary + { + {"ComponentName", tuple.Item1.Replace("Component", "")}, + {"ComponentId", tuple.Item2}, + {"IsTag", tuple.Item3.Length == 0} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + var output = componentTemplate.TransformText(); + + SaveFile("Sync/Capture/", $"ServerCaptureRemoved{tuple.Item1.Replace("Component", "")}System.cs", output); + } + + #endregion + + #region capture changed/added components + + foreach (var tuple in components) + { + var componentTemplate = new SyncChangedComponentSystemGenerator(); + var d = new Dictionary + { + {"ComponentName", tuple.Item1.Replace("Component", "")}, + {"ComponentId", tuple.Item2}, + {"IsTag", tuple.Item3.Length == 0} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + var output = componentTemplate.TransformText(); + + SaveFile("Sync/Capture/", $"ServerCaptureChanged{tuple.Item1.Replace("Component", "")}System.cs", output); + } + + #endregion + + #region pack entity utility + + { + var packUtilityTemplate = new PackEntityUtilityGenerator(); + var d = new Dictionary + { + {"ComponentNames", components.Select(x => x.Item1).ToArray()}, + {"ComponentIds", components.Select(x => x.Item2).ToArray()}, + {"IsTags", components.Select(x => x.Item3.Length == 0).ToArray()} + }; + + packUtilityTemplate.Session = d; + packUtilityTemplate.Initialize(); + var output = packUtilityTemplate.TransformText(); + + SaveFile("Sync/Utility/", "PackEntityUtility.cs", output); + } + + #endregion + + #region unpack entity utility + + { + var template = new UnpackEntityUtilityGenerator(); + var d = new Dictionary + { + {"ComponentNames", components.Select(x => x.Item1).ToArray()}, + {"ComponentIds", components.Select(x => x.Item2).ToArray()}, + {"IsTags", components.Select(x => x.Item3.Length == 0).ToArray()} + }; + + template.Session = d; + template.Initialize(); + var output = template.TransformText(); + + SaveFile("Sync/Utility/", "UnpackEntityUtility.cs", output); + } + + #endregion + + #region feature + + { + var template = new SyncFeatureGenerator(); + var d = new Dictionary + { + {"ComponentNames", components.Select(x => x.Item1.Replace("Component", "")).ToArray()} + }; + + template.Session = d; + template.Initialize(); + var output = template.TransformText(); + + SaveFile("Sync/Feature/", "ServerStateCaptureFeature.cs", output); + } + + #endregion + + #region compressors + + { + var template = new CompressorsGenerator(); + var d = new Dictionary + { + {"Prefix", "Sync"}, + {"CompressorNames", compressors.Select(x => x.Item1).ToArray()}, + {"Mins", compressors.Select(x => x.Item2).ToArray()}, + {"Maxs", compressors.Select(x => x.Item3).ToArray()}, + {"Precisions", compressors.Select(x => x.Item4).ToArray()} + }; + + template.Session = d; + template.Initialize(); + var output = template.TransformText(); + + SaveFile("Sync/Compressors/", "SyncCompressors.cs", output); + } + + #endregion + + AssetDatabase.Refresh(); + } + + [ContextMenu("Generate Command Code")] + private void GenerateCommandCode() + { + #region collect + + var clearPath = Path.Combine(Application.dataPath, OutputPath, "Command"); + if (Directory.Exists(clearPath)) + Directory.Delete(clearPath, true); + + ushort serverCounter = 0; + ushort clientCounter = 0; + var compressors = new List>(); + var serverCommands = new List>(); + var clientCommands = new List>(); + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + foreach (var type in assembly.GetTypes()) + { + var serverAttribute = type.GetCustomAttributes(typeof(CommandToServerAttribute), false); + + if (serverAttribute != null && serverAttribute.Length > 0) + { + var name = type.Name.Replace("Scheme", ""); + + var fields = type.GetFields(); + var fieldTypes = new List(); + var fieldNames = new List(); + var isEnums = new List(); + var isCompressed = new List(); + + foreach (var field in fields) + { + var compressed = false; + switch (field.FieldType.ToString()) + { + case "System.Single": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}", compressor.Min, + compressor.Max, compressor.Precision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector2": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector3": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressors.Add(new Tuple( + $"Client{name.Replace("Component", "")}{field.Name}Z", compressor.ZMin, + compressor.ZMax, compressor.ZPrecision)); + compressed = true; + } + } + break; + } + + isEnums.Add(field.FieldType.IsEnum); + fieldTypes.Add(field.FieldType.ToString()); + fieldNames.Add(field.Name); + isCompressed.Add(compressed); + } + + clientCommands.Add(new Tuple(name, clientCounter, + fieldTypes.ToArray(), fieldNames.ToArray(), isEnums.ToArray(), isCompressed.ToArray())); + clientCounter++; + } + + var clientAttribute = type.GetCustomAttributes(typeof(CommandToClientAttribute), false); + + if (clientAttribute != null && clientAttribute.Length > 0) + { + var name = type.Name.Replace("Scheme", ""); + + var fields = type.GetFields(); + var fieldTypes = new List(); + var fieldNames = new List(); + var isEnums = new List(); + var isCompressed = new List(); + + foreach (var field in fields) + { + var compressed = false; + switch (field.FieldType.ToString()) + { + case "System.Single": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Server{name}{field.Name}", compressor.Min, + compressor.Max, compressor.Precision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector2": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Server{name}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"Server{name}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressed = true; + } + } + break; + case "UnityEngine.Vector3": + { + var compressor = field.GetCustomAttribute(); + if (compressor != null) + { + compressors.Add(new Tuple( + $"Server{name}{field.Name}X", compressor.XMin, + compressor.XMax, compressor.XPrecision)); + compressors.Add(new Tuple( + $"Server{name}{field.Name}Y", compressor.YMin, + compressor.YMax, compressor.YPrecision)); + compressors.Add(new Tuple( + $"Server{name}{field.Name}Z", compressor.ZMin, + compressor.ZMax, compressor.ZPrecision)); + compressed = true; + } + } + break; + } + + isEnums.Add(field.FieldType.IsEnum); + fieldTypes.Add(field.FieldType.ToString()); + fieldNames.Add(field.Name); + isCompressed.Add(compressed); + } + + serverCommands.Add(new Tuple(name, serverCounter, + fieldTypes.ToArray(), fieldNames.ToArray(), isEnums.ToArray(), isCompressed.ToArray())); + serverCounter++; + } + } + + #endregion + + #region execution interfaces + + var serverSystem = new SchemeCommandExecutorInterfaceGenerator(); + var d = new Dictionary + { + {"Using", "Client"}, + {"Type", "Server"}, + {"SchemeNames", clientCommands.Select(x => x.Item1).ToArray()} + }; + + serverSystem.Session = d; + serverSystem.Initialize(); + var output = serverSystem.TransformText(); + + SaveFile("Command/Execution/", "IServerHandler.cs", output); + + var clientSystem = new SchemeCommandExecutorInterfaceGenerator(); + d = new Dictionary + { + {"Using", "Server"}, + {"Type", "Client"}, + {"SchemeNames", serverCommands.Select(x => x.Item1).ToArray()} + }; + + clientSystem.Session = d; + clientSystem.Initialize(); + output = clientSystem.TransformText(); + + SaveFile("Command/Execution/", "IClientHandler.cs", output); + + #endregion + + #region executors + + var serverExecutor = new SchemeCommandExecutorGenerator(); + d = new Dictionary + { + {"Using", "Client"}, + {"Type", "Server"}, + {"SchemeNames", clientCommands.Select(x => x.Item1).ToArray()}, + {"SchemeIds", clientCommands.Select(x => x.Item2).ToArray()} + }; + + serverExecutor.Session = d; + serverExecutor.Initialize(); + output = serverExecutor.TransformText(); + + SaveFile("Command/Execution/", "ServerCommandExecutor.cs", output); + + var clientExecutor = new SchemeCommandExecutorGenerator(); + d = new Dictionary + { + {"Using", "Server"}, + {"Type", "Client"}, + {"SchemeNames", serverCommands.Select(x => x.Item1).ToArray()}, + {"SchemeIds", serverCommands.Select(x => x.Item2).ToArray()} + }; + + clientExecutor.Session = d; + clientExecutor.Initialize(); + output = clientExecutor.TransformText(); + + SaveFile("Command/Execution/", "ClientCommandExecutor.cs", output); + + #endregion + + #region commands + + foreach (var tuple in serverCommands) + { + var componentTemplate = new SchemeCommandGenerator(); + d = new Dictionary + { + {"Namespace", "Server"}, + {"CommandName", tuple.Item1}, + {"CommandId", tuple.Item2}, + {"FieldTypes", tuple.Item3}, + {"FieldNames", tuple.Item4}, + {"IsEnums", tuple.Item5}, + {"IsCompressed", tuple.Item6} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + output = componentTemplate.TransformText(); + + SaveFile("Command/Server/", $"{tuple.Item1}Command.cs", output); + } + + foreach (var tuple in clientCommands) + { + var componentTemplate = new SchemeCommandGenerator(); + d = new Dictionary + { + {"Namespace", "Client"}, + {"CommandName", tuple.Item1}, + {"CommandId", tuple.Item2}, + {"FieldTypes", tuple.Item3}, + {"FieldNames", tuple.Item4}, + {"IsEnums", tuple.Item5}, + {"IsCompressed", tuple.Item6} + }; + + componentTemplate.Session = d; + componentTemplate.Initialize(); + output = componentTemplate.TransformText(); + + SaveFile("Command/Client/", $"{tuple.Item1}Command.cs", output); + } + + #endregion + + #region compressors + + { + var template = new CompressorsGenerator(); + d = new Dictionary + { + {"Prefix", "Command"}, + {"CompressorNames", compressors.Select(x => x.Item1).ToArray()}, + {"Mins", compressors.Select(x => x.Item2).ToArray()}, + {"Maxs", compressors.Select(x => x.Item3).ToArray()}, + {"Precisions", compressors.Select(x => x.Item4).ToArray()} + }; + + template.Session = d; + template.Initialize(); + output = template.TransformText(); + + SaveFile("Command/Compressors/", "SyncCompressors.cs", output); + } + + #endregion + + AssetDatabase.Refresh(); + } + + private void SaveFile(string directory, string fileName, string text) + { + try + { + var path = Path.Combine(Application.dataPath, OutputPath, directory); + Directory.CreateDirectory(path); + path = Path.Combine(path, fileName); + File.WriteAllText(path, text); + } + catch (Exception e) + { + Debug.LogError($"Error while saving file {name}:" + e.Message); + throw; + } + } +#endif +} \ No newline at end of file diff --git a/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs.meta b/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs.meta new file mode 100644 index 0000000..f6abc76 --- /dev/null +++ b/Assets/Sources/Codegen/CodegenExecutor/CodegenExecutor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 16d40f4c171d6f647a7e84fcaaf26327 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/CommandSchemes.meta b/Assets/Sources/CommandSchemes.meta new file mode 100644 index 0000000..5fe8b56 --- /dev/null +++ b/Assets/Sources/CommandSchemes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 35583590a39948738fb0e9ca84c2fae8 +timeCreated: 1557594366 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ICommand.cs b/Assets/Sources/CommandSchemes/ICommand.cs new file mode 100644 index 0000000..7253355 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ICommand.cs @@ -0,0 +1,7 @@ +using NetStack.Serialization; + +public interface ICommand +{ + void Serialize(BitBuffer bitBuffer); + void Deserialize(BitBuffer bitBuffer); +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ICommand.cs.meta b/Assets/Sources/CommandSchemes/ICommand.cs.meta new file mode 100644 index 0000000..71dc59f --- /dev/null +++ b/Assets/Sources/CommandSchemes/ICommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f1be1272dfa84381b835c4f0a59a1870 +timeCreated: 1557598638 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient.meta b/Assets/Sources/CommandSchemes/ToClient.meta new file mode 100644 index 0000000..a155dbc --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4011258077df4954be2668a6e1c8c16d +timeCreated: 1557594392 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs b/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs new file mode 100644 index 0000000..aabc328 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs @@ -0,0 +1,11 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToClient +{ + [CommandToClient] + public class ChatMessageScheme + { + public string Message; + public ushort Sender; + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs.meta b/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs.meta new file mode 100644 index 0000000..1318962 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/ChatMessageScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94a4bc6ac9d941e288b522bcb53d88ac +timeCreated: 1557599093 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs b/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs new file mode 100644 index 0000000..5af1d77 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs @@ -0,0 +1,10 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToClient +{ + [CommandToClient] + public class GrantedIdScheme + { + public ushort Id; + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs.meta b/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs.meta new file mode 100644 index 0000000..2d67f2e --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/GrantedIdScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e852bd7e236142e2a28151e90a9e1eb7 +timeCreated: 1557671269 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs b/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs new file mode 100644 index 0000000..2ea6674 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs @@ -0,0 +1,10 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToClient +{ + [CommandToClient] + public class SetTickrateScheme + { + public ushort Tickrate; + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs.meta b/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs.meta new file mode 100644 index 0000000..1d49ae0 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToClient/SetTickrateScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2e8a4564270d4f57bc1ce346ee660205 +timeCreated: 1557922705 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer.meta b/Assets/Sources/CommandSchemes/ToServer.meta new file mode 100644 index 0000000..710ff98 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 56193667f4da4fffbda78a639b2cd32f +timeCreated: 1557594385 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs b/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs new file mode 100644 index 0000000..ea4a399 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs @@ -0,0 +1,10 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToServer +{ + [CommandToServer] + public class ChatMessageScheme + { + public string Message; + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs.meta b/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs.meta new file mode 100644 index 0000000..5fdd87e --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/ChatMessageScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5d578a4f6ef041108d864c7af5458ecd +timeCreated: 1557676027 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs b/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs new file mode 100644 index 0000000..1091544 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs @@ -0,0 +1,9 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToServer +{ + [CommandToServer] + public class RequestCharacterScheme + { + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs.meta b/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs.meta new file mode 100644 index 0000000..9892b53 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/RequestCharacterScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f4e812ce938b43578290aeb186598d0e +timeCreated: 1558201839 \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs b/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs new file mode 100644 index 0000000..0b3f2f5 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs @@ -0,0 +1,10 @@ +using Codegen.CodegenAttributes; + +namespace Sources.CommandSchemes.ToServer +{ + [CommandToServer] + public class SetTickrateScheme + { + public ushort Tickrate; + } +} \ No newline at end of file diff --git a/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs.meta b/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs.meta new file mode 100644 index 0000000..13f67d7 --- /dev/null +++ b/Assets/Sources/CommandSchemes/ToServer/SetTickrateScheme.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6fdcc79fbd1b42c9bee92a0700a36d69 +timeCreated: 1558385134 \ No newline at end of file diff --git a/Assets/Sources/Common.meta b/Assets/Sources/Common.meta new file mode 100644 index 0000000..b72e776 --- /dev/null +++ b/Assets/Sources/Common.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eacb205581764de39af914df9ad5dd2d +timeCreated: 1556833308 \ No newline at end of file diff --git a/Assets/Sources/Common/DestroyedComponent.cs b/Assets/Sources/Common/DestroyedComponent.cs new file mode 100644 index 0000000..c3f7030 --- /dev/null +++ b/Assets/Sources/Common/DestroyedComponent.cs @@ -0,0 +1,9 @@ +using Entitas; +using Entitas.CodeGeneration.Attributes; + +[Game] +[Event(EventTarget.Self)] +[Cleanup(CleanupMode.DestroyEntity)] +public class DestroyedComponent : IComponent +{ +} \ No newline at end of file diff --git a/Assets/Sources/Common/DestroyedComponent.cs.meta b/Assets/Sources/Common/DestroyedComponent.cs.meta new file mode 100644 index 0000000..2748d13 --- /dev/null +++ b/Assets/Sources/Common/DestroyedComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 68cda93113f94ddb8d32b78c141bf027 +timeCreated: 1556833325 \ No newline at end of file diff --git a/Assets/Sources/Common/IdComponent.cs b/Assets/Sources/Common/IdComponent.cs new file mode 100644 index 0000000..5683407 --- /dev/null +++ b/Assets/Sources/Common/IdComponent.cs @@ -0,0 +1,15 @@ +using Codegen.CodegenAttributes; +using Entitas; +using Entitas.CodeGeneration.Attributes; + +[Game] +[Sync] +public partial class IdComponent : IComponent +{ + [PrimaryEntityIndex] public ushort Value; + + public IdComponent() + { + Value = ushort.MaxValue; + } +} \ No newline at end of file diff --git a/Assets/Sources/Common/IdComponent.cs.meta b/Assets/Sources/Common/IdComponent.cs.meta new file mode 100644 index 0000000..ace3520 --- /dev/null +++ b/Assets/Sources/Common/IdComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 929e1b29b0c54929af5b04cfe641591b +timeCreated: 1556835251 \ No newline at end of file diff --git a/Assets/Sources/CommonGeneratedFeature.cs b/Assets/Sources/CommonGeneratedFeature.cs new file mode 100644 index 0000000..cebb84b --- /dev/null +++ b/Assets/Sources/CommonGeneratedFeature.cs @@ -0,0 +1,8 @@ +public class CommonGeneratedFeature : Feature +{ + public CommonGeneratedFeature(Contexts contexts) + { + Add(new GameEventSystems(contexts)); + Add(new GameCleanupSystems(contexts)); + } +} \ No newline at end of file diff --git a/Assets/Sources/CommonGeneratedFeature.cs.meta b/Assets/Sources/CommonGeneratedFeature.cs.meta new file mode 100644 index 0000000..cb8f062 --- /dev/null +++ b/Assets/Sources/CommonGeneratedFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 410fcdef53cd4afca6a7005f26e7f0a2 +timeCreated: 1557759807 \ No newline at end of file diff --git a/Assets/Sources/GameController.cs b/Assets/Sources/GameController.cs new file mode 100644 index 0000000..8bf2e7e --- /dev/null +++ b/Assets/Sources/GameController.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using ENet; +using Entitas; +using Sources.Networking.Client; +using Sources.Networking.Server; +using UnityEngine; +using Random = UnityEngine.Random; + +public class GameController : MonoBehaviour +{ + public static GameController I; + [NonSerialized] public Mode Mode = Mode.Inactive; + + [Header("Server")] public int TargetTickPerSecond = 20; + + [Header("Client")] public int PanicStateCount = 10; + public int PanicCleanupTarget = 6; + + private IGroup _connectionsGroup; + private readonly List _connectionsBuffer = new List(ServerNetworkSystem.MaxPlayers); + + private Contexts _contexts; + + private ClientNetworkSystem _client; + private ClientFeature _clientFeature; + + private ServerNetworkSystem _server; + private ServerFeature _serverFeature; + + private int _tickCount; + private ushort _tickrate = 10; + private float _timer = 1f; + private int _totalTicksThisSecond; + + private string _ip = "192.168.1.1"; + private float _lastUpdate; + private string _message = ""; + private ushort _port = 9500; + + private int _lastId; + + private void Awake() + { + I = this; + Library.Initialize(); + + _contexts = Contexts.sharedInstance; + _connectionsGroup = _contexts.game.GetGroup(GameMatcher.Connection); + _lastUpdate = Time.realtimeSinceStartup; + } + + public void StartServer() + { + if (Mode != Mode.Inactive) + throw new ApplicationException("Can't start server if already active."); + + SetupHooks(_contexts); + + _server = new ServerNetworkSystem(_contexts); + _server.TickRate = (ushort) TargetTickPerSecond; + + var services = new Services + { + ServerSystem = _server + }; + + _serverFeature = new ServerFeature(_contexts, services); + Mode = Mode.Server; + } + + public void StartClient() + { + if (Mode != Mode.Inactive) + throw new ApplicationException("Can't start client if already active."); + + _client = new ClientNetworkSystem(_contexts); + _client.TickRate = (ushort) TargetTickPerSecond; + _client.PanicStateCount = PanicStateCount; + _client.PanicCleanupTarget = PanicCleanupTarget; + + var services = new Services + { + ClientSystem = _client + }; + + _clientFeature = new ClientFeature(_contexts, services); + Mode = Mode.Client; + } + + private void Update() + { + switch (Mode) + { + case Mode.Server: + TargetTickPerSecond = _server.TickRate; + break; + case Mode.Client: + TargetTickPerSecond = _client.TickRate; + break; + } + + while (_lastUpdate < Time.realtimeSinceStartup) + { + _lastUpdate += 1f / TargetTickPerSecond; + _tickCount++; + switch (Mode) + { + case Mode.Server: + _server.Execute(); + _serverFeature.Execute(); + _serverFeature.Cleanup(); + break; + case Mode.Client: + _client.UpdateNetwork(); + _client.Execute(); + _clientFeature.Execute(); + _clientFeature.Cleanup(); + break; + } + } + + _timer -= Time.deltaTime; + if (_timer < 0f) + { + _totalTicksThisSecond = _tickCount; + _tickCount = 0; + _timer += 1; + } + } + + private void OnGUI() + { + GUILayout.Label($"TPS {_totalTicksThisSecond}"); + switch (Mode) + { + case Mode.Inactive: + if (GUILayout.Button("Setup Server")) StartServer(); + if (GUILayout.Button("Setup Client")) StartClient(); + break; + case Mode.Server: + switch (_server.State) + { + case ServerState.Stopped: + GUILayout.Label("Server stopped"); + GUILayout.BeginHorizontal(); + _ip = GUILayout.TextField(_ip, GUILayout.Width(120)); + var tmp = + GUILayout.TextField(_port.ToString(), GUILayout.Width(60)); + if (ushort.TryParse(tmp, out var result)) _port = result; + if (GUILayout.Button("Start!")) + { + var address = new Address(); + address.Port = _port; + address.SetHost(_ip); + _server.StartServer(address); + } + + GUILayout.EndHorizontal(); + if (GUILayout.Button("localhost")) _ip = "localhost"; + break; + case ServerState.Starting: + GUILayout.Label("Server starting"); + break; + case ServerState.Working: + GUILayout.Label("Server working"); + if (GUILayout.Button("Stop!")) _server.StopServer(); + break; + case ServerState.Stopping: + GUILayout.Label("Server stopping"); + break; + } + + break; + case Mode.Client: + switch (_client.State) + { + case ClientState.Disconnected: + GUILayout.Label("Disconnected"); + GUILayout.BeginHorizontal(); + _ip = GUILayout.TextField(_ip, GUILayout.Width(120)); + var tmp = + GUILayout.TextField(_port.ToString(), GUILayout.Width(60)); + if (ushort.TryParse(tmp, out var result)) _port = result; + if (GUILayout.Button("Connect!")) + { + var address = new Address(); + address.Port = _port; + address.SetHost(_ip); + _client.Connect(address); + } + + GUILayout.EndHorizontal(); + if (GUILayout.Button("localhost")) _ip = "localhost"; + break; + case ClientState.Connecting: + GUILayout.Label("Connecting"); + if (GUILayout.Button("Cancel")) _client.EnqueueRequest(NetworkThreadRequest.CancelConnect); + break; + case ClientState.WaitingForId: + GUILayout.Label("WaitingForId"); + break; + case ClientState.Connected: + GUILayout.BeginHorizontal(); + GUILayout.Label("Connected"); + tmp = GUILayout.TextField(_tickrate.ToString(), GUILayout.Width(60)); + if (ushort.TryParse(tmp, out result)) + if (result > 0) + _tickrate = result; + + if (GUILayout.Button("Set tickRate")) + _client.EnqueueCommand(new ClientSetTickrateCommand {Tickrate = _tickrate}); + + var str = "States :"; + for (var i = 0; i < _client.StatesCount; i++) str += "#"; + GUILayout.Label(str); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + _message = GUILayout.TextField(_message, GUILayout.Width(120)); + if (GUILayout.Button("Send message")) + _client.EnqueueCommand(new ClientChatMessageCommand {Message = _message}); + if (GUILayout.Button("Request character")) + _client.EnqueueCommand(new ClientRequestCharacterCommand()); + GUILayout.EndHorizontal(); + if (GUILayout.Button("Disconnect")) _client.Disconnect(); + break; + case ClientState.Disconnecting: + GUILayout.Label("Disconnecting"); + break; + } + + break; + } + } + + private void OnDestroy() + { + switch (Mode) + { + case Mode.Server: + _server.TearDown(); + _serverFeature.TearDown(); + break; + case Mode.Client: + _client.TearDown(); + _clientFeature.TearDown(); + break; + } + + Library.Deinitialize(); + } + + private void SetupHooks(Contexts contexts) + { + contexts.Reset(); + contexts.game.OnEntityCreated += (context, entity) => + { + ((GameEntity) entity).AddId((ushort) _lastId); + _lastId++; + }; + } +} + +public enum Mode +{ + Inactive, + Server, + Client +} \ No newline at end of file diff --git a/Assets/Sources/GameController.cs.meta b/Assets/Sources/GameController.cs.meta new file mode 100644 index 0000000..3400457 --- /dev/null +++ b/Assets/Sources/GameController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dbbbddda32854a78aa149317fbcf6c63 +timeCreated: 1556835320 \ No newline at end of file diff --git a/Assets/Sources/Gameplay.meta b/Assets/Sources/Gameplay.meta new file mode 100644 index 0000000..240f751 --- /dev/null +++ b/Assets/Sources/Gameplay.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a459d548064819d4faeac7e9959bea15 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Gameplay/Cleanup.meta b/Assets/Sources/Gameplay/Cleanup.meta new file mode 100644 index 0000000..c7156d3 --- /dev/null +++ b/Assets/Sources/Gameplay/Cleanup.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a3819cbfe421ef4591ed8beade42d2f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs b/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs new file mode 100644 index 0000000..76933f3 --- /dev/null +++ b/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Entitas; + +public sealed class DestroyDestroyedGameSystem : ICleanupSystem { + + readonly IGroup _group; + readonly List _buffer = new List(); + + public DestroyDestroyedGameSystem(Contexts contexts) { + _group = contexts.game.GetGroup(GameMatcher.Destroyed); + } + + public void Cleanup() { + foreach (var e in _group.GetEntities(_buffer)) { + e.Destroy(); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs.meta b/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs.meta new file mode 100644 index 0000000..3b3b453 --- /dev/null +++ b/Assets/Sources/Gameplay/Cleanup/DestroyDestroyedGameSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1031de9a0e542604aa6c82fd62743636 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs b/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs new file mode 100644 index 0000000..bfa6b25 --- /dev/null +++ b/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs @@ -0,0 +1,6 @@ +public sealed class GameCleanupSystems : Feature { + + public GameCleanupSystems(Contexts contexts) { + Add(new DestroyDestroyedGameSystem(contexts)); + } +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs.meta b/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs.meta new file mode 100644 index 0000000..5835dd7 --- /dev/null +++ b/Assets/Sources/Gameplay/Cleanup/GameCleanupSystems.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a98d0021cf2dc2a44961d60da2b77009 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Gameplay/Client.meta b/Assets/Sources/Gameplay/Client.meta new file mode 100644 index 0000000..bd24e41 --- /dev/null +++ b/Assets/Sources/Gameplay/Client.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce4bd5193e9442f6bf0b0dfe28c3b1ad +timeCreated: 1557775740 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/ClientGameplayFeature.cs b/Assets/Sources/Gameplay/ClientGameplayFeature.cs new file mode 100644 index 0000000..ab6b236 --- /dev/null +++ b/Assets/Sources/Gameplay/ClientGameplayFeature.cs @@ -0,0 +1,6 @@ +public class ClientGameplayFeature : Feature +{ + public ClientGameplayFeature(Contexts contexts, Services services) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/ClientGameplayFeature.cs.meta b/Assets/Sources/Gameplay/ClientGameplayFeature.cs.meta new file mode 100644 index 0000000..0091a09 --- /dev/null +++ b/Assets/Sources/Gameplay/ClientGameplayFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 60fe02e654cc4660b676ecd8b1c434d0 +timeCreated: 1557775928 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Common.meta b/Assets/Sources/Gameplay/Common.meta new file mode 100644 index 0000000..2149a62 --- /dev/null +++ b/Assets/Sources/Gameplay/Common.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce47a1fe8d0c48dbbe92e88b368be477 +timeCreated: 1557775724 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/CommonGameplayFeature.cs b/Assets/Sources/Gameplay/CommonGameplayFeature.cs new file mode 100644 index 0000000..77e3f51 --- /dev/null +++ b/Assets/Sources/Gameplay/CommonGameplayFeature.cs @@ -0,0 +1,6 @@ +public class CommonGameplayFeature : Feature +{ + public CommonGameplayFeature(Contexts contexts, Services services) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/CommonGameplayFeature.cs.meta b/Assets/Sources/Gameplay/CommonGameplayFeature.cs.meta new file mode 100644 index 0000000..f8647b2 --- /dev/null +++ b/Assets/Sources/Gameplay/CommonGameplayFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2c6135d09f474085ade568535be751c9 +timeCreated: 1557776025 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server.meta b/Assets/Sources/Gameplay/Server.meta new file mode 100644 index 0000000..67f5249 --- /dev/null +++ b/Assets/Sources/Gameplay/Server.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 26daafa7f2094000b01d40d7886cc47b +timeCreated: 1557775731 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server/Character.meta b/Assets/Sources/Gameplay/Server/Character.meta new file mode 100644 index 0000000..f6cded9 --- /dev/null +++ b/Assets/Sources/Gameplay/Server/Character.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: add92519f9da47a8be206bf303ae2682 +timeCreated: 1558107065 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server/Character/Character.cs b/Assets/Sources/Gameplay/Server/Character/Character.cs new file mode 100644 index 0000000..946ebf6 --- /dev/null +++ b/Assets/Sources/Gameplay/Server/Character/Character.cs @@ -0,0 +1,8 @@ +using Codegen.CodegenAttributes; +using Entitas; + +[Game] +[Sync] +public partial class Character : IComponent +{ +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server/Character/Character.cs.meta b/Assets/Sources/Gameplay/Server/Character/Character.cs.meta new file mode 100644 index 0000000..d84c32b --- /dev/null +++ b/Assets/Sources/Gameplay/Server/Character/Character.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d6250aee6fc478cbf00a4b87a2265ff +timeCreated: 1558107070 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs b/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs new file mode 100644 index 0000000..db07e87 --- /dev/null +++ b/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs @@ -0,0 +1,10 @@ +using Codegen.CodegenAttributes; +using Entitas; +using Entitas.CodeGeneration.Attributes; + +[Game] +[Sync] +public partial class ControlledBy : IComponent +{ + [PrimaryEntityIndex] public ushort Value; +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs.meta b/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs.meta new file mode 100644 index 0000000..3f61c5c --- /dev/null +++ b/Assets/Sources/Gameplay/Server/Character/ControlledBy.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6e64bdea8db349a5bfe64490ce656e0d +timeCreated: 1558107120 \ No newline at end of file diff --git a/Assets/Sources/Gameplay/ServerGameplayFeature.cs b/Assets/Sources/Gameplay/ServerGameplayFeature.cs new file mode 100644 index 0000000..4570ca6 --- /dev/null +++ b/Assets/Sources/Gameplay/ServerGameplayFeature.cs @@ -0,0 +1,6 @@ +public class ServerGameplayFeature : Feature +{ + public ServerGameplayFeature(Contexts contexts, Services services) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Gameplay/ServerGameplayFeature.cs.meta b/Assets/Sources/Gameplay/ServerGameplayFeature.cs.meta new file mode 100644 index 0000000..f02dd2e --- /dev/null +++ b/Assets/Sources/Gameplay/ServerGameplayFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ed61ffd1840f4e52ba1d7b308145a0dc +timeCreated: 1557775992 \ No newline at end of file diff --git a/Assets/Sources/Generated.meta b/Assets/Sources/Generated.meta new file mode 100644 index 0000000..218e744 --- /dev/null +++ b/Assets/Sources/Generated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b068ead1c3f5d54eb74f04148a25d08 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command.meta b/Assets/Sources/Generated/Command.meta new file mode 100644 index 0000000..77259e4 --- /dev/null +++ b/Assets/Sources/Generated/Command.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9ceef8a286f46a4b9fe205d7fd61f11 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Client.meta b/Assets/Sources/Generated/Command/Client.meta new file mode 100644 index 0000000..486f852 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e3d5da0ebf3dd84b9eaec269e3fbee2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs b/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs new file mode 100644 index 0000000..06ffe86 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs @@ -0,0 +1,17 @@ +using NetStack.Serialization; + +public struct ClientChatMessageCommand : ICommand, IClientCommand +{ + public System.String Message; + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(0); + + bitBuffer.AddString(Message); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Message = bitBuffer.ReadString(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs.meta b/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs.meta new file mode 100644 index 0000000..ce91369 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/ChatMessageCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b9a6c41b5ff5467479f6f8105f68393e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs b/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs new file mode 100644 index 0000000..6f9e109 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs @@ -0,0 +1,14 @@ +using NetStack.Serialization; + +public struct ClientRequestCharacterCommand : ICommand, IClientCommand +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(1); + + } + + public void Deserialize(BitBuffer bitBuffer) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs.meta b/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs.meta new file mode 100644 index 0000000..a0b8910 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/RequestCharacterCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3bcaeb854aef90449887d074aeb6f9c9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs b/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs new file mode 100644 index 0000000..e213981 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs @@ -0,0 +1,17 @@ +using NetStack.Serialization; + +public struct ClientSetTickrateCommand : ICommand, IClientCommand +{ + public System.UInt16 Tickrate; + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(2); + + bitBuffer.AddUShort(Tickrate); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Tickrate = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs.meta b/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs.meta new file mode 100644 index 0000000..7016fd0 --- /dev/null +++ b/Assets/Sources/Generated/Command/Client/SetTickrateCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1caa3b54131741c45af9ebe904e37b06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Compressors.meta b/Assets/Sources/Generated/Command/Compressors.meta new file mode 100644 index 0000000..c126871 --- /dev/null +++ b/Assets/Sources/Generated/Command/Compressors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66079a72588ae4c4683dc879c97d5e24 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs b/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs new file mode 100644 index 0000000..dfa4dcc --- /dev/null +++ b/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs @@ -0,0 +1,9 @@ +using NetStack.Compression; + +public static class CommandCompressors +{ + + static CommandCompressors() + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs.meta b/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs.meta new file mode 100644 index 0000000..690ddaa --- /dev/null +++ b/Assets/Sources/Generated/Command/Compressors/SyncCompressors.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4851cb22edcf4ba4e87310230be6ecfd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Execution.meta b/Assets/Sources/Generated/Command/Execution.meta new file mode 100644 index 0000000..0301c1b --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2cbb8536ae171ae4a8a7074e91c541d9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs b/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs new file mode 100644 index 0000000..27f18d4 --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs @@ -0,0 +1,43 @@ +using NetStack.Serialization; +using Sources.Tools; + +public static class ClientCommandExecutor +{ + public static void Execute(IClientHandler handler, BitBuffer buffer, ushort commandCount) + { + for (int i = 0; i < commandCount; i++) + { + var commandId = buffer.ReadUShort(); + switch (commandId) + { + + case 0: + { + Logger.I.Log("ClientCommandExecutor", "Executing ServerChatMessageCommand"); + var c = new ServerChatMessageCommand(); + c.Deserialize(buffer); + handler.HandleChatMessageCommand(ref c); + break; + } + + case 1: + { + Logger.I.Log("ClientCommandExecutor", "Executing ServerGrantedIdCommand"); + var c = new ServerGrantedIdCommand(); + c.Deserialize(buffer); + handler.HandleGrantedIdCommand(ref c); + break; + } + + case 2: + { + Logger.I.Log("ClientCommandExecutor", "Executing ServerSetTickrateCommand"); + var c = new ServerSetTickrateCommand(); + c.Deserialize(buffer); + handler.HandleSetTickrateCommand(ref c); + break; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs.meta b/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs.meta new file mode 100644 index 0000000..08a38dc --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/ClientCommandExecutor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae152834dfbf07a4982e3c86ba2a5f5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Execution/IClientHandler.cs b/Assets/Sources/Generated/Command/Execution/IClientHandler.cs new file mode 100644 index 0000000..33b1a8f --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/IClientHandler.cs @@ -0,0 +1,8 @@ +public interface IClientHandler +{ + void HandleChatMessageCommand(ref ServerChatMessageCommand command); + void HandleGrantedIdCommand(ref ServerGrantedIdCommand command); + void HandleSetTickrateCommand(ref ServerSetTickrateCommand command); +} + +public interface IClientCommand{} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Execution/IClientHandler.cs.meta b/Assets/Sources/Generated/Command/Execution/IClientHandler.cs.meta new file mode 100644 index 0000000..52948e3 --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/IClientHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f185a23acafaebc4889899f003aeca13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Execution/IServerHandler.cs b/Assets/Sources/Generated/Command/Execution/IServerHandler.cs new file mode 100644 index 0000000..89f4b28 --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/IServerHandler.cs @@ -0,0 +1,8 @@ +public interface IServerHandler +{ + void HandleChatMessageCommand(ref ClientChatMessageCommand command); + void HandleRequestCharacterCommand(ref ClientRequestCharacterCommand command); + void HandleSetTickrateCommand(ref ClientSetTickrateCommand command); +} + +public interface IServerCommand{} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Execution/IServerHandler.cs.meta b/Assets/Sources/Generated/Command/Execution/IServerHandler.cs.meta new file mode 100644 index 0000000..d59797e --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/IServerHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4bac11dfd945caa459dcb90879e764f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs b/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs new file mode 100644 index 0000000..bac9c18 --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs @@ -0,0 +1,43 @@ +using NetStack.Serialization; +using Sources.Tools; + +public static class ServerCommandExecutor +{ + public static void Execute(IServerHandler handler, BitBuffer buffer, ushort commandCount) + { + for (int i = 0; i < commandCount; i++) + { + var commandId = buffer.ReadUShort(); + switch (commandId) + { + + case 0: + { + Logger.I.Log("ServerCommandExecutor", "Executing ClientChatMessageCommand"); + var c = new ClientChatMessageCommand(); + c.Deserialize(buffer); + handler.HandleChatMessageCommand(ref c); + break; + } + + case 1: + { + Logger.I.Log("ServerCommandExecutor", "Executing ClientRequestCharacterCommand"); + var c = new ClientRequestCharacterCommand(); + c.Deserialize(buffer); + handler.HandleRequestCharacterCommand(ref c); + break; + } + + case 2: + { + Logger.I.Log("ServerCommandExecutor", "Executing ClientSetTickrateCommand"); + var c = new ClientSetTickrateCommand(); + c.Deserialize(buffer); + handler.HandleSetTickrateCommand(ref c); + break; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs.meta b/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs.meta new file mode 100644 index 0000000..7cd23a8 --- /dev/null +++ b/Assets/Sources/Generated/Command/Execution/ServerCommandExecutor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b32e8bc56c359104abbe05d4946fd74d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Server.meta b/Assets/Sources/Generated/Command/Server.meta new file mode 100644 index 0000000..ad920d0 --- /dev/null +++ b/Assets/Sources/Generated/Command/Server.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a89b58cc54c3ee74fb07528eca827228 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs b/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs new file mode 100644 index 0000000..1a04d54 --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs @@ -0,0 +1,20 @@ +using NetStack.Serialization; + +public struct ServerChatMessageCommand : ICommand, IServerCommand +{ + public System.String Message; + public System.UInt16 Sender; + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(0); + + bitBuffer.AddString(Message); + bitBuffer.AddUShort(Sender); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Message = bitBuffer.ReadString(); + Sender = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs.meta b/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs.meta new file mode 100644 index 0000000..770926f --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/ChatMessageCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5211e1d87b1728b4bb7a618fb612ed09 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs b/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs new file mode 100644 index 0000000..499779d --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs @@ -0,0 +1,17 @@ +using NetStack.Serialization; + +public struct ServerGrantedIdCommand : ICommand, IServerCommand +{ + public System.UInt16 Id; + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(1); + + bitBuffer.AddUShort(Id); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Id = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs.meta b/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs.meta new file mode 100644 index 0000000..66bac0b --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/GrantedIdCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab0d8d88cbd960f478a1c2cfc30b422d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs b/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs new file mode 100644 index 0000000..aed523e --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs @@ -0,0 +1,17 @@ +using NetStack.Serialization; + +public struct ServerSetTickrateCommand : ICommand, IServerCommand +{ + public System.UInt16 Tickrate; + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(2); + + bitBuffer.AddUShort(Tickrate); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Tickrate = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs.meta b/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs.meta new file mode 100644 index 0000000..a0843ad --- /dev/null +++ b/Assets/Sources/Generated/Command/Server/SetTickrateCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d197b5ff57fa8c49a60c25eb679973e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync.meta b/Assets/Sources/Generated/Sync.meta new file mode 100644 index 0000000..0d25511 --- /dev/null +++ b/Assets/Sources/Generated/Sync.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a051aa1e17d55d74cb8de545e492b667 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture.meta b/Assets/Sources/Generated/Sync/Capture.meta new file mode 100644 index 0000000..ba1d43c --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aef0405c7e145b84ebe7f844e8b38e11 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs new file mode 100644 index 0000000..f7b9069 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + + +public class ServerCaptureChangedCharacterSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChangedCharacterSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Character.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.isCharacter; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); + _server.ChangedComponents.AddUShort(1); + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs.meta new file mode 100644 index 0000000..15f24a3 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedCharacterSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 636d0e1ffa182b24f9cecdb486fd2fb9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs new file mode 100644 index 0000000..de920e9 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + + +public class ServerCaptureChangedConnectionSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChangedConnectionSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Connection.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.hasConnection; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); + e.connection.Serialize(_server.ChangedComponents); + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs.meta new file mode 100644 index 0000000..d6d328d --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedConnectionSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c393bad8a325ed841821b2f15b5d8e5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs new file mode 100644 index 0000000..ac77266 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + + +public class ServerCaptureChangedControlledBySystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChangedControlledBySystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.ControlledBy.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.hasControlledBy; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); + e.controlledBy.Serialize(_server.ChangedComponents); + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs.meta new file mode 100644 index 0000000..0a857db --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedControlledBySystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff531dfa0001c0544aa1001e4ef43f78 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs new file mode 100644 index 0000000..3112569 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + + +public class ServerCaptureChangedIdSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChangedIdSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Id.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.hasId; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); + e.id.Serialize(_server.ChangedComponents); + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs.meta new file mode 100644 index 0000000..8d33873 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedIdSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd87814bfd1322542a74e8c71be6ccd7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs new file mode 100644 index 0000000..47933f1 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + + +public class ServerCaptureChangedSyncSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChangedSyncSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Sync.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.isSync; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); + _server.ChangedComponents.AddUShort(4); + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs.meta new file mode 100644 index 0000000..a6d6f07 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureChangedSyncSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c17a8b303444dca49a4b8e6903d5ab04 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs new file mode 100644 index 0000000..78950be --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemovedCharacterSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemovedCharacterSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Character.Removed()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.isCharacter; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(1); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs.meta new file mode 100644 index 0000000..a982701 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedCharacterSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 932899bd60c3eb1458bb7ccb5a8edf48 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs new file mode 100644 index 0000000..5163a6a --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemovedConnectionSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemovedConnectionSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Connection.Removed()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && !entity.hasConnection; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(3); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs.meta new file mode 100644 index 0000000..79a4c90 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedConnectionSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5f80f69ef94173441977116e7bc1b988 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs new file mode 100644 index 0000000..da3dbb2 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemovedControlledBySystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemovedControlledBySystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.ControlledBy.Removed()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && !entity.hasControlledBy; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(2); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs.meta new file mode 100644 index 0000000..6ff3e9a --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedControlledBySystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9206889da990bb949a669328bcb27745 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs new file mode 100644 index 0000000..ac5fc3e --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemovedIdSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemovedIdSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Id.Removed()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && !entity.hasId; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(0); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs.meta new file mode 100644 index 0000000..879efc0 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedIdSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5d64118b099d86942a62628f13633cd2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs new file mode 100644 index 0000000..2d7d195 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemovedSyncSystem : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemovedSyncSystem (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.Sync.Removed()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && entity.isWasSynced && entity.isSync; + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(4); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs.meta b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs.meta new file mode 100644 index 0000000..02f904c --- /dev/null +++ b/Assets/Sources/Generated/Sync/Capture/ServerCaptureRemovedSyncSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c07c9a250da33b74786c75a9d208a37f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components.meta b/Assets/Sources/Generated/Sync/Components.meta new file mode 100644 index 0000000..3c03239 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 61aef9424aa37ab4fa531201bfa1b728 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components/Character.cs b/Assets/Sources/Generated/Sync/Components/Character.cs new file mode 100644 index 0000000..6663e1d --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Character.cs @@ -0,0 +1,14 @@ +using NetStack.Serialization; + +public partial class Character : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(1); + + } + + public void Deserialize(BitBuffer bitBuffer) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Components/Character.cs.meta b/Assets/Sources/Generated/Sync/Components/Character.cs.meta new file mode 100644 index 0000000..2aea38e --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Character.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 127678bdb84643c4596d592076480bf6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components/Connection.cs b/Assets/Sources/Generated/Sync/Components/Connection.cs new file mode 100644 index 0000000..4e7ebbf --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Connection.cs @@ -0,0 +1,16 @@ +using NetStack.Serialization; + +public partial class Connection : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(3); + + bitBuffer.AddUShort(Id); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Id = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Components/Connection.cs.meta b/Assets/Sources/Generated/Sync/Components/Connection.cs.meta new file mode 100644 index 0000000..6472751 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Connection.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5e4f796d844b2d746988928ff7eb3834 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components/ControlledBy.cs b/Assets/Sources/Generated/Sync/Components/ControlledBy.cs new file mode 100644 index 0000000..12e93f9 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/ControlledBy.cs @@ -0,0 +1,16 @@ +using NetStack.Serialization; + +public partial class ControlledBy : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(2); + + bitBuffer.AddUShort(Value); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Value = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Components/ControlledBy.cs.meta b/Assets/Sources/Generated/Sync/Components/ControlledBy.cs.meta new file mode 100644 index 0000000..9973ca5 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/ControlledBy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e7ed7ca713cd617429e5845af6ed1922 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components/IdComponent.cs b/Assets/Sources/Generated/Sync/Components/IdComponent.cs new file mode 100644 index 0000000..c766916 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/IdComponent.cs @@ -0,0 +1,16 @@ +using NetStack.Serialization; + +public partial class IdComponent : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(0); + + bitBuffer.AddUShort(Value); + } + + public void Deserialize(BitBuffer bitBuffer) + { + Value = bitBuffer.ReadUShort(); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Components/IdComponent.cs.meta b/Assets/Sources/Generated/Sync/Components/IdComponent.cs.meta new file mode 100644 index 0000000..9e978ca --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/IdComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8d0654b0014bf8a44af178beafb316c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Components/Sync.cs b/Assets/Sources/Generated/Sync/Components/Sync.cs new file mode 100644 index 0000000..c93cc2f --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Sync.cs @@ -0,0 +1,14 @@ +using NetStack.Serialization; + +public partial class Sync : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(4); + + } + + public void Deserialize(BitBuffer bitBuffer) + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Components/Sync.cs.meta b/Assets/Sources/Generated/Sync/Components/Sync.cs.meta new file mode 100644 index 0000000..fdf0b9e --- /dev/null +++ b/Assets/Sources/Generated/Sync/Components/Sync.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66939820ae6c67a4fb03a0db93006c95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Compressors.meta b/Assets/Sources/Generated/Sync/Compressors.meta new file mode 100644 index 0000000..f634b5d --- /dev/null +++ b/Assets/Sources/Generated/Sync/Compressors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f3a9b44acca2ffe41a9b8dfb4e8eabc4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs b/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs new file mode 100644 index 0000000..15af4f5 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs @@ -0,0 +1,9 @@ +using NetStack.Compression; + +public static class SyncCompressors +{ + + static SyncCompressors() + { + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs.meta b/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs.meta new file mode 100644 index 0000000..669bb04 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Compressors/SyncCompressors.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00f6375f03eaa834ea120f0b31ad8ec1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Feature.meta b/Assets/Sources/Generated/Sync/Feature.meta new file mode 100644 index 0000000..449e007 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Feature.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e9cbba561e89a449a0d8ae0e0e567b9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs b/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs new file mode 100644 index 0000000..9c6ec1a --- /dev/null +++ b/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs @@ -0,0 +1,22 @@ +using Sources.Networking.Server.StateCapture; + +public class ServerStateCaptureFeature : Feature +{ + public ServerStateCaptureFeature(Contexts contexts, Services services) + { + Add(new ServerCaptureChangedIdSystem(contexts, services)); + Add(new ServerCaptureRemovedIdSystem(contexts, services)); + Add(new ServerCaptureChangedCharacterSystem(contexts, services)); + Add(new ServerCaptureRemovedCharacterSystem(contexts, services)); + Add(new ServerCaptureChangedControlledBySystem(contexts, services)); + Add(new ServerCaptureRemovedControlledBySystem(contexts, services)); + Add(new ServerCaptureChangedConnectionSystem(contexts, services)); + Add(new ServerCaptureRemovedConnectionSystem(contexts, services)); + Add(new ServerCaptureChangedSyncSystem(contexts, services)); + Add(new ServerCaptureRemovedSyncSystem(contexts, services)); + + Add(new ServerCreateWorldStateSystem(contexts)); + Add(new ServerCaptureCreatedEntitiesSystem(contexts, services)); + Add(new ServerCaptureRemovedEntitiesSystem(contexts, services)); + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs.meta b/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs.meta new file mode 100644 index 0000000..42fbe42 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Feature/ServerStateCaptureFeature.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b5b518ef5ef748f4a98a98889c2b8aba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Utility.meta b/Assets/Sources/Generated/Sync/Utility.meta new file mode 100644 index 0000000..fbad2c9 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Utility.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd8a42ea3ddabbf41a3e9afe3a83167f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs b/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs new file mode 100644 index 0000000..2c16e6f --- /dev/null +++ b/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs @@ -0,0 +1,73 @@ +using NetStack.Serialization; + +public static class PackEntityUtility +{ + public static void Pack(GameEntity e, BitBuffer buffer) + { + ushort counter = 0; + + var hasId = false; + if(e.hasId) + { + hasId = true; + counter++; + } + + var hasCharacter = false; + if(e.isCharacter) + { + hasCharacter = true; + counter++; + } + + var hasControlledBy = false; + if(e.hasControlledBy) + { + hasControlledBy = true; + counter++; + } + + var hasConnection = false; + if(e.hasConnection) + { + hasConnection = true; + counter++; + } + + var hasSync = false; + if(e.isSync) + { + hasSync = true; + counter++; + } + + + buffer.AddUShort(counter); + + if (hasId) + { + e.id.Serialize(buffer); + } + + if (hasCharacter) + { + buffer.AddUShort(1); + } + + if (hasControlledBy) + { + e.controlledBy.Serialize(buffer); + } + + if (hasConnection) + { + e.connection.Serialize(buffer); + } + + if (hasSync) + { + buffer.AddUShort(4); + } + + } +} diff --git a/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs.meta b/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs.meta new file mode 100644 index 0000000..0052c6c --- /dev/null +++ b/Assets/Sources/Generated/Sync/Utility/PackEntityUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d11314fa33b50b649882f5d3abff425d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs b/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs new file mode 100644 index 0000000..d80b6c8 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs @@ -0,0 +1,175 @@ +using System.Text; +using NetStack.Serialization; +using Sources.Tools; + +public static class UnpackEntityUtility +{ + public static void CreateEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var addedComponents = new StringBuilder(128); + + var e = game.CreateEntity(); + + var componentsCount = buffer.ReadUShort(); + + for (int j = 0; j < componentsCount; j++) + { + var componentId = buffer.ReadUShort(); + + switch (componentId) + { + case 0: + { + addedComponents.Append(" Id "); + var lookup = GameComponentsLookup.Id; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.AddComponent(lookup, comp); + } + break; + case 1: + { + addedComponents.Append(" Character "); + e.isCharacter = true; + } + break; + case 2: + { + addedComponents.Append(" ControlledBy "); + var lookup = GameComponentsLookup.ControlledBy; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.AddComponent(lookup, comp); + } + break; + case 3: + { + addedComponents.Append(" Connection "); + var lookup = GameComponentsLookup.Connection; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.AddComponent(lookup, comp); + } + break; + case 4: + { + addedComponents.Append(" Sync "); + e.isSync = true; + } + break; + } + } + Logger.I.Log("UnpackEntityUtility", $" Entity-{e.id.Value}: created - ({addedComponents})"); + } + } + + public static void ChangeComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { + case 0: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed Id component"); + var lookup = GameComponentsLookup.Id; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.ReplaceComponent(lookup, comp); + } + break; + case 1: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed Character component"); + e.isCharacter = true; + } + break; + case 2: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed ControlledBy component"); + var lookup = GameComponentsLookup.ControlledBy; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.ReplaceComponent(lookup, comp); + } + break; + case 3: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed Connection component"); + var lookup = GameComponentsLookup.Connection; + var comp = e.CreateComponent(lookup); + comp.Deserialize(buffer); + e.ReplaceComponent(lookup, comp); + } + break; + case 4: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed Sync component"); + e.isSync = true; + } + break; + } + } + } + + public static void RemoveComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { + case 0: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed Id component"); + e.RemoveId(); + } + break; + case 1: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed Character component"); + e.isCharacter = false; + } + break; + case 2: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed ControlledBy component"); + e.RemoveControlledBy(); + } + break; + case 3: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed Connection component"); + e.RemoveConnection(); + } + break; + case 4: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed Sync component"); + e.isSync = false; + } + break; + } + } + } + + public static void RemoveEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var id = buffer.ReadUShort(); + var e = game.GetEntityWithId(id); + e.isDestroyed = true; + Logger.I.Log("UnpackEntityUtility", $" Entity-{id}: is removed"); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs.meta b/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs.meta new file mode 100644 index 0000000..865ae76 --- /dev/null +++ b/Assets/Sources/Generated/Sync/Utility/UnpackEntityUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6154746269b648de8fd6f7349120d4ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Networking.meta b/Assets/Sources/Networking.meta new file mode 100644 index 0000000..777c5e5 --- /dev/null +++ b/Assets/Sources/Networking.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8628921752ea4af09fa81cf6d4a894a6 +timeCreated: 1557590894 \ No newline at end of file diff --git a/Assets/Sources/Networking/Client.meta b/Assets/Sources/Networking/Client.meta new file mode 100644 index 0000000..ece6686 --- /dev/null +++ b/Assets/Sources/Networking/Client.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3e900997d0904237bc0be96e0fe54d78 +timeCreated: 1557679839 \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientCommandHandler.cs b/Assets/Sources/Networking/Client/ClientCommandHandler.cs new file mode 100644 index 0000000..c725c20 --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientCommandHandler.cs @@ -0,0 +1,49 @@ +using ENet; +using Sources.Tools; + +namespace Sources.Networking.Client +{ + public class ClientCommandHandler : IClientHandler + { + private readonly ClientNetworkSystem _client; + private readonly GameContext _game; + + public ClientCommandHandler(GameContext game, ClientNetworkSystem client) + { + _game = game; + _client = client; + } + + public void HandleChatMessageCommand(ref ServerChatMessageCommand command) + { + Logger.I.Log(this, $"Client-{command.Sender}: {command.Message}"); + } + + public void HandleGrantedIdCommand(ref ServerGrantedIdCommand command) + { + Logger.I.Log(this, $"Got ID - {command.Id}"); + _client.State = ClientState.Connected; + _client.ConnectionId.IsSet = true; + _client.ConnectionId.Id = command.Id; + } + + public void HandleSetTickrateCommand(ref ServerSetTickrateCommand command) + { + _client.TickRate = command.Tickrate; + } + + public void OnConnected(Peer peer) + { + Logger.I.Log(this, $"Connected to server {peer.IP} {peer.Port}, waiting for ID"); + _client.State = ClientState.WaitingForId; + _client.ServerConnection = peer; + } + + public void OnDisconnected(Peer peer) + { + Logger.I.Log(this, "Disconnected from server"); + _client.EnqueueRequest(NetworkThreadRequest.Cleanup); + _client.CleanupState(); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientCommandHandler.cs.meta b/Assets/Sources/Networking/Client/ClientCommandHandler.cs.meta new file mode 100644 index 0000000..06f5c0e --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientCommandHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 711fefb517cf44708e3d0e7c54e5a55e +timeCreated: 1557920852 \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientNetworkFeature.cs b/Assets/Sources/Networking/Client/ClientNetworkFeature.cs new file mode 100644 index 0000000..310d882 --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientNetworkFeature.cs @@ -0,0 +1,10 @@ +namespace Sources.Networking.Client +{ + public class ClientNetworkFeature : Feature + { + public ClientNetworkFeature(Contexts contexts, Services services) + { + Add(new ClientSendPacketSystem(services)); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientNetworkFeature.cs.meta b/Assets/Sources/Networking/Client/ClientNetworkFeature.cs.meta new file mode 100644 index 0000000..7496322 --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientNetworkFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7fc8981c089f455899ecba9292962692 +timeCreated: 1557679967 \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientNetworkSystem.cs b/Assets/Sources/Networking/Client/ClientNetworkSystem.cs new file mode 100644 index 0000000..40ea8ef --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientNetworkSystem.cs @@ -0,0 +1,410 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; +using DisruptorUnity3d; +using ENet; +using Entitas; +using NetStack.Serialization; +using Sources.Networking.Server; +using Sources.Tools; + +namespace Sources.Networking.Client +{ + public class ClientNetworkSystem : IExecuteSystem, ITearDownSystem + { + public ClientState State = ClientState.Disconnected; + public ConnectionId ConnectionId; + public Peer ServerConnection; + + public ushort TickRate = 20; + public int PanicCleanupTarget = 6; + public int PanicStateCount = 10; + + public int StatesCount => _states.Count; + + private readonly GameContext _game; + private readonly ClientCommandHandler _handler; + + private readonly Thread _networkThread; + private readonly RingBuffer _eventsToHandle = new RingBuffer(1024); + private readonly RingBuffer _sendData = new RingBuffer(64); + private readonly RingBuffer _responses = new RingBuffer(8); + private readonly RingBuffer _requests = new RingBuffer(8); + private Address _address; + + private readonly Queue _states = new Queue(124); + + private readonly IGroup _syncGroup; + private readonly List _syncBuffer = new List(ServerNetworkSystem.MaxPlayers); + + public ushort EnqueuedCommandCount; + public readonly BitBuffer ToServer = new BitBuffer(512); + + private readonly BitBuffer _fromServer = new BitBuffer(512); + + private bool _firstPacket = true; + private Host _host = new Host(); + + private readonly PacketFreeCallback _freeCallback = packet => { Marshal.FreeHGlobal(packet.Data); }; + private readonly IntPtr _cachedFreeCallback; + + public ClientNetworkSystem(Contexts contexts) + { + Logger.I.Log(this, "Created"); + + _game = contexts.game; + _host.Create(); + _handler = new ClientCommandHandler(_game, this); + ConnectionId.IsSet = false; + + _networkThread = NetworkThread(); + _networkThread.Start(); + _syncGroup = _game.GetGroup(GameMatcher.Sync); + _cachedFreeCallback = Marshal.GetFunctionPointerForDelegate(_freeCallback); + } + + public void Execute() + { + if (_states.Count > PanicStateCount) + { + //Catchup after lag + while (_states.Count > PanicCleanupTarget) + { + var state = _states.Dequeue(); + ExecuteState(state); + } + } + else if (_states.Count > 0) + { + var state = _states.Dequeue(); + ExecuteState(state); + } + } + + public void TearDown() + { + if (State == ClientState.Connected) _requests.Enqueue(NetworkThreadRequest.Disconnect); + + Thread.Sleep(20); + _networkThread.Abort(); + } + + + private Thread NetworkThread() + { + return new Thread(() => + { + while (true) + { + while (_sendData.TryDequeue(out var data)) + { + var packet = new Packet(); + packet.Create(data.Data, data.Length, PacketFlags.Reliable | PacketFlags.NoAllocate); + packet.SetFreeCallback(_cachedFreeCallback); + data.Peer.Send(0, ref packet); + } + + while (_requests.TryDequeue(out var request)) + switch (request) + { + case NetworkThreadRequest.Connect: + try + { + _host.Connect(_address, 2); + } + catch (Exception e) + { + Logger.I.Log(this, e.Message); + _host = new Host(); + _host.Create(); + _responses.Enqueue(NetworkThreadResponse.ConnectFailure); + } + + break; + case NetworkThreadRequest.Disconnect: + ServerConnection.DisconnectNow(0); + _host.Flush(); + _host.Dispose(); + _host = new Host(); + _host.Create(); + _responses.Enqueue(NetworkThreadResponse.Disconnected); + break; + case NetworkThreadRequest.Cleanup: + _host = new Host(); + _host.Create(); + break; + case NetworkThreadRequest.CancelConnect: + _host.Dispose(); + _host = new Host(); + _host.Create(); + _responses.Enqueue(NetworkThreadResponse.ConnectCancelled); + break; + } + + if (!_host.IsSet) Thread.Sleep(15); + if (_host.Service(15, out var @event) > 0) + switch (@event.Type) + { + case EventType.Connect: + case EventType.Disconnect: + case EventType.Timeout: + _eventsToHandle.Enqueue(new ReceivedEvent + {EventType = @event.Type, Peer = @event.Peer}); + break; + case EventType.Receive: + unsafe + { + var length = @event.Packet.Length; + var newPtr = Marshal.AllocHGlobal(length); + Buffer.MemoryCopy(@event.Packet.Data.ToPointer(), newPtr.ToPointer(), length, + length); + _eventsToHandle.Enqueue(new ReceivedEvent + {Data = newPtr, Peer = @event.Peer, EventType = EventType.Receive}); + } + + break; + } + } + }); + } + + public void Connect(Address address) + { + if (State != ClientState.Disconnected) return; + + Logger.I.Log(this, $"Connecting to {address.GetIP()}:{address.Port}"); + State = ClientState.Connecting; + + _address = address; + _requests.Enqueue(NetworkThreadRequest.Connect); + } + + public void Disconnect() + { + if (State != ClientState.Connected) return; + + Logger.I.Log(this, "Disconnecting"); + + State = ClientState.Disconnecting; + _requests.Enqueue(NetworkThreadRequest.Disconnect); + } + + public void EnqueueCommand(T command) where T : ICommand, IClientCommand + { + Logger.I.Log(this, $"Enqueued {command.GetType().Name}"); + + EnqueuedCommandCount++; + command.Serialize(ToServer); + } + + public void EnqueueSendData(SendData data) + { + _sendData.Enqueue(data); + } + + public void EnqueueRequest(NetworkThreadRequest request) + { + _requests.Enqueue(request); + } + + public void UpdateNetwork() + { + while (_responses.TryDequeue(out var response)) + switch (response) + { + case NetworkThreadResponse.ConnectFailure: + State = ClientState.Disconnected; + break; + case NetworkThreadResponse.Disconnected: + CleanupState(); + Logger.I.Log(this, "Disconnected"); + break; + case NetworkThreadResponse.ConnectCancelled: + CleanupState(); + Logger.I.Log(this, "Connect cancelled"); + break; + } + + if (State == ClientState.Disconnected) return; + while (_eventsToHandle.TryDequeue(out var @event)) + switch (@event.EventType) + { + case EventType.Connect: + _handler.OnConnected(@event.Peer); + break; + case EventType.Disconnect: + _handler.OnDisconnected(@event.Peer); + break; + case EventType.Receive: + _states.Enqueue(@event.Data); + break; + case EventType.Timeout: + _handler.OnDisconnected(@event.Peer); + break; + } + } + + private unsafe void ExecuteState(IntPtr state) + { + #region commands + + var commandsHeaderSpan = new ReadOnlySpan(state.ToPointer(), 2); + var commandCount = commandsHeaderSpan[0]; + var commandLength = commandsHeaderSpan[1]; + var cursor = 4; + + if (commandCount > 0) + { + var dataSpan = new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), + commandLength); + _fromServer.Clear(); + _fromServer.FromSpan(ref dataSpan, commandLength); + ClientCommandExecutor.Execute(_handler, _fromServer, commandCount); + cursor += commandLength; + } + + #endregion + + #region created entities + + var createdEntitiesHeaderSpan = + new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), 2); + var createdEntitiesCount = createdEntitiesHeaderSpan[0]; + var createdEntitiesLength = createdEntitiesHeaderSpan[1]; + cursor += 4; + + if (createdEntitiesCount > 0) + { + var dataSpan = new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), + createdEntitiesLength); + _fromServer.Clear(); + _fromServer.FromSpan(ref dataSpan, createdEntitiesLength); + UnpackEntityUtility.CreateEntities(_game, _fromServer, createdEntitiesCount); + cursor += createdEntitiesLength; + } + + #endregion + + if (_firstPacket) + { + _firstPacket = false; + Marshal.FreeHGlobal(state); + return; + } + + #region removed entities + + var removedEntitiesHeaderSpan = + new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), 2); + var removedEntitiesCount = removedEntitiesHeaderSpan[0]; + var removedEntitiesLength = removedEntitiesHeaderSpan[1]; + + cursor += 4; + + if (removedEntitiesCount > 0) + { + var dataSpan = new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), + removedEntitiesLength); + _fromServer.Clear(); + _fromServer.FromSpan(ref dataSpan, removedEntitiesLength); + UnpackEntityUtility.RemoveEntities(_game, _fromServer, removedEntitiesCount); + cursor += removedEntitiesLength; + } + + #endregion + + #region removed components + + var removedComponentsHeaderSpan = + new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), 2); + var removedComponentsCount = removedComponentsHeaderSpan[0]; + var removedComponentsLength = removedComponentsHeaderSpan[1]; + cursor += 4; + + if (removedComponentsCount > 0) + { + var dataSpan = new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), + removedComponentsLength); + _fromServer.Clear(); + _fromServer.FromSpan(ref dataSpan, removedComponentsLength); + UnpackEntityUtility.RemoveComponents(_game, _fromServer, removedComponentsCount); + cursor += removedComponentsLength; + } + + #endregion + + #region changed components + + var changedComponentsHeaderSpan = + new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), 2); + var changedComponentsCount = changedComponentsHeaderSpan[0]; + var changedComponentsLength = changedComponentsHeaderSpan[1]; + cursor += 4; + + if (changedComponentsCount > 0) + { + var dataSpan = new ReadOnlySpan(IntPtr.Add(state, cursor).ToPointer(), + changedComponentsLength); + _fromServer.Clear(); + _fromServer.FromSpan(ref dataSpan, changedComponentsLength); + UnpackEntityUtility.ChangeComponents(_game, _fromServer, changedComponentsCount); + } + + #endregion + + Marshal.FreeHGlobal(state); + } + + public void CleanupState() + { + while (_eventsToHandle.TryDequeue(out _)) + { + } + + while (_states.Count > 0) Marshal.FreeHGlobal(_states.Dequeue()); + + State = ClientState.Disconnected; + ServerConnection = new Peer(); + ConnectionId.IsSet = false; + _firstPacket = true; + + _syncGroup.GetEntities(_syncBuffer); + foreach (var e in _syncBuffer) e.isDestroyed = true; + + EnqueuedCommandCount = 0; + ToServer.Clear(); + _fromServer.Clear(); + } + } + + public enum NetworkThreadRequest + { + Connect, + CancelConnect, + Disconnect, + Cleanup + } + + public enum NetworkThreadResponse + { + ConnectCancelled, + ConnectFailure, + Disconnected + } + + public enum ClientState + { + Disconnected, + Connecting, + WaitingForId, + Connected, + Disconnecting + } + + public struct ConnectionId + { + public bool IsSet; + public ushort Id; + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientNetworkSystem.cs.meta b/Assets/Sources/Networking/Client/ClientNetworkSystem.cs.meta new file mode 100644 index 0000000..e56e2f3 --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientNetworkSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2511d306cda14fd195510160fd719bb6 +timeCreated: 1557606536 \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs b/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs new file mode 100644 index 0000000..f6d2c4d --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs @@ -0,0 +1,51 @@ +using System; +using System.Runtime.InteropServices; +using Entitas; + +namespace Sources.Networking.Client +{ + public class ClientSendPacketSystem : IExecuteSystem + { + private readonly ClientNetworkSystem _client; + + private readonly byte[] _data = new byte[2048]; + + public ClientSendPacketSystem(Services services) + { + _client = services.ClientSystem; + } + + public unsafe void Execute() + { + if (_client.State != ClientState.Connected) return; + + var commandLength = _client.ToServer.Length; + var commandCount = _client.EnqueuedCommandCount; + var totalLength = commandLength + 4; + + fixed (byte* destination = &_data[0]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = commandCount; + shortsSpan[1] = (ushort) commandLength; + } + + if (commandCount > 0) + { + _client.ToServer.ToArray(_data, 4); + + _client.EnqueuedCommandCount = 0; + } + + var newPtr = Marshal.AllocHGlobal(totalLength); + fixed (byte* source = &_data[0]) + { + Buffer.MemoryCopy(source, newPtr.ToPointer(), totalLength, totalLength); + } + + _client.EnqueueSendData(new SendData + {Data = newPtr, Length = totalLength, Peer = _client.ServerConnection}); + _client.ToServer.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs.meta b/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs.meta new file mode 100644 index 0000000..f1164b2 --- /dev/null +++ b/Assets/Sources/Networking/Client/ClientSendPacketSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9dbd5bafb2d242e7b93484f512438e12 +timeCreated: 1557667194 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components.meta b/Assets/Sources/Networking/Components.meta new file mode 100644 index 0000000..f3ff7dc --- /dev/null +++ b/Assets/Sources/Networking/Components.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 39b1155173d149489cbc83182cb66c64 +timeCreated: 1557679891 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/ClientDataBuffer.cs b/Assets/Sources/Networking/Components/ClientDataBuffer.cs new file mode 100644 index 0000000..d7d9c5d --- /dev/null +++ b/Assets/Sources/Networking/Components/ClientDataBuffer.cs @@ -0,0 +1,9 @@ +using Entitas; +using NetStack.Serialization; + +[Game] +public class ClientDataBuffer : IComponent +{ + public ushort CommandCount; + public BitBuffer Value; +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/ClientDataBuffer.cs.meta b/Assets/Sources/Networking/Components/ClientDataBuffer.cs.meta new file mode 100644 index 0000000..a87fc1c --- /dev/null +++ b/Assets/Sources/Networking/Components/ClientDataBuffer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c938462d022d4ab7931f92c7cbf4f1b5 +timeCreated: 1557608203 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/Connection.cs b/Assets/Sources/Networking/Components/Connection.cs new file mode 100644 index 0000000..a4bb4da --- /dev/null +++ b/Assets/Sources/Networking/Components/Connection.cs @@ -0,0 +1,15 @@ +using Codegen.CodegenAttributes; +using Entitas; +using Entitas.CodeGeneration.Attributes; + +[Game] +[Sync] +public partial class Connection : IComponent +{ + [PrimaryEntityIndex] public ushort Id; + + public Connection() + { + Id = ushort.MaxValue; + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/Connection.cs.meta b/Assets/Sources/Networking/Components/Connection.cs.meta new file mode 100644 index 0000000..a4f382f --- /dev/null +++ b/Assets/Sources/Networking/Components/Connection.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8b1b467438dc4159b0ed0ff36224ffcd +timeCreated: 1557590914 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/ConnectionPeer.cs b/Assets/Sources/Networking/Components/ConnectionPeer.cs new file mode 100644 index 0000000..9c3b0df --- /dev/null +++ b/Assets/Sources/Networking/Components/ConnectionPeer.cs @@ -0,0 +1,8 @@ +using ENet; +using Entitas; + +[Game] +public class ConnectionPeer : IComponent +{ + public Peer Value; +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/ConnectionPeer.cs.meta b/Assets/Sources/Networking/Components/ConnectionPeer.cs.meta new file mode 100644 index 0000000..5be0184 --- /dev/null +++ b/Assets/Sources/Networking/Components/ConnectionPeer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 88e76b210855494a86f2fcac25bc146f +timeCreated: 1557610050 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/RequiresWorldState.cs b/Assets/Sources/Networking/Components/RequiresWorldState.cs new file mode 100644 index 0000000..86cf03c --- /dev/null +++ b/Assets/Sources/Networking/Components/RequiresWorldState.cs @@ -0,0 +1,6 @@ +using Entitas; + +[Game] +public class RequiresWorldState : IComponent +{ +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/RequiresWorldState.cs.meta b/Assets/Sources/Networking/Components/RequiresWorldState.cs.meta new file mode 100644 index 0000000..5157a3a --- /dev/null +++ b/Assets/Sources/Networking/Components/RequiresWorldState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: db0d538d4f034dc7a77e54a8f4d8eae2 +timeCreated: 1557701494 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/Sync.cs b/Assets/Sources/Networking/Components/Sync.cs new file mode 100644 index 0000000..957801f --- /dev/null +++ b/Assets/Sources/Networking/Components/Sync.cs @@ -0,0 +1,8 @@ +using Codegen.CodegenAttributes; +using Entitas; + +[Game] +[Sync] +public partial class Sync : IComponent +{ +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/Sync.cs.meta b/Assets/Sources/Networking/Components/Sync.cs.meta new file mode 100644 index 0000000..4ee648f --- /dev/null +++ b/Assets/Sources/Networking/Components/Sync.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4e2864c387fd4813becc0be45fef02c5 +timeCreated: 1557591290 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/WasSynced.cs b/Assets/Sources/Networking/Components/WasSynced.cs new file mode 100644 index 0000000..f3890c1 --- /dev/null +++ b/Assets/Sources/Networking/Components/WasSynced.cs @@ -0,0 +1,6 @@ +using Entitas; + +[Game] +public class WasSynced : IComponent +{ +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/WasSynced.cs.meta b/Assets/Sources/Networking/Components/WasSynced.cs.meta new file mode 100644 index 0000000..3d88c28 --- /dev/null +++ b/Assets/Sources/Networking/Components/WasSynced.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 20e41a507e0c404eb0300f3520a35f77 +timeCreated: 1557682237 \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/WorldState.cs b/Assets/Sources/Networking/Components/WorldState.cs new file mode 100644 index 0000000..4f59f2e --- /dev/null +++ b/Assets/Sources/Networking/Components/WorldState.cs @@ -0,0 +1,11 @@ +using Entitas; +using Entitas.CodeGeneration.Attributes; +using NetStack.Serialization; + +[Game] +[Unique] +public class WorldState : IComponent +{ + public ushort EntityCount; + public BitBuffer Buffer; +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Components/WorldState.cs.meta b/Assets/Sources/Networking/Components/WorldState.cs.meta new file mode 100644 index 0000000..b9a23a1 --- /dev/null +++ b/Assets/Sources/Networking/Components/WorldState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6b72351fcf8044758fd95038d367d1df +timeCreated: 1557701866 \ No newline at end of file diff --git a/Assets/Sources/Networking/INetworkComponent.cs b/Assets/Sources/Networking/INetworkComponent.cs new file mode 100644 index 0000000..4b5cd72 --- /dev/null +++ b/Assets/Sources/Networking/INetworkComponent.cs @@ -0,0 +1,7 @@ +using NetStack.Serialization; + +public interface INetworkComponent +{ + void Serialize(BitBuffer bitbuffer); + void Deserialize(BitBuffer bitBuffer); +} \ No newline at end of file diff --git a/Assets/Sources/Networking/INetworkComponent.cs.meta b/Assets/Sources/Networking/INetworkComponent.cs.meta new file mode 100644 index 0000000..9ec600a --- /dev/null +++ b/Assets/Sources/Networking/INetworkComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c3772c493a234b5eb82503fcc9b9ebff +timeCreated: 1557593018 \ No newline at end of file diff --git a/Assets/Sources/Networking/ReceivedEvent.cs b/Assets/Sources/Networking/ReceivedEvent.cs new file mode 100644 index 0000000..5abdc2e --- /dev/null +++ b/Assets/Sources/Networking/ReceivedEvent.cs @@ -0,0 +1,9 @@ +using System; +using ENet; + +public struct ReceivedEvent +{ + public EventType EventType; + public Peer Peer; + public IntPtr Data; +} \ No newline at end of file diff --git a/Assets/Sources/Networking/ReceivedEvent.cs.meta b/Assets/Sources/Networking/ReceivedEvent.cs.meta new file mode 100644 index 0000000..14b5a1d --- /dev/null +++ b/Assets/Sources/Networking/ReceivedEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ea1afc3b274b4649b6840ddef3df96e7 +timeCreated: 1558007850 \ No newline at end of file diff --git a/Assets/Sources/Networking/SendData.cs b/Assets/Sources/Networking/SendData.cs new file mode 100644 index 0000000..171d763 --- /dev/null +++ b/Assets/Sources/Networking/SendData.cs @@ -0,0 +1,9 @@ +using System; +using ENet; + +public struct SendData +{ + public Peer Peer; + public IntPtr Data; + public int Length; +} \ No newline at end of file diff --git a/Assets/Sources/Networking/SendData.cs.meta b/Assets/Sources/Networking/SendData.cs.meta new file mode 100644 index 0000000..bdb37d4 --- /dev/null +++ b/Assets/Sources/Networking/SendData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 281a9491ad4044a2b643bb25a4104b2a +timeCreated: 1557910591 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server.meta b/Assets/Sources/Networking/Server.meta new file mode 100644 index 0000000..0ea35a3 --- /dev/null +++ b/Assets/Sources/Networking/Server.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8edb8aff7dc465cba661cbd92a3b409 +timeCreated: 1557679843 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/DisconnectData.cs b/Assets/Sources/Networking/Server/DisconnectData.cs new file mode 100644 index 0000000..f81b9df --- /dev/null +++ b/Assets/Sources/Networking/Server/DisconnectData.cs @@ -0,0 +1,9 @@ +using ENet; + +namespace Sources.Networking.Server +{ + public struct DisconnectData + { + public Peer Peer; + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/DisconnectData.cs.meta b/Assets/Sources/Networking/Server/DisconnectData.cs.meta new file mode 100644 index 0000000..1100401 --- /dev/null +++ b/Assets/Sources/Networking/Server/DisconnectData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1cead76930db413882646a0e89570379 +timeCreated: 1557911339 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerCommandHandler.cs b/Assets/Sources/Networking/Server/ServerCommandHandler.cs new file mode 100644 index 0000000..c7a1876 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerCommandHandler.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using ENet; +using Entitas; +using NetStack.Serialization; +using UnityEngine; +using Logger = Sources.Tools.Logger; + +namespace Sources.Networking.Server +{ + public class ServerCommandHandler : IServerHandler + { + private readonly List _connectionsBuffer = new List(ServerNetworkSystem.MaxPlayers); + + private readonly IGroup _connectionsGroup; + + private readonly GameContext _game; + private readonly ServerNetworkSystem _server; + public ushort CurrentClientId; + + public ServerCommandHandler(GameContext game, ServerNetworkSystem server) + { + _game = game; + _server = server; + _connectionsGroup = _game.GetGroup(GameMatcher.Connection); + } + + public void HandleChatMessageCommand(ref ClientChatMessageCommand command) + { + Logger.I.Log(this, $"Client-{CurrentClientId}: {command.Message}"); + _server.EnqueueCommandForEveryone(new ServerChatMessageCommand + {Message = command.Message, Sender = CurrentClientId}); + } + + public void HandleRequestCharacterCommand(ref ClientRequestCharacterCommand command) + { + var e = _game.GetEntityWithControlledBy(CurrentClientId); + if (e == null) + { + e = _game.CreateEntity(); + e.isSync = true; + e.AddControlledBy(CurrentClientId); + } + else + { + _server.EnqueueCommandForClient(CurrentClientId, + new ServerChatMessageCommand {Message = "You already have one.", Sender = 0}); + } + } + + public void HandleSetTickrateCommand(ref ClientSetTickrateCommand command) + { + _server.TickRate = command.Tickrate; + _server.EnqueueCommandForEveryone(new ServerSetTickrateCommand {Tickrate = command.Tickrate}); + } + + public void OnClientConnected(Peer peer) + { + Logger.I.Log(this, $"Client connected - {peer.ID}"); + + if (_connectionsGroup.count == ServerNetworkSystem.MaxPlayers) + { + _server.EnqueueDisconnectData(new DisconnectData {Peer = peer}); + return; + } + + var id = (ushort) peer.ID; + var e = _game.CreateEntity(); + e.isSync = true; + e.AddConnectionPeer(peer); + e.AddConnection(id); + e.AddClientDataBuffer(0, new BitBuffer(64)); + e.isRequiresWorldState = true; + + _server.EnqueueCommandForClient(id, new ServerGrantedIdCommand {Id = id}); + _server.EnqueueCommandForClient(id, new ServerSetTickrateCommand {Tickrate = _server.TickRate}); + } + + public void OnClientDisconnected(Peer peer) + { + Logger.I.Log(this, $"Client disconnected - {peer.ID}"); + + var e = _game.GetEntityWithConnection((ushort) peer.ID); + + if (e != null) e.isDestroyed = true; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerCommandHandler.cs.meta b/Assets/Sources/Networking/Server/ServerCommandHandler.cs.meta new file mode 100644 index 0000000..732b3ac --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerCommandHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 54d96f5d710d41e0a56e91de18c6e62d +timeCreated: 1557921170 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerNetworkFeature.cs b/Assets/Sources/Networking/Server/ServerNetworkFeature.cs new file mode 100644 index 0000000..d6bc01d --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerNetworkFeature.cs @@ -0,0 +1,11 @@ +namespace Sources.Networking.Server +{ + public class ServerNetworkFeature : Feature + { + public ServerNetworkFeature(Contexts contexts, Services services) + { + Add(new ServerStateCaptureFeature(contexts, services)); + Add(new ServerSendPacketsSystem(contexts, services)); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerNetworkFeature.cs.meta b/Assets/Sources/Networking/Server/ServerNetworkFeature.cs.meta new file mode 100644 index 0000000..e2c1180 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerNetworkFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 53dd3bb061b942f68a5865d75ccb4a53 +timeCreated: 1557680010 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerNetworkSystem.cs b/Assets/Sources/Networking/Server/ServerNetworkSystem.cs new file mode 100644 index 0000000..de4cae4 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerNetworkSystem.cs @@ -0,0 +1,312 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; +using DisruptorUnity3d; +using ENet; +using Entitas; +using NetStack.Serialization; +using Sources.Tools; + +namespace Sources.Networking.Server +{ + public class ServerNetworkSystem : IExecuteSystem, ITearDownSystem + { + public const ushort MaxPlayers = 5; + public ushort TickRate = 20; + + private readonly List _connectionsBuffer = new List(MaxPlayers); + private readonly IGroup _connectionsGroup; + + + private readonly GameContext _game; + private readonly ServerCommandHandler _handler; + + //Data for clients + public ushort ChangedComponentsCount; + public readonly BitBuffer ChangedComponents = new BitBuffer(512); + public ushort CreatedEntitiesCount; + public readonly BitBuffer CreatedEntities = new BitBuffer(512); + public ushort RemovedComponentsCount; + public readonly BitBuffer RemovedComponents = new BitBuffer(512); + public ushort RemovedEntitiesCount; + public readonly BitBuffer RemovedEntities = new BitBuffer(512); + + //Data from clients + private readonly BitBuffer _fromClients = new BitBuffer(512); + + private ushort _currentPeerId; + private Host _host = new Host(); + + private readonly Thread _networkThread; + private readonly RingBuffer _eventsToHandle = new RingBuffer(1024); + private readonly RingBuffer _disconnectData = new RingBuffer(128); + private readonly RingBuffer _sendData = new RingBuffer(1024); + private readonly RingBuffer _responses = new RingBuffer(8); + private readonly RingBuffer _requests = new RingBuffer(8); + private Address _address; + + public ServerState State = ServerState.Stopped; + + private readonly PacketFreeCallback _freeCallback = packet => { Marshal.FreeHGlobal(packet.Data); }; + private readonly IntPtr _cachedFreeCallback; + + public ServerNetworkSystem(Contexts contexts) + { + Logger.I.Log(this, "Created"); + _game = contexts.game; + _handler = new ServerCommandHandler(_game, this); + + _networkThread = NetworkThread(); + _networkThread.Start(); + _connectionsGroup = _game.GetGroup(GameMatcher.Connection); + _cachedFreeCallback = Marshal.GetFunctionPointerForDelegate(_freeCallback); + } + + public void Execute() + { + while (_responses.TryDequeue(out var response)) + switch (response) + { + case NetworkThreadResponse.StartSuccess: + Logger.I.Log(this, "Server is working"); + State = ServerState.Working; + break; + case NetworkThreadResponse.StartFailure: + Logger.I.Log(this, "Server start failed"); + State = ServerState.Stopped; + break; + case NetworkThreadResponse.Stoppoed: + Logger.I.Log(this, "Server is stopped"); + ClearBuffers(); + while (_eventsToHandle.TryDequeue(out _)) + { + } + + State = ServerState.Stopped; + break; + } + + if (State != ServerState.Working) return; + while (_eventsToHandle.TryDequeue(out var @event)) + unsafe + { + switch (@event.EventType) + { + case EventType.Connect: + _handler.OnClientConnected(@event.Peer); + break; + case EventType.Disconnect: + _handler.OnClientDisconnected(@event.Peer); + break; + case EventType.Receive: + _currentPeerId = (ushort) @event.Peer.ID; + _handler.CurrentClientId = _currentPeerId; + + var e = _game.GetEntityWithConnection(_currentPeerId); + if (e == null) + { + Marshal.FreeHGlobal(@event.Data); + break; + } + + var headerSpan = new ReadOnlySpan(@event.Data.ToPointer(), 2); + var commandCount = headerSpan[0]; + var commandLength = headerSpan[1]; + + if (commandCount > 0) + { + var commandsSpan = + new ReadOnlySpan(IntPtr.Add(@event.Data, 4).ToPointer(), commandLength); + _fromClients.Clear(); + _fromClients.FromSpan(ref commandsSpan, commandLength); + ServerCommandExecutor.Execute(_handler, _fromClients, commandCount); + } + + Marshal.FreeHGlobal(@event.Data); + _currentPeerId = ushort.MaxValue; + break; + case EventType.Timeout: + _handler.OnClientDisconnected(@event.Peer); + break; + } + } + } + + public void TearDown() + { + StopServer(); + Thread.Sleep(20); + _networkThread.Abort(); + } + + private Thread NetworkThread() + { + return new Thread(() => + { + while (true) + { + while (_sendData.TryDequeue(out var data)) + { + var packet = new Packet(); + packet.Create(data.Data, data.Length, PacketFlags.Reliable | PacketFlags.NoAllocate); + packet.SetFreeCallback(_cachedFreeCallback); + data.Peer.Send(0, ref packet); + } + + while (_disconnectData.TryDequeue(out var data)) data.Peer.DisconnectNow(0); + + while (_requests.TryDequeue(out var request)) + switch (request) + { + case NetworkThreadRequest.Start: + try + { + _host.Create(_address, MaxPlayers * 2, 2); + _responses.Enqueue(NetworkThreadResponse.StartSuccess); + } + catch (Exception e) + { + Logger.I.Log(this, e.Message); + _host = new Host(); + _responses.Enqueue(NetworkThreadResponse.StartFailure); + } + + break; + case NetworkThreadRequest.Stop: + _host.Flush(); + _host.Dispose(); + _host = new Host(); + _responses.Enqueue(NetworkThreadResponse.Stoppoed); + break; + } + + if (!_host.IsSet) + { + Thread.Sleep(15); + } + else + { + if (_host.Service(15, out var @event) > 0) + switch (@event.Type) + { + case EventType.Connect: + case EventType.Disconnect: + case EventType.Timeout: + _eventsToHandle.Enqueue(new ReceivedEvent + {EventType = @event.Type, Peer = @event.Peer}); + break; + case EventType.Receive: + unsafe + { + var length = @event.Packet.Length; + var newPtr = Marshal.AllocHGlobal(length); + Buffer.MemoryCopy(@event.Packet.Data.ToPointer(), newPtr.ToPointer(), length, + length); + _eventsToHandle.Enqueue(new ReceivedEvent + {Data = newPtr, Peer = @event.Peer, EventType = EventType.Receive}); + } + + break; + } + } + } + }); + } + + public void StartServer(Address address) + { + if (State != ServerState.Stopped) return; + + Logger.I.Log(this, $"Starting server on {address.GetIP()}:{address.Port}"); + State = ServerState.Starting; + + _address = address; + _requests.Enqueue(NetworkThreadRequest.Start); + } + + public void StopServer() + { + if (State != ServerState.Working) return; + + Logger.I.Log(this, "Stopping server"); + State = ServerState.Stopping; + + _connectionsGroup.GetEntities(_connectionsBuffer); + foreach (var e in _connectionsBuffer) + { + _disconnectData.Enqueue(new DisconnectData {Peer = e.connectionPeer.Value}); + e.isDestroyed = true; + } + + _requests.Enqueue(NetworkThreadRequest.Stop); + } + + public void EnqueueCommandForEveryone(T command) where T : ICommand, IServerCommand + { + Logger.I.Log(this, $"Enqueued {command.GetType().Name} for everyone"); + + _connectionsGroup.GetEntities(_connectionsBuffer); + foreach (var e in _connectionsBuffer) + { + e.clientDataBuffer.CommandCount++; + command.Serialize(e.clientDataBuffer.Value); + } + } + + public void EnqueueCommandForClient(ushort connectionId, T command) where T : ICommand, IServerCommand + { + Logger.I.Log(this, $"Enqueued {command.GetType().Name} for {connectionId}"); + + var e = _game.GetEntityWithConnection(connectionId); + if (e != null) + { + e.clientDataBuffer.CommandCount++; + command.Serialize(e.clientDataBuffer.Value); + } + } + + public void EnqueueSendData(SendData data) + { + _sendData.Enqueue(data); + } + + public void EnqueueDisconnectData(DisconnectData data) + { + _disconnectData.Enqueue(data); + } + + public void ClearBuffers() + { + RemovedEntities.Clear(); + RemovedComponents.Clear(); + ChangedComponents.Clear(); + CreatedEntities.Clear(); + ChangedComponentsCount = 0; + CreatedEntitiesCount = 0; + RemovedComponentsCount = 0; + RemovedEntitiesCount = 0; + } + + private enum NetworkThreadRequest + { + Start, + Stop + } + + private enum NetworkThreadResponse + { + StartSuccess, + StartFailure, + Stoppoed + } + } + + public enum ServerState + { + Stopped, + Starting, + Working, + Stopping + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerNetworkSystem.cs.meta b/Assets/Sources/Networking/Server/ServerNetworkSystem.cs.meta new file mode 100644 index 0000000..b0ea567 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerNetworkSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 62c549229098496db745769b9002859a +timeCreated: 1557606653 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs b/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs new file mode 100644 index 0000000..16a8500 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Entitas; + +namespace Sources.Networking.Server +{ + public class ServerSendPacketsSystem : IExecuteSystem + { + private readonly List _connectionsBuffer = new List(ServerNetworkSystem.MaxPlayers); + private readonly IGroup _connectionsGroup; + + private readonly byte[] _data = new byte[2048]; + private readonly GameContext _game; + + private readonly ServerNetworkSystem _server; + + public ServerSendPacketsSystem(Contexts contexts, Services services) + { + _game = contexts.game; + _connectionsGroup = _game.GetGroup(GameMatcher.Connection); + + _server = services.ServerSystem; + } + + public void Execute() + { + if (_server.State != ServerState.Working) return; + + var createdEntitiesLength = _server.CreatedEntities.Length; + var changedComponentsLength = _server.ChangedComponents.Length; + var removedEntitiesLength = _server.RemovedEntities.Length; + var removedComponentsLength = _server.RemovedComponents.Length; + + _connectionsGroup.GetEntities(_connectionsBuffer); + foreach (var e in _connectionsBuffer) + unsafe + { + if (e.isDestroyed) continue; + + if (e.isRequiresWorldState) + { + var cb = e.clientDataBuffer; + var commandLength = cb.Value.Length; + + var commandCount = cb.CommandCount; + fixed (byte* destination = &_data[0]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = commandCount; + shortsSpan[1] = (ushort) commandLength; + } + + var offset = 4; + if (commandCount > 0) + { + cb.Value.ToArray(_data, offset); + offset += commandLength; + + cb.Value.Clear(); + cb.CommandCount = 0; + } + + fixed (byte* destination = &_data[offset]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = _game.worldState.EntityCount; + shortsSpan[1] = (ushort) _game.worldState.Buffer.Length; + } + + offset += 4; + + _game.worldState.Buffer.ToArray(_data, offset); + offset += _game.worldState.Buffer.Length; + + var newPtr = Marshal.AllocHGlobal(offset); + fixed (byte* source = &_data[0]) + { + Buffer.MemoryCopy(source, newPtr.ToPointer(), offset, offset); + } + + _server.EnqueueSendData(new SendData + {Data = newPtr, Length = offset, Peer = e.connectionPeer.Value}); + e.isRequiresWorldState = false; + } + else + { + #region commands + + var cb = e.clientDataBuffer; + var commandLength = cb.Value.Length; + + var commandCount = cb.CommandCount; + fixed (byte* destination = &_data[0]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = commandCount; + shortsSpan[1] = (ushort) commandLength; + } + + var offset = 4; + if (commandCount > 0) + { + cb.Value.ToArray(_data, offset); + offset += commandLength; + + cb.Value.Clear(); + cb.CommandCount = 0; + } + + #endregion + + #region created entities + + fixed (byte* destination = &_data[offset]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = _server.CreatedEntitiesCount; + shortsSpan[1] = (ushort) createdEntitiesLength; + } + + offset += 4; + + if (_server.CreatedEntitiesCount > 0) + { + _server.CreatedEntities.ToArray(_data, offset); + offset += createdEntitiesLength; + } + + #endregion + + #region removed entities + + fixed (byte* destination = &_data[offset]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = _server.RemovedEntitiesCount; + shortsSpan[1] = (ushort) removedEntitiesLength; + } + + offset += 4; + + if (_server.RemovedEntitiesCount > 0) + { + _server.RemovedEntities.ToArray(_data, offset); + offset += removedEntitiesLength; + } + + #endregion + + #region removed components + + fixed (byte* destination = &_data[offset]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = _server.RemovedComponentsCount; + shortsSpan[1] = (ushort) removedComponentsLength; + } + + offset += 4; + + if (_server.RemovedComponentsCount > 0) + { + _server.RemovedComponents.ToArray(_data, offset); + offset += removedComponentsLength; + } + + #endregion + + #region changed components + + fixed (byte* destination = &_data[offset]) + { + var shortsSpan = new Span(destination, 2); + shortsSpan[0] = _server.ChangedComponentsCount; + shortsSpan[1] = (ushort) changedComponentsLength; + } + + offset += 4; + + if (_server.ChangedComponentsCount > 0) + { + _server.ChangedComponents.ToArray(_data, offset); + offset += changedComponentsLength; + } + + #endregion + + var newPtr = Marshal.AllocHGlobal(offset); + fixed (byte* source = &_data[0]) + { + Buffer.MemoryCopy(source, newPtr.ToPointer(), offset, offset); + } + + _server.EnqueueSendData(new SendData + {Data = newPtr, Length = offset, Peer = e.connectionPeer.Value}); + } + } + + _server.ClearBuffers(); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs.meta b/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs.meta new file mode 100644 index 0000000..0376ba9 --- /dev/null +++ b/Assets/Sources/Networking/Server/ServerSendPacketsSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b1abfc0deea34e62b32d8b8a4984f992 +timeCreated: 1557662138 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture.meta b/Assets/Sources/Networking/Server/StateCapture.meta new file mode 100644 index 0000000..dbe6f5d --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2219b80460e641cdbd788dd2c2531291 +timeCreated: 1557694130 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs new file mode 100644 index 0000000..39daeb5 --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using Entitas; + +namespace Sources.Networking.Server.StateCapture +{ + public class ServerCaptureCreatedEntitiesSystem : ReactiveSystem + { + private readonly ServerNetworkSystem _server; + + public ServerCaptureCreatedEntitiesSystem(Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) + { + return context.CreateCollector(GameMatcher.Sync.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return !entity.isDestroyed && !entity.isWasSynced && entity.isSync; + } + + protected override void Execute(List entities) + { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) + { + PackEntityUtility.Pack(e, _server.CreatedEntities); + + e.isWasSynced = true; + _server.CreatedEntitiesCount++; + } + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs.meta b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs.meta new file mode 100644 index 0000000..ab8f764 --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureCreatedEntitiesSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5c9d250729f407d40962d29f5ad76942 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs new file mode 100644 index 0000000..ac9a466 --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using Entitas; + +namespace Sources.Networking.Server.StateCapture +{ + public class ServerCaptureRemovedEntitiesSystem : ReactiveSystem + { + private readonly ServerNetworkSystem _server; + + public ServerCaptureRemovedEntitiesSystem(Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) + { + return context.CreateCollector(GameMatcher.Destroyed.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return entity.isDestroyed && entity.isWasSynced; + } + + protected override void Execute(List entities) + { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) + { + _server.RemovedEntities.AddUShort(e.id.Value); + _server.RemovedEntitiesCount++; + } + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs.meta b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs.meta new file mode 100644 index 0000000..abb6d06 --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCaptureRemovedEntitiesSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ab22de66358b4562ab1dfacc9fd1a468 +timeCreated: 1557694166 \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs b/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs new file mode 100644 index 0000000..f03642c --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using Entitas; +using NetStack.Serialization; +using Sources.Tools; + +namespace Sources.Networking.Server.StateCapture +{ + public class ServerCreateWorldStateSystem : ReactiveSystem + { + private readonly BitBuffer _buffer = new BitBuffer(512); + private readonly GameContext _game; + private readonly List _syncBuffer = new List(256); + + private readonly IGroup _syncGroup; + + public ServerCreateWorldStateSystem(Contexts contexts) : base(contexts.game) + { + _game = contexts.game; + _syncGroup = _game.GetGroup(GameMatcher.Sync); + } + + protected override ICollector GetTrigger(IContext context) + { + return context.CreateCollector(GameMatcher.RequiresWorldState.Added()); + } + + protected override bool Filter(GameEntity entity) + { + return entity.isRequiresWorldState; + } + + protected override void Execute(List entities) + { + Logger.I.Log(this, "Creating world snapshot."); + + var e = _game.CreateEntity(); + e.AddWorldState(0, _buffer); + e.isDestroyed = true; + + _buffer.Clear(); + _syncGroup.GetEntities(_syncBuffer); + + foreach (var entity in _syncBuffer) + if (!entity.isDestroyed) + { + e.worldState.EntityCount++; + PackEntityUtility.Pack(entity, _buffer); + } + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs.meta b/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs.meta new file mode 100644 index 0000000..d8c2741 --- /dev/null +++ b/Assets/Sources/Networking/Server/StateCapture/ServerCreateWorldStateSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 21521ce8d6c84b609fa1d4db6b9777fc +timeCreated: 1557702599 \ No newline at end of file diff --git a/Assets/Sources/ServerFeature.cs b/Assets/Sources/ServerFeature.cs new file mode 100644 index 0000000..d499178 --- /dev/null +++ b/Assets/Sources/ServerFeature.cs @@ -0,0 +1,13 @@ +using Sources.Networking.Server; + +public class ServerFeature : Feature +{ + public ServerFeature(Contexts contexts, Services services) + { + Add(new CommonGameplayFeature(contexts, services)); + Add(new ServerGameplayFeature(contexts, services)); + + Add(new ServerNetworkFeature(contexts, services)); + Add(new CommonGeneratedFeature(contexts)); + } +} \ No newline at end of file diff --git a/Assets/Sources/ServerFeature.cs.meta b/Assets/Sources/ServerFeature.cs.meta new file mode 100644 index 0000000..b3e68d6 --- /dev/null +++ b/Assets/Sources/ServerFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 68907c9f53fd4a678bb3e757095803f6 +timeCreated: 1557775285 \ No newline at end of file diff --git a/Assets/Sources/Services.meta b/Assets/Sources/Services.meta new file mode 100644 index 0000000..886d53e --- /dev/null +++ b/Assets/Sources/Services.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d029187714a45946815a38f821e6594 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Services/Service.cs b/Assets/Sources/Services/Service.cs new file mode 100644 index 0000000..03dc918 --- /dev/null +++ b/Assets/Sources/Services/Service.cs @@ -0,0 +1,9 @@ +public abstract class Service +{ + protected readonly Contexts _contexts; + + public Service(Contexts contexts) + { + _contexts = contexts; + } +} \ No newline at end of file diff --git a/Assets/Sources/Services/Service.cs.meta b/Assets/Sources/Services/Service.cs.meta new file mode 100644 index 0000000..9c0ac25 --- /dev/null +++ b/Assets/Sources/Services/Service.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1a2bcab3e5b1b68448fb8a293d4a9048 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Services/Services.cs b/Assets/Sources/Services/Services.cs new file mode 100644 index 0000000..7237741 --- /dev/null +++ b/Assets/Sources/Services/Services.cs @@ -0,0 +1,8 @@ +using Sources.Networking.Client; +using Sources.Networking.Server; + +public class Services +{ + public ClientNetworkSystem ClientSystem; + public ServerNetworkSystem ServerSystem; +} \ No newline at end of file diff --git a/Assets/Sources/Services/Services.cs.meta b/Assets/Sources/Services/Services.cs.meta new file mode 100644 index 0000000..d63201d --- /dev/null +++ b/Assets/Sources/Services/Services.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b8cdf22fabe8ee04ca2153642376c9a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/Tools.meta b/Assets/Sources/Tools.meta new file mode 100644 index 0000000..37d3647 --- /dev/null +++ b/Assets/Sources/Tools.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: da952fd18276427aae893fc936f7f5d7 +timeCreated: 1557757520 \ No newline at end of file diff --git a/Assets/Sources/Tools/ComponentsLookup.cs b/Assets/Sources/Tools/ComponentsLookup.cs new file mode 100644 index 0000000..c7073cb --- /dev/null +++ b/Assets/Sources/Tools/ComponentsLookup.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace Sources.Tools +{ + public static class ComponentsLookup + { + private static readonly Dictionary _typeToIndex; + + static ComponentsLookup() + { + _typeToIndex = new Dictionary(GameComponentsLookup.componentTypes.Length); + for (var i = 0; i < GameComponentsLookup.componentTypes.Length; i++) + _typeToIndex.Add(GameComponentsLookup.componentTypes[i], i); + } + + public static int GetIndex(Type componentType) + { + return _typeToIndex[componentType]; + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Tools/ComponentsLookup.cs.meta b/Assets/Sources/Tools/ComponentsLookup.cs.meta new file mode 100644 index 0000000..88ad127 --- /dev/null +++ b/Assets/Sources/Tools/ComponentsLookup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 37e2925d738d4eb0af7736a88b05e594 +timeCreated: 1558113160 \ No newline at end of file diff --git a/Assets/Sources/Tools/Logger.cs b/Assets/Sources/Tools/Logger.cs new file mode 100644 index 0000000..3d44adf --- /dev/null +++ b/Assets/Sources/Tools/Logger.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Sources.Tools +{ + public class Logger : MonoBehaviour + { + public static Logger I; + + private readonly object _locker = new object(); + + public int DrawCount = 15; + public List Messages = new List(); + + private void Awake() + { + I = this; + } + + public void Log(object caller, string message) + { + lock (_locker) + { + Messages.Add($"{caller.GetType().Name}: {message}"); + } + } + + public void Log(string caller, string message) + { + lock (_locker) + { + Messages.Add($"{caller}: {message}"); + } + } + + private void OnGUI() + { + GUILayout.Space(100); + GUILayout.BeginVertical(GUI.skin.box); + var counter = 0; + lock (_locker) + { + for (var i = Messages.Count - 1; i >= 0; i--) + { + counter++; + var message = Messages[i]; + GUILayout.Label(message); + if (counter == DrawCount) + break; + } + } + + GUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Assets/Sources/Tools/Logger.cs.meta b/Assets/Sources/Tools/Logger.cs.meta new file mode 100644 index 0000000..95de2e6 --- /dev/null +++ b/Assets/Sources/Tools/Logger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9ab84c5d2ea6467a8a733e98051580b1 +timeCreated: 1557757526 \ No newline at end of file diff --git a/Assets/Sources/Utilities.meta b/Assets/Sources/Utilities.meta new file mode 100644 index 0000000..656705f --- /dev/null +++ b/Assets/Sources/Utilities.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 268eccefd9bf46a688c7fcfe9469661b +timeCreated: 1556835578 \ No newline at end of file diff --git a/Assets/Sources/Utilities/GameObjectUtility.cs b/Assets/Sources/Utilities/GameObjectUtility.cs new file mode 100644 index 0000000..e923107 --- /dev/null +++ b/Assets/Sources/Utilities/GameObjectUtility.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +public static class GameObjectUtility +{ + public static void InitializeObject(GameObject go, GameEntity entity, bool isServer) + { + var view = go.GetComponent(); + view?.InitializeView(entity); + } +} \ No newline at end of file diff --git a/Assets/Sources/Utilities/GameObjectUtility.cs.meta b/Assets/Sources/Utilities/GameObjectUtility.cs.meta new file mode 100644 index 0000000..adaa248 --- /dev/null +++ b/Assets/Sources/Utilities/GameObjectUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1917f25894a84708b48609112df6e38c +timeCreated: 1556835651 \ No newline at end of file diff --git a/Assets/Sources/View.meta b/Assets/Sources/View.meta new file mode 100644 index 0000000..2f60508 --- /dev/null +++ b/Assets/Sources/View.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d8f78974655d41458a3e720d2a562435 +timeCreated: 1556833060 \ No newline at end of file diff --git a/Assets/Sources/View/IView.cs b/Assets/Sources/View/IView.cs new file mode 100644 index 0000000..bb87d8c --- /dev/null +++ b/Assets/Sources/View/IView.cs @@ -0,0 +1,10 @@ +using Entitas; + +public interface IView +{ + void InitializeView(IEntity entity); +} +// CONGRATULATIONS! YOU FOUND THE CAT! +// )\._.,--....,'``. +// .b--. /; _.. \ _\ (`._ ,. +//`=,-,-'~~~ `----(,_..'--(,_..'`-.;.' \ No newline at end of file diff --git a/Assets/Sources/View/IView.cs.meta b/Assets/Sources/View/IView.cs.meta new file mode 100644 index 0000000..1889b09 --- /dev/null +++ b/Assets/Sources/View/IView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fa9f9250015243e41b55b87b12ca75aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/View/Listeners.meta b/Assets/Sources/View/Listeners.meta new file mode 100644 index 0000000..bfae541 --- /dev/null +++ b/Assets/Sources/View/Listeners.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e5486b455899c604b80ee9f53708d8f0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/View/Listeners/IEventListener.cs b/Assets/Sources/View/Listeners/IEventListener.cs new file mode 100644 index 0000000..3310cbb --- /dev/null +++ b/Assets/Sources/View/Listeners/IEventListener.cs @@ -0,0 +1,5 @@ +public interface IEventListener +{ + bool enabled { get; set; } + void RegisterListeners(GameEntity entity); +} \ No newline at end of file diff --git a/Assets/Sources/View/Listeners/IEventListener.cs.meta b/Assets/Sources/View/Listeners/IEventListener.cs.meta new file mode 100644 index 0000000..40c8a3e --- /dev/null +++ b/Assets/Sources/View/Listeners/IEventListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f9e58e7d841f974c9a93700718f790a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sources/View/UnityView.cs b/Assets/Sources/View/UnityView.cs new file mode 100644 index 0000000..88fa8f4 --- /dev/null +++ b/Assets/Sources/View/UnityView.cs @@ -0,0 +1,25 @@ +using Entitas; +using Entitas.Unity; +using UnityEngine; + +public class UnityView : MonoBehaviour, IView, IDestroyedListener +{ + private GameEntity _entity; + + public void OnDestroyed(GameEntity entity) + { +#if UNITY_EDITOR + gameObject.Unlink(); +#endif + Destroy(gameObject); + } + + public void InitializeView(IEntity entity) + { + _entity = (GameEntity) entity; + _entity.AddDestroyedListener(this); +#if UNITY_EDITOR + gameObject.Link(entity); +#endif + } +} \ No newline at end of file diff --git a/Assets/Sources/View/UnityView.cs.meta b/Assets/Sources/View/UnityView.cs.meta new file mode 100644 index 0000000..2185e72 --- /dev/null +++ b/Assets/Sources/View/UnityView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0f3c779ae94ad044b925a386acd60e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Entitas.properties b/Entitas.properties new file mode 100644 index 0000000..61dc4a2 --- /dev/null +++ b/Entitas.properties @@ -0,0 +1,3 @@ +Entitas.VisualDebugging.Unity.Editor.SystemWarningThreshold = 5 +Entitas.VisualDebugging.Unity.Editor.DefaultInstanceCreatorFolderPath = Assets/Editor/DefaultInstanceCreator +Entitas.VisualDebugging.Unity.Editor.TypeDrawerFolderPath = Assets/Editor/TypeDrawer diff --git a/Generators/Generators/Generators/Compressors/CompressorsGenerator.cs b/Generators/Generators/Generators/Compressors/CompressorsGenerator.cs new file mode 100644 index 0000000..ee9151f --- /dev/null +++ b/Generators/Generators/Generators/Compressors/CompressorsGenerator.cs @@ -0,0 +1,554 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Compressors +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class CompressorsGenerator : CompressorsGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using NetStack.Compression;\r\n\r\npublic static class "); + + #line 9 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Prefix)); + + #line default + #line hidden + this.Write("Compressors\r\n{\r\n"); + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + +for (int i = 0; i < Mins.Length; i++) +{ + var name = CompressorNames[i]; + + + #line default + #line hidden + this.Write("\tpublic static readonly BoundedRange "); + + #line 16 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Compressor;\r\n\t"); + + #line 17 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + +} + + + #line default + #line hidden + this.Write(" \r\n static "); + + #line 21 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Prefix)); + + #line default + #line hidden + this.Write("Compressors()\r\n {\r\n"); + + #line 23 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + +for (int i = 0; i < Mins.Length; i++) +{ + var name = CompressorNames[i]; + var min = Mins[i]; + var max = Maxs[i]; + var precision = Precisions[i]; + + + #line default + #line hidden + this.Write("\t "); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Compressor = new BoundedRange("); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(min)); + + #line default + #line hidden + this.Write(", "); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(max)); + + #line default + #line hidden + this.Write(", "); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(precision)); + + #line default + #line hidden + this.Write("f);\r\n\t"); + + #line 32 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + +} + + + #line default + #line hidden + this.Write(" }\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Compressors\CompressorsGenerator.tt" + +private string _PrefixField; + +/// +/// Access the Prefix parameter of the template. +/// +private string Prefix +{ + get + { + return this._PrefixField; + } +} + +private string[] _CompressorNamesField; + +/// +/// Access the CompressorNames parameter of the template. +/// +private string[] CompressorNames +{ + get + { + return this._CompressorNamesField; + } +} + +private float[] _MinsField; + +/// +/// Access the Mins parameter of the template. +/// +private float[] Mins +{ + get + { + return this._MinsField; + } +} + +private float[] _MaxsField; + +/// +/// Access the Maxs parameter of the template. +/// +private float[] Maxs +{ + get + { + return this._MaxsField; + } +} + +private float[] _PrecisionsField; + +/// +/// Access the Precisions parameter of the template. +/// +private float[] Precisions +{ + get + { + return this._PrecisionsField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool PrefixValueAcquired = false; +if (this.Session.ContainsKey("Prefix")) +{ + this._PrefixField = ((string)(this.Session["Prefix"])); + PrefixValueAcquired = true; +} +if ((PrefixValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Prefix"); + if ((data != null)) + { + this._PrefixField = ((string)(data)); + } +} +bool CompressorNamesValueAcquired = false; +if (this.Session.ContainsKey("CompressorNames")) +{ + this._CompressorNamesField = ((string[])(this.Session["CompressorNames"])); + CompressorNamesValueAcquired = true; +} +if ((CompressorNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("CompressorNames"); + if ((data != null)) + { + this._CompressorNamesField = ((string[])(data)); + } +} +bool MinsValueAcquired = false; +if (this.Session.ContainsKey("Mins")) +{ + this._MinsField = ((float[])(this.Session["Mins"])); + MinsValueAcquired = true; +} +if ((MinsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Mins"); + if ((data != null)) + { + this._MinsField = ((float[])(data)); + } +} +bool MaxsValueAcquired = false; +if (this.Session.ContainsKey("Maxs")) +{ + this._MaxsField = ((float[])(this.Session["Maxs"])); + MaxsValueAcquired = true; +} +if ((MaxsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Maxs"); + if ((data != null)) + { + this._MaxsField = ((float[])(data)); + } +} +bool PrecisionsValueAcquired = false; +if (this.Session.ContainsKey("Precisions")) +{ + this._PrecisionsField = ((float[])(this.Session["Precisions"])); + PrecisionsValueAcquired = true; +} +if ((PrecisionsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Precisions"); + if ((data != null)) + { + this._PrecisionsField = ((float[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class CompressorsGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Compressors/CompressorsGenerator.tt b/Generators/Generators/Generators/Compressors/CompressorsGenerator.tt new file mode 100644 index 0000000..af87505 --- /dev/null +++ b/Generators/Generators/Generators/Compressors/CompressorsGenerator.tt @@ -0,0 +1,36 @@ +<#@ template language="C#" #> +<#@ parameter name="Prefix" type="System.String"#> +<#@ parameter name="CompressorNames" type="System.String[]"#> +<#@ parameter name="Mins" type="System.Single[]"#> +<#@ parameter name="Maxs" type="System.Single[]"#> +<#@ parameter name="Precisions" type="System.Single[]"#> +using NetStack.Compression; + +public static class <#=Prefix#>Compressors +{ +<# +for (int i = 0; i < Mins.Length; i++) +{ + var name = CompressorNames[i]; + #> + public static readonly BoundedRange <#=name#>Compressor; + <# +} +#> + + static <#=Prefix#>Compressors() + { +<# +for (int i = 0; i < Mins.Length; i++) +{ + var name = CompressorNames[i]; + var min = Mins[i]; + var max = Maxs[i]; + var precision = Precisions[i]; + #> + <#=name#>Compressor = new BoundedRange(<#=min#>, <#=max#>, <#=precision#>f); + <# +} +#> + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Properties/AssemblyInfo.cs b/Generators/Generators/Generators/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..af732f9 --- /dev/null +++ b/Generators/Generators/Generators/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Generators")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Generators")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8ba1de98-20de-43e8-8276-efe4bebb8b98")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.cs b/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.cs new file mode 100644 index 0000000..472b02c --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.cs @@ -0,0 +1,461 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Scheme.Command.Executor.Interface +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SchemeCommandExecutorInterfaceGenerator : SchemeCommandExecutorInterfaceGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("public interface I"); + + #line 5 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Type)); + + #line default + #line hidden + this.Write("Handler\r\n{\r\n"); + + #line 7 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + + foreach (var name in SchemeNames) + { + + + #line default + #line hidden + this.Write("\tvoid Handle"); + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Command(ref "); + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Using)); + + #line default + #line hidden + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Command command);\r\n"); + + #line 12 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + + } + + + #line default + #line hidden + this.Write("}\r\n\r\npublic interface I"); + + #line 17 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Type)); + + #line default + #line hidden + this.Write("Command{}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\Interface\SchemeCommandExecutorInterfaceGenerator.tt" + +private string _UsingField; + +/// +/// Access the Using parameter of the template. +/// +private string Using +{ + get + { + return this._UsingField; + } +} + +private string _TypeField; + +/// +/// Access the Type parameter of the template. +/// +private string Type +{ + get + { + return this._TypeField; + } +} + +private string[] _SchemeNamesField; + +/// +/// Access the SchemeNames parameter of the template. +/// +private string[] SchemeNames +{ + get + { + return this._SchemeNamesField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool UsingValueAcquired = false; +if (this.Session.ContainsKey("Using")) +{ + this._UsingField = ((string)(this.Session["Using"])); + UsingValueAcquired = true; +} +if ((UsingValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Using"); + if ((data != null)) + { + this._UsingField = ((string)(data)); + } +} +bool TypeValueAcquired = false; +if (this.Session.ContainsKey("Type")) +{ + this._TypeField = ((string)(this.Session["Type"])); + TypeValueAcquired = true; +} +if ((TypeValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Type"); + if ((data != null)) + { + this._TypeField = ((string)(data)); + } +} +bool SchemeNamesValueAcquired = false; +if (this.Session.ContainsKey("SchemeNames")) +{ + this._SchemeNamesField = ((string[])(this.Session["SchemeNames"])); + SchemeNamesValueAcquired = true; +} +if ((SchemeNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("SchemeNames"); + if ((data != null)) + { + this._SchemeNamesField = ((string[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SchemeCommandExecutorInterfaceGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.tt b/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.tt new file mode 100644 index 0000000..fb3a728 --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/Executor/Interface/SchemeCommandExecutorInterfaceGenerator.tt @@ -0,0 +1,17 @@ +<#@ template language="C#" #> +<#@ parameter name="Using" type="System.String"#> +<#@ parameter name="Type" type="System.String"#> +<#@ parameter name="SchemeNames" type="System.String[]"#> +public interface I<#=Type#>Handler +{ +<# + foreach (var name in SchemeNames) + { +#> + void Handle<#=name#>Command(ref <#=Using#><#=name#>Command command); +<# + } +#> +} + +public interface I<#=Type#>Command{} \ No newline at end of file diff --git a/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.cs b/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.cs new file mode 100644 index 0000000..7dd9a34 --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.cs @@ -0,0 +1,539 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Scheme.Command.Executor +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SchemeCommandExecutorGenerator : SchemeCommandExecutorGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using NetStack.Serialization;\r\nusing Sources.Tools;\r\n\r\npublic static class "); + + #line 9 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Type)); + + #line default + #line hidden + this.Write("CommandExecutor\r\n{\r\n public static void Execute(I"); + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Type)); + + #line default + #line hidden + this.Write("Handler handler, BitBuffer buffer, ushort commandCount)\r\n\t{\r\n\t\tfor (int i = 0; i " + + "< commandCount; i++)\r\n {\r\n var commandId = buffer.ReadUShort()" + + ";\r\n switch (commandId)\r\n {\r\n\t\t\t"); + + #line 18 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + + for (int i = 0; i < SchemeNames.Length; i++) + { + var id = SchemeIds[i]; + var name = SchemeNames[i]; + + + #line default + #line hidden + this.Write("\t\t\t\t\r\n case "); + + #line 25 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(id)); + + #line default + #line hidden + this.Write(":\r\n {\r\n"); + + #line 27 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + + if (name != "Input" && name != "InputBufferState") + { + + + #line default + #line hidden + this.Write("\t\t\t\t\tLogger.I.Log(\""); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Type)); + + #line default + #line hidden + this.Write("CommandExecutor\", \"Executing "); + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Using)); + + #line default + #line hidden + + #line 31 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Command\");\r\n"); + + #line 32 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + + } + + + #line default + #line hidden + this.Write(" var c = new "); + + #line 35 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Using)); + + #line default + #line hidden + + #line 35 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Command();\r\n c.Deserialize(buffer);\r\n handl" + + "er.Handle"); + + #line 37 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("Command(ref c);\r\n break;\r\n }\r\n\t\t\t\t"); + + #line 40 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n }\r\n\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\Executor\SchemeCommandExecutorGenerator.tt" + +private string _UsingField; + +/// +/// Access the Using parameter of the template. +/// +private string Using +{ + get + { + return this._UsingField; + } +} + +private string _TypeField; + +/// +/// Access the Type parameter of the template. +/// +private string Type +{ + get + { + return this._TypeField; + } +} + +private ushort[] _SchemeIdsField; + +/// +/// Access the SchemeIds parameter of the template. +/// +private ushort[] SchemeIds +{ + get + { + return this._SchemeIdsField; + } +} + +private string[] _SchemeNamesField; + +/// +/// Access the SchemeNames parameter of the template. +/// +private string[] SchemeNames +{ + get + { + return this._SchemeNamesField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool UsingValueAcquired = false; +if (this.Session.ContainsKey("Using")) +{ + this._UsingField = ((string)(this.Session["Using"])); + UsingValueAcquired = true; +} +if ((UsingValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Using"); + if ((data != null)) + { + this._UsingField = ((string)(data)); + } +} +bool TypeValueAcquired = false; +if (this.Session.ContainsKey("Type")) +{ + this._TypeField = ((string)(this.Session["Type"])); + TypeValueAcquired = true; +} +if ((TypeValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Type"); + if ((data != null)) + { + this._TypeField = ((string)(data)); + } +} +bool SchemeIdsValueAcquired = false; +if (this.Session.ContainsKey("SchemeIds")) +{ + this._SchemeIdsField = ((ushort[])(this.Session["SchemeIds"])); + SchemeIdsValueAcquired = true; +} +if ((SchemeIdsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("SchemeIds"); + if ((data != null)) + { + this._SchemeIdsField = ((ushort[])(data)); + } +} +bool SchemeNamesValueAcquired = false; +if (this.Session.ContainsKey("SchemeNames")) +{ + this._SchemeNamesField = ((string[])(this.Session["SchemeNames"])); + SchemeNamesValueAcquired = true; +} +if ((SchemeNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("SchemeNames"); + if ((data != null)) + { + this._SchemeNamesField = ((string[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SchemeCommandExecutorGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.tt b/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.tt new file mode 100644 index 0000000..a6a475e --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/Executor/SchemeCommandExecutorGenerator.tt @@ -0,0 +1,46 @@ +<#@ template language="C#" #> +<#@ parameter name="Using" type="System.String"#> +<#@ parameter name="Type" type="System.String"#> +<#@ parameter name="SchemeIds" type="System.UInt16[]"#> +<#@ parameter name="SchemeNames" type="System.String[]"#> +using NetStack.Serialization; +using Sources.Tools; + +public static class <#=Type#>CommandExecutor +{ + public static void Execute(I<#=Type#>Handler handler, BitBuffer buffer, ushort commandCount) + { + for (int i = 0; i < commandCount; i++) + { + var commandId = buffer.ReadUShort(); + switch (commandId) + { + <# + for (int i = 0; i < SchemeNames.Length; i++) + { + var id = SchemeIds[i]; + var name = SchemeNames[i]; + #> + + case <#=id#>: + { +<# + if (name != "Input" && name != "InputBufferState") + { +#> + Logger.I.Log("<#=Type#>CommandExecutor", "Executing <#=Using#><#=name#>Command"); +<# + } +#> + var c = new <#=Using#><#=name#>Command(); + c.Deserialize(buffer); + handler.Handle<#=name#>Command(ref c); + break; + } + <# + } + #> + } + } + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.cs b/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.cs new file mode 100644 index 0000000..5840c10 --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.cs @@ -0,0 +1,1545 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Scheme.Command +{ + using System.Linq; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SchemeCommandGenerator : SchemeCommandGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using NetStack.Serialization;\r\n"); + + #line 11 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + if (FieldTypes.Any(x => x == "System.Single")|| + FieldTypes.Any(x => x == "UnityEngine.Vector2")|| + FieldTypes.Any(x => x == "UnityEngine.Vector3")) + { + + + #line default + #line hidden + this.Write("using NetStack.Compression;\r\n\t"); + + #line 18 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\r\npublic struct "); + + #line 22 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 22 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + this.Write("Command : ICommand, I"); + + #line 22 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + this.Write("Command\r\n{\r\n"); + + #line 24 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + for (int i = 0; i < FieldTypes.Length; i++) + { + + + #line default + #line hidden + this.Write("\tpublic "); + + #line 27 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldTypes[i])); + + #line default + #line hidden + this.Write(" "); + + #line 27 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(";\r\n"); + + #line 28 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + + + #line default + #line hidden + this.Write(" public void Serialize(BitBuffer bitBuffer)\r\n\t{\r\n\t\tbitBuffer.AddUShort("); + + #line 33 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandId)); + + #line default + #line hidden + this.Write(");\r\n\r\n"); + + #line 35 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddByte((byte)"); + + #line 41 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 42 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddByte("); + + #line 51 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 52 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int32": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddInt("); + + #line 57 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 58 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt32": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddUInt("); + + #line 63 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 64 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int64": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddLong("); + + #line 69 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 70 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt64": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddULong("); + + #line 75 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 76 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int16": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddShort("); + + #line 81 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 82 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt16": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddUShort("); + + #line 87 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 88 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.String": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddString("); + + #line 93 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 94 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Boolean": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddBool("); + + #line 99 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 100 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Single": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(CommandCompressors."); + + #line 107 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 107 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 107 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("Compressor.Compress("); + + #line 107 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("));\r\n"); + + #line 108 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 113 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("));\r\n"); + + #line 114 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(CommandCompressors."); + + #line 122 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 122 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 122 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Compress("); + + #line 122 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUInt(CommandCompressors."); + + #line 123 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 123 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 123 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Compress("); + + #line 123 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n"); + + #line 124 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 129 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 130 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n"); + + #line 131 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(CommandCompressors."); + + #line 139 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 139 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 139 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Compress("); + + #line 139 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUInt(CommandCompressors."); + + #line 140 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 140 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 140 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Compress("); + + #line 140 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n bitBuffer.AddUInt(CommandCompressors."); + + #line 141 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 141 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 141 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("ZCompressor.Compress("); + + #line 141 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z));\r\n"); + + #line 142 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 147 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 148 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 149 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z));\r\n"); + + #line 150 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + } + + } + } + + + #line default + #line hidden + this.Write("\t}\r\n\r\n\tpublic void Deserialize(BitBuffer bitBuffer)\r\n\t{\r\n"); + + #line 161 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { + + + #line default + #line hidden + this.Write("\t\t"); + + #line 167 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = ("); + + #line 167 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldTypes[i])); + + #line default + #line hidden + this.Write(")bitBuffer.ReadByte(); \r\n"); + + #line 168 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 177 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadByte(); \r\n"); + + #line 178 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int32": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 183 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadInt(); \r\n"); + + #line 184 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt32": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 189 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadUInt(); \r\n"); + + #line 190 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int64": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 195 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadLong(); \r\n"); + + #line 196 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt64": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 201 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadULong();\r\n"); + + #line 202 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Int16": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 207 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadShort(); \r\n"); + + #line 208 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.UInt16": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 213 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadUShort(); \r\n"); + + #line 214 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.String": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 219 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadString();\r\n"); + + #line 220 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Boolean": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 225 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadBool(); \r\n"); + + #line 226 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + break; + + case "System.Single": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 233 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = CommandCompressors."); + + #line 233 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 233 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 233 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("Compressor.Decompress(bitBuffer.ReadUInt());\r\n"); + + #line 234 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 239 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 240 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 248 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = CommandCompressors."); + + #line 248 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 248 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 248 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 249 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = CommandCompressors."); + + #line 249 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 249 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 249 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Decompress(bitBuffer.ReadUInt());\r\n"); + + #line 250 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 255 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 256 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 257 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 265 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = CommandCompressors."); + + #line 265 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 265 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 265 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 266 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = CommandCompressors."); + + #line 266 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 266 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 266 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 267 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z = CommandCompressors."); + + #line 267 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + + #line default + #line hidden + + #line 267 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(CommandName)); + + #line default + #line hidden + + #line 267 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("ZCompressor.Decompress(bitBuffer.ReadUInt());\r\n\r\n"); + + #line 269 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 274 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 275 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 276 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 277 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + + } + break; + } + } + } + + + #line default + #line hidden + this.Write("\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Scheme\Command\SchemeCommandGenerator.tt" + +private string _NamespaceField; + +/// +/// Access the Namespace parameter of the template. +/// +private string Namespace +{ + get + { + return this._NamespaceField; + } +} + +private string _CommandNameField; + +/// +/// Access the CommandName parameter of the template. +/// +private string CommandName +{ + get + { + return this._CommandNameField; + } +} + +private ushort _CommandIdField; + +/// +/// Access the CommandId parameter of the template. +/// +private ushort CommandId +{ + get + { + return this._CommandIdField; + } +} + +private string[] _FieldTypesField; + +/// +/// Access the FieldTypes parameter of the template. +/// +private string[] FieldTypes +{ + get + { + return this._FieldTypesField; + } +} + +private string[] _FieldNamesField; + +/// +/// Access the FieldNames parameter of the template. +/// +private string[] FieldNames +{ + get + { + return this._FieldNamesField; + } +} + +private bool[] _IsEnumsField; + +/// +/// Access the IsEnums parameter of the template. +/// +private bool[] IsEnums +{ + get + { + return this._IsEnumsField; + } +} + +private bool[] _IsCompressedField; + +/// +/// Access the IsCompressed parameter of the template. +/// +private bool[] IsCompressed +{ + get + { + return this._IsCompressedField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool NamespaceValueAcquired = false; +if (this.Session.ContainsKey("Namespace")) +{ + this._NamespaceField = ((string)(this.Session["Namespace"])); + NamespaceValueAcquired = true; +} +if ((NamespaceValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Namespace"); + if ((data != null)) + { + this._NamespaceField = ((string)(data)); + } +} +bool CommandNameValueAcquired = false; +if (this.Session.ContainsKey("CommandName")) +{ + this._CommandNameField = ((string)(this.Session["CommandName"])); + CommandNameValueAcquired = true; +} +if ((CommandNameValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("CommandName"); + if ((data != null)) + { + this._CommandNameField = ((string)(data)); + } +} +bool CommandIdValueAcquired = false; +if (this.Session.ContainsKey("CommandId")) +{ + this._CommandIdField = ((ushort)(this.Session["CommandId"])); + CommandIdValueAcquired = true; +} +if ((CommandIdValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("CommandId"); + if ((data != null)) + { + this._CommandIdField = ((ushort)(data)); + } +} +bool FieldTypesValueAcquired = false; +if (this.Session.ContainsKey("FieldTypes")) +{ + this._FieldTypesField = ((string[])(this.Session["FieldTypes"])); + FieldTypesValueAcquired = true; +} +if ((FieldTypesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("FieldTypes"); + if ((data != null)) + { + this._FieldTypesField = ((string[])(data)); + } +} +bool FieldNamesValueAcquired = false; +if (this.Session.ContainsKey("FieldNames")) +{ + this._FieldNamesField = ((string[])(this.Session["FieldNames"])); + FieldNamesValueAcquired = true; +} +if ((FieldNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("FieldNames"); + if ((data != null)) + { + this._FieldNamesField = ((string[])(data)); + } +} +bool IsEnumsValueAcquired = false; +if (this.Session.ContainsKey("IsEnums")) +{ + this._IsEnumsField = ((bool[])(this.Session["IsEnums"])); + IsEnumsValueAcquired = true; +} +if ((IsEnumsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsEnums"); + if ((data != null)) + { + this._IsEnumsField = ((bool[])(data)); + } +} +bool IsCompressedValueAcquired = false; +if (this.Session.ContainsKey("IsCompressed")) +{ + this._IsCompressedField = ((bool[])(this.Session["IsCompressed"])); + IsCompressedValueAcquired = true; +} +if ((IsCompressedValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsCompressed"); + if ((data != null)) + { + this._IsCompressedField = ((bool[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SchemeCommandGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.tt b/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.tt new file mode 100644 index 0000000..db96d9e --- /dev/null +++ b/Generators/Generators/Generators/Scheme/Command/SchemeCommandGenerator.tt @@ -0,0 +1,284 @@ +<#@ template language="C#" #> +<#@ parameter name="Namespace" type="System.String"#> +<#@ parameter name="CommandName" type="System.String"#> +<#@ parameter name="CommandId" type="System.UInt16"#> +<#@ parameter name="FieldTypes" type="System.String[]"#> +<#@ parameter name="FieldNames" type="System.String[]"#> +<#@ parameter name="IsEnums" type="System.Boolean[]"#> +<#@ parameter name="IsCompressed" type="System.Boolean[]"#> +<#@ import namespace="System.Linq" #> +using NetStack.Serialization; +<# + if (FieldTypes.Any(x => x == "System.Single")|| + FieldTypes.Any(x => x == "UnityEngine.Vector2")|| + FieldTypes.Any(x => x == "UnityEngine.Vector3")) + { + #> +using NetStack.Compression; + <# + } +#> + +public struct <#=Namespace#><#= CommandName #>Command : ICommand, I<#=Namespace#>Command +{ +<# for (int i = 0; i < FieldTypes.Length; i++) + { +#> + public <#=FieldTypes[i]#> <#=FieldNames[i]#>; +<# + } +#> + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(<#= CommandId #>); + +<# + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { +#> + bitBuffer.AddByte((byte)<#=FieldNames[i]#>); +<# + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": +#> + bitBuffer.AddByte(<#=FieldNames[i]#>); +<# + break; + + case "System.Int32": +#> + bitBuffer.AddInt(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt32": +#> + bitBuffer.AddUInt(<#=FieldNames[i]#>); +<# + break; + + case "System.Int64": +#> + bitBuffer.AddLong(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt64": +#> + bitBuffer.AddULong(<#=FieldNames[i]#>); +<# + break; + + case "System.Int16": +#> + bitBuffer.AddShort(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt16": +#> + bitBuffer.AddUShort(<#=FieldNames[i]#>); +<# + break; + + case "System.String": +#> + bitBuffer.AddString(<#=FieldNames[i]#>); +<# + break; + + case "System.Boolean": +#> + bitBuffer.AddBool(<#=FieldNames[i]#>); +<# + break; + + case "System.Single": + if (compressed) + { +#> + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>Compressor.Compress(<#=FieldNames[i]#>)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>)); +<# + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { +#> + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>XCompressor.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>YCompressor.Compress(<#=FieldNames[i]#>.y)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.y)); +<# + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { +#> + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>XCompressor.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>YCompressor.Compress(<#=FieldNames[i]#>.y)); + bitBuffer.AddUInt(CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>ZCompressor.Compress(<#=FieldNames[i]#>.z)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.y)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.z)); +<# + } + break; + } + + } + } +#> } + + public void Deserialize(BitBuffer bitBuffer) + { +<# + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { +#> + <#=FieldNames[i]#> = (<#=FieldTypes[i]#>)bitBuffer.ReadByte(); +<# + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": +#> + <#=FieldNames[i]#> = bitBuffer.ReadByte(); +<# + break; + + case "System.Int32": +#> + <#=FieldNames[i]#> = bitBuffer.ReadInt(); +<# + break; + + case "System.UInt32": +#> + <#=FieldNames[i]#> = bitBuffer.ReadUInt(); +<# + break; + + case "System.Int64": +#> + <#=FieldNames[i]#> = bitBuffer.ReadLong(); +<# + break; + + case "System.UInt64": +#> + <#=FieldNames[i]#> = bitBuffer.ReadULong(); +<# + break; + + case "System.Int16": +#> + <#=FieldNames[i]#> = bitBuffer.ReadShort(); +<# + break; + + case "System.UInt16": +#> + <#=FieldNames[i]#> = bitBuffer.ReadUShort(); +<# + break; + + case "System.String": +#> + <#=FieldNames[i]#> = bitBuffer.ReadString(); +<# + break; + + case "System.Boolean": +#> + <#=FieldNames[i]#> = bitBuffer.ReadBool(); +<# + break; + + case "System.Single": + if (compressed) + { +#> + <#=FieldNames[i]#> = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>Compressor.Decompress(bitBuffer.ReadUInt()); +<# + } + else + { +#> + <#=FieldNames[i]#> = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { +#> + <#=FieldNames[i]#>.x = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>XCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.y = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>YCompressor.Decompress(bitBuffer.ReadUInt()); +<# + } + else + { +#> + <#=FieldNames[i]#>.x = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.y = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { +#> + <#=FieldNames[i]#>.x = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>XCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.y = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>YCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.z = CommandCompressors.<#=Namespace#><#= CommandName #><#=FieldNames[i]#>ZCompressor.Decompress(bitBuffer.ReadUInt()); + +<# + } + else + { +#> + <#=FieldNames[i]#>.x = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.y = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.z = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + } + } + } +#> } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.cs b/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.cs new file mode 100644 index 0000000..aba10ff --- /dev/null +++ b/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.cs @@ -0,0 +1,1403 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Component +{ + using System.Linq; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SyncComponentGenerator : SyncComponentGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using NetStack.Serialization;\r\n"); + + #line 10 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + if (FieldTypes.Any(x => x == "System.Single")|| + FieldTypes.Any(x => x == "UnityEngine.Vector2")|| + FieldTypes.Any(x => x == "UnityEngine.Vector3")) + { + + + #line default + #line hidden + this.Write("using NetStack.Compression;\r\n\t"); + + #line 17 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\r\npublic partial class "); + + #line 21 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write(" : INetworkComponent\r\n{\r\n public void Serialize(BitBuffer bitBuffer)\r\n\t{\r\n\t\tbi" + + "tBuffer.AddUShort("); + + #line 25 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentId)); + + #line default + #line hidden + this.Write(");\r\n\r\n"); + + #line 27 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddByte((byte)"); + + #line 33 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 34 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + var compressed = IsCompressed[i]; + var compName = ComponentName.Replace("Component", ""); + + switch(FieldTypes[i]) + { + case "System.Byte": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddByte("); + + #line 45 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 46 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int32": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddInt("); + + #line 51 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 52 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt32": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddUInt("); + + #line 57 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 58 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int64": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddLong("); + + #line 63 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 64 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt64": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddULong("); + + #line 69 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 70 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int16": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddShort("); + + #line 75 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 76 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt16": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddUShort("); + + #line 81 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 82 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.String": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddString("); + + #line 87 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 88 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Boolean": + + + #line default + #line hidden + this.Write("\t\tbitBuffer.AddBool("); + + #line 93 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("); \r\n"); + + #line 94 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Single": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(SyncCompressors."); + + #line 101 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 101 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("Compressor.Compress("); + + #line 101 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("));\r\n"); + + #line 102 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 107 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("));\r\n"); + + #line 108 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(SyncCompressors."); + + #line 116 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 116 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Compress("); + + #line 116 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUInt(SyncCompressors."); + + #line 117 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 117 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Compress("); + + #line 117 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n"); + + #line 118 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 123 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 124 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n"); + + #line 125 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUInt(SyncCompressors."); + + #line 133 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 133 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Compress("); + + #line 133 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUInt(SyncCompressors."); + + #line 134 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 134 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Compress("); + + #line 134 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n bitBuffer.AddUInt(SyncCompressors."); + + #line 135 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 135 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("ZCompressor.Compress("); + + #line 135 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z));\r\n"); + + #line 136 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 141 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 142 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y));\r\n bitBuffer.AddUShort(HalfPrecision.Compress("); + + #line 143 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z));\r\n"); + + #line 144 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + } + } + } + + + #line default + #line hidden + this.Write("\t}\r\n\r\n\tpublic void Deserialize(BitBuffer bitBuffer)\r\n\t{\r\n"); + + #line 154 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { + + + #line default + #line hidden + this.Write("\t\t"); + + #line 160 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = ("); + + #line 160 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldTypes[i])); + + #line default + #line hidden + this.Write(")bitBuffer.ReadByte(); \r\n"); + + #line 161 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 170 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadByte(); \r\n"); + + #line 171 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int32": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 176 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadInt(); \r\n"); + + #line 177 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt32": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 182 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadUInt(); \r\n"); + + #line 183 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int64": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 188 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadLong(); \r\n"); + + #line 189 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt64": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 194 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadULong();\r\n"); + + #line 195 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Int16": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 200 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadShort(); \r\n"); + + #line 201 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.UInt16": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 206 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadUShort(); \r\n"); + + #line 207 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.String": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 212 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadString();\r\n"); + + #line 213 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Boolean": + + + #line default + #line hidden + this.Write("\t\t"); + + #line 218 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = bitBuffer.ReadBool(); \r\n"); + + #line 219 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + break; + + case "System.Single": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 226 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = SyncCompressors."); + + #line 226 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 226 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("Compressor.Decompress(bitBuffer.ReadUInt());\r\n"); + + #line 227 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 232 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(" = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 233 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 241 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = SyncCompressors."); + + #line 241 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 241 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 242 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = SyncCompressors."); + + #line 242 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 242 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Decompress(bitBuffer.ReadUInt());\r\n"); + + #line 243 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 248 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 249 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 250 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { + + + #line default + #line hidden + this.Write(" "); + + #line 258 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = SyncCompressors."); + + #line 258 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 258 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("XCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 259 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = SyncCompressors."); + + #line 259 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 259 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("YCompressor.Decompress(bitBuffer.ReadUInt());\r\n "); + + #line 260 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z = SyncCompressors."); + + #line 260 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName.Replace("Component", ""))); + + #line default + #line hidden + + #line 260 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write("ZCompressor.Decompress(bitBuffer.ReadUInt());\r\n\r\n"); + + #line 262 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 267 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".x = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 268 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".y = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n "); + + #line 269 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(FieldNames[i])); + + #line default + #line hidden + this.Write(".z = HalfPrecision.Decompress(bitBuffer.ReadUShort());\r\n"); + + #line 270 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + + } + break; + } + } + } + + + #line default + #line hidden + this.Write("\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG-git\Generators\Generators\Generators\Sync\Component\SyncComponentGenerator.tt" + +private string _ComponentNameField; + +/// +/// Access the ComponentName parameter of the template. +/// +private string ComponentName +{ + get + { + return this._ComponentNameField; + } +} + +private ushort _ComponentIdField; + +/// +/// Access the ComponentId parameter of the template. +/// +private ushort ComponentId +{ + get + { + return this._ComponentIdField; + } +} + +private string[] _FieldTypesField; + +/// +/// Access the FieldTypes parameter of the template. +/// +private string[] FieldTypes +{ + get + { + return this._FieldTypesField; + } +} + +private string[] _FieldNamesField; + +/// +/// Access the FieldNames parameter of the template. +/// +private string[] FieldNames +{ + get + { + return this._FieldNamesField; + } +} + +private bool[] _IsEnumsField; + +/// +/// Access the IsEnums parameter of the template. +/// +private bool[] IsEnums +{ + get + { + return this._IsEnumsField; + } +} + +private bool[] _IsCompressedField; + +/// +/// Access the IsCompressed parameter of the template. +/// +private bool[] IsCompressed +{ + get + { + return this._IsCompressedField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNameValueAcquired = false; +if (this.Session.ContainsKey("ComponentName")) +{ + this._ComponentNameField = ((string)(this.Session["ComponentName"])); + ComponentNameValueAcquired = true; +} +if ((ComponentNameValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentName"); + if ((data != null)) + { + this._ComponentNameField = ((string)(data)); + } +} +bool ComponentIdValueAcquired = false; +if (this.Session.ContainsKey("ComponentId")) +{ + this._ComponentIdField = ((ushort)(this.Session["ComponentId"])); + ComponentIdValueAcquired = true; +} +if ((ComponentIdValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentId"); + if ((data != null)) + { + this._ComponentIdField = ((ushort)(data)); + } +} +bool FieldTypesValueAcquired = false; +if (this.Session.ContainsKey("FieldTypes")) +{ + this._FieldTypesField = ((string[])(this.Session["FieldTypes"])); + FieldTypesValueAcquired = true; +} +if ((FieldTypesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("FieldTypes"); + if ((data != null)) + { + this._FieldTypesField = ((string[])(data)); + } +} +bool FieldNamesValueAcquired = false; +if (this.Session.ContainsKey("FieldNames")) +{ + this._FieldNamesField = ((string[])(this.Session["FieldNames"])); + FieldNamesValueAcquired = true; +} +if ((FieldNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("FieldNames"); + if ((data != null)) + { + this._FieldNamesField = ((string[])(data)); + } +} +bool IsEnumsValueAcquired = false; +if (this.Session.ContainsKey("IsEnums")) +{ + this._IsEnumsField = ((bool[])(this.Session["IsEnums"])); + IsEnumsValueAcquired = true; +} +if ((IsEnumsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsEnums"); + if ((data != null)) + { + this._IsEnumsField = ((bool[])(data)); + } +} +bool IsCompressedValueAcquired = false; +if (this.Session.ContainsKey("IsCompressed")) +{ + this._IsCompressedField = ((bool[])(this.Session["IsCompressed"])); + IsCompressedValueAcquired = true; +} +if ((IsCompressedValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsCompressed"); + if ((data != null)) + { + this._IsCompressedField = ((bool[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SyncComponentGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.tt b/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.tt new file mode 100644 index 0000000..22807a7 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Component/SyncComponentGenerator.tt @@ -0,0 +1,277 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentName" type="System.String"#> +<#@ parameter name="ComponentId" type="System.UInt16"#> +<#@ parameter name="FieldTypes" type="System.String[]"#> +<#@ parameter name="FieldNames" type="System.String[]"#> +<#@ parameter name="IsEnums" type="System.Boolean[]"#> +<#@ parameter name="IsCompressed" type="System.Boolean[]"#> +<#@ import namespace="System.Linq" #> +using NetStack.Serialization; +<# + if (FieldTypes.Any(x => x == "System.Single")|| + FieldTypes.Any(x => x == "UnityEngine.Vector2")|| + FieldTypes.Any(x => x == "UnityEngine.Vector3")) + { + #> +using NetStack.Compression; + <# + } +#> + +public partial class <#= ComponentName #> : INetworkComponent +{ + public void Serialize(BitBuffer bitBuffer) + { + bitBuffer.AddUShort(<#= ComponentId #>); + +<# + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { +#> + bitBuffer.AddByte((byte)<#=FieldNames[i]#>); +<# + } + else + { + var compressed = IsCompressed[i]; + var compName = ComponentName.Replace("Component", ""); + + switch(FieldTypes[i]) + { + case "System.Byte": +#> + bitBuffer.AddByte(<#=FieldNames[i]#>); +<# + break; + + case "System.Int32": +#> + bitBuffer.AddInt(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt32": +#> + bitBuffer.AddUInt(<#=FieldNames[i]#>); +<# + break; + + case "System.Int64": +#> + bitBuffer.AddLong(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt64": +#> + bitBuffer.AddULong(<#=FieldNames[i]#>); +<# + break; + + case "System.Int16": +#> + bitBuffer.AddShort(<#=FieldNames[i]#>); +<# + break; + + case "System.UInt16": +#> + bitBuffer.AddUShort(<#=FieldNames[i]#>); +<# + break; + + case "System.String": +#> + bitBuffer.AddString(<#=FieldNames[i]#>); +<# + break; + + case "System.Boolean": +#> + bitBuffer.AddBool(<#=FieldNames[i]#>); +<# + break; + + case "System.Single": + if (compressed) + { +#> + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>Compressor.Compress(<#=FieldNames[i]#>)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>)); +<# + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { +#> + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>XCompressor.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>YCompressor.Compress(<#=FieldNames[i]#>.y)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.y)); +<# + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { +#> + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>XCompressor.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>YCompressor.Compress(<#=FieldNames[i]#>.y)); + bitBuffer.AddUInt(SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>ZCompressor.Compress(<#=FieldNames[i]#>.z)); +<# + } + else + { +#> + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.x)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.y)); + bitBuffer.AddUShort(HalfPrecision.Compress(<#=FieldNames[i]#>.z)); +<# + } + break; + } + } + } +#> } + + public void Deserialize(BitBuffer bitBuffer) + { +<# + for (int i = 0; i < FieldTypes.Length; i++) + { + if (IsEnums[i]) + { +#> + <#=FieldNames[i]#> = (<#=FieldTypes[i]#>)bitBuffer.ReadByte(); +<# + } + else + { + var compressed = IsCompressed[i]; + switch(FieldTypes[i]) + { + case "System.Byte": +#> + <#=FieldNames[i]#> = bitBuffer.ReadByte(); +<# + break; + + case "System.Int32": +#> + <#=FieldNames[i]#> = bitBuffer.ReadInt(); +<# + break; + + case "System.UInt32": +#> + <#=FieldNames[i]#> = bitBuffer.ReadUInt(); +<# + break; + + case "System.Int64": +#> + <#=FieldNames[i]#> = bitBuffer.ReadLong(); +<# + break; + + case "System.UInt64": +#> + <#=FieldNames[i]#> = bitBuffer.ReadULong(); +<# + break; + + case "System.Int16": +#> + <#=FieldNames[i]#> = bitBuffer.ReadShort(); +<# + break; + + case "System.UInt16": +#> + <#=FieldNames[i]#> = bitBuffer.ReadUShort(); +<# + break; + + case "System.String": +#> + <#=FieldNames[i]#> = bitBuffer.ReadString(); +<# + break; + + case "System.Boolean": +#> + <#=FieldNames[i]#> = bitBuffer.ReadBool(); +<# + break; + + case "System.Single": + if (compressed) + { +#> + <#=FieldNames[i]#> = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>Compressor.Decompress(bitBuffer.ReadUInt()); +<# + } + else + { +#> + <#=FieldNames[i]#> = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + + case "UnityEngine.Vector2": + if (compressed) + { +#> + <#=FieldNames[i]#>.x = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>XCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.y = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>YCompressor.Decompress(bitBuffer.ReadUInt()); +<# + } + else + { +#> + <#=FieldNames[i]#>.x = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.y = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + + case "UnityEngine.Vector3": + if (compressed) + { +#> + <#=FieldNames[i]#>.x = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>XCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.y = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>YCompressor.Decompress(bitBuffer.ReadUInt()); + <#=FieldNames[i]#>.z = SyncCompressors.<#=ComponentName.Replace("Component", "")#><#=FieldNames[i]#>ZCompressor.Decompress(bitBuffer.ReadUInt()); + +<# + } + else + { +#> + <#=FieldNames[i]#>.x = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.y = HalfPrecision.Decompress(bitBuffer.ReadUShort()); + <#=FieldNames[i]#>.z = HalfPrecision.Decompress(bitBuffer.ReadUShort()); +<# + } + break; + } + } + } +#> } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.cs b/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.cs new file mode 100644 index 0000000..43cdf22 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.cs @@ -0,0 +1,391 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Feature +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SyncFeatureGenerator : SyncFeatureGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using Sources.Networking.Server.StateCapture;\r\n\r\npublic class ServerStateCaptureF" + + "eature : Feature\r\n{\r\n public ServerStateCaptureFeature(Contexts contexts, Ser" + + "vices services)\r\n {\r\n"); + + #line 9 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + + foreach (var name in ComponentNames) + { + + + #line default + #line hidden + this.Write(" Add(new ServerCaptureChanged"); + + #line 13 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("System(contexts, services));\r\n Add(new ServerCaptureRemoved"); + + #line 14 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("System(contexts, services));\r\n"); + + #line 15 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\r\n\t Add(new ServerCreateWorldStateSystem(contexts));\r\n Add(new ServerCa" + + "ptureCreatedEntitiesSystem(contexts, services));\r\n Add(new ServerCaptureR" + + "emovedEntitiesSystem(contexts, services));\r\n\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Feature\SyncFeatureGenerator.tt" + +private string[] _ComponentNamesField; + +/// +/// Access the ComponentNames parameter of the template. +/// +private string[] ComponentNames +{ + get + { + return this._ComponentNamesField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNamesValueAcquired = false; +if (this.Session.ContainsKey("ComponentNames")) +{ + this._ComponentNamesField = ((string[])(this.Session["ComponentNames"])); + ComponentNamesValueAcquired = true; +} +if ((ComponentNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentNames"); + if ((data != null)) + { + this._ComponentNamesField = ((string[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SyncFeatureGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.tt b/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.tt new file mode 100644 index 0000000..1a5d329 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Feature/SyncFeatureGenerator.tt @@ -0,0 +1,23 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentNames" type="System.String[]"#> +using Sources.Networking.Server.StateCapture; + +public class ServerStateCaptureFeature : Feature +{ + public ServerStateCaptureFeature(Contexts contexts, Services services) + { +<# + foreach (var name in ComponentNames) + { +#> + Add(new ServerCaptureChanged<#=name#>System(contexts, services)); + Add(new ServerCaptureRemoved<#=name#>System(contexts, services)); +<# + } +#> + + Add(new ServerCreateWorldStateSystem(contexts)); + Add(new ServerCaptureCreatedEntitiesSystem(contexts, services)); + Add(new ServerCaptureRemovedEntitiesSystem(contexts, services)); + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.cs b/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.cs new file mode 100644 index 0000000..b066f8d --- /dev/null +++ b/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.cs @@ -0,0 +1,534 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Systems +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SyncChangedComponentSystemGenerator : SyncChangedComponentSystemGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using System.Collections.Generic;\r\nusing Entitas;\r\nusing Sources.Networking.Serve" + + "r;\r\n\r\n"); + + #line 9 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + var name = ComponentName.Replace("Component", ""); + var firstLowerName = char.ToLowerInvariant(name[0]) + name.Substring(1); + + + #line default + #line hidden + this.Write("\r\npublic class ServerCaptureChanged"); + + #line 14 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("System : ReactiveSystem\r\n{\r\n\tprivate readonly ServerNetworkSystem _se" + + "rver;\r\n\tpublic ServerCaptureChanged"); + + #line 17 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("System (Contexts contexts, Services services) : base(contexts.game)\r\n\t{\r\n\t\t_serve" + + "r = services.ServerSystem;\r\n\t}\r\n\t\t\r\n\tprotected override ICollector G" + + "etTrigger(IContext context) {\r\n\t\treturn context.CreateCollector(Game" + + "Matcher."); + + #line 23 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(".Added());\r\n\t}\r\n\t\t\r\n\tprotected override bool Filter(GameEntity entity)\r\n\t{\r\n"); + + #line 28 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + if (IsTag) + { + + + #line default + #line hidden + this.Write(" return !entity.isDestroyed && entity.isWasSynced && entity.is"); + + #line 32 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(";\r\n"); + + #line 33 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" return !entity.isDestroyed && entity.isWasSynced && entity.has"); + + #line 38 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(";\r\n"); + + #line 39 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\t}\r\n\r\n\tprotected override void Execute(List entities) {\r\n\t\tif (_serve" + + "r.State != ServerState.Working) return;\r\n\r\n\t\tforeach (var e in entities) {\r\n\t\t " + + " _server.ChangedComponents.AddUShort(e.id.Value);\r\n"); + + #line 49 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + if (IsTag) + { + + + #line default + #line hidden + this.Write(" _server.ChangedComponents.AddUShort("); + + #line 53 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentId)); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 54 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" e."); + + #line 59 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(firstLowerName)); + + #line default + #line hidden + this.Write(".Serialize(_server.ChangedComponents);\r\n"); + + #line 60 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\t\t\t_server.ChangedComponentsCount++;\r\n\t\t}\r\n\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncChangedComponentSystemGenerator.tt" + +private string _ComponentNameField; + +/// +/// Access the ComponentName parameter of the template. +/// +private string ComponentName +{ + get + { + return this._ComponentNameField; + } +} + +private ushort _ComponentIdField; + +/// +/// Access the ComponentId parameter of the template. +/// +private ushort ComponentId +{ + get + { + return this._ComponentIdField; + } +} + +private bool _IsTagField; + +/// +/// Access the IsTag parameter of the template. +/// +private bool IsTag +{ + get + { + return this._IsTagField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNameValueAcquired = false; +if (this.Session.ContainsKey("ComponentName")) +{ + this._ComponentNameField = ((string)(this.Session["ComponentName"])); + ComponentNameValueAcquired = true; +} +if ((ComponentNameValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentName"); + if ((data != null)) + { + this._ComponentNameField = ((string)(data)); + } +} +bool ComponentIdValueAcquired = false; +if (this.Session.ContainsKey("ComponentId")) +{ + this._ComponentIdField = ((ushort)(this.Session["ComponentId"])); + ComponentIdValueAcquired = true; +} +if ((ComponentIdValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentId"); + if ((data != null)) + { + this._ComponentIdField = ((ushort)(data)); + } +} +bool IsTagValueAcquired = false; +if (this.Session.ContainsKey("IsTag")) +{ + this._IsTagField = ((bool)(this.Session["IsTag"])); + IsTagValueAcquired = true; +} +if ((IsTagValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsTag"); + if ((data != null)) + { + this._IsTagField = ((bool)(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SyncChangedComponentSystemGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.tt b/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.tt new file mode 100644 index 0000000..3765a6b --- /dev/null +++ b/Generators/Generators/Generators/Sync/Systems/SyncChangedComponentSystemGenerator.tt @@ -0,0 +1,66 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentName" type="System.String"#> +<#@ parameter name="ComponentId" type="System.UInt16"#> +<#@ parameter name="IsTag" type="System.Boolean"#> +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +<# + var name = ComponentName.Replace("Component", ""); + var firstLowerName = char.ToLowerInvariant(name[0]) + name.Substring(1); +#> + +public class ServerCaptureChanged<#=name#>System : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureChanged<#=name#>System (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.<#=name#>.Added()); + } + + protected override bool Filter(GameEntity entity) + { +<# + if (IsTag) + { +#> + return !entity.isDestroyed && entity.isWasSynced && entity.is<#=name#>; +<# + } + else + { +#> + return !entity.isDestroyed && entity.isWasSynced && entity.has<#=name#>; +<# + } +#> + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.ChangedComponents.AddUShort(e.id.Value); +<# + if (IsTag) + { +#> + _server.ChangedComponents.AddUShort(<#=ComponentId#>); +<# + } + else + { +#> + e.<#=firstLowerName#>.Serialize(_server.ChangedComponents); +<# + } +#> + _server.ChangedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.cs b/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.cs new file mode 100644 index 0000000..687167d --- /dev/null +++ b/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.cs @@ -0,0 +1,492 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Systems +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class SyncRemovedComponentSystemGenerator : SyncRemovedComponentSystemGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using System.Collections.Generic;\r\nusing Entitas;\r\nusing Sources.Networking.Serve" + + "r;\r\n\r\npublic class ServerCaptureRemoved"); + + #line 9 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write("System : ReactiveSystem\r\n{\r\n\tprivate readonly ServerNetworkSystem _se" + + "rver;\r\n\tpublic ServerCaptureRemoved"); + + #line 12 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write("System (Contexts contexts, Services services) : base(contexts.game)\r\n\t{\r\n\t\t_serve" + + "r = services.ServerSystem;\r\n\t}\r\n\t\t\r\n\tprotected override ICollector G" + + "etTrigger(IContext context) {\r\n\t\treturn context.CreateCollector(Game" + + "Matcher."); + + #line 18 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write(".Removed());\r\n\t}\r\n\t\t\r\n\tprotected override bool Filter(GameEntity entity)\r\n\t{\r\n"); + + #line 23 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + + if (IsTag) + { + + + #line default + #line hidden + this.Write("\t\treturn !entity.isDestroyed && entity.isWasSynced && entity.is"); + + #line 27 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write(";\r\n"); + + #line 28 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" return !entity.isDestroyed && entity.isWasSynced && !entity.has"); + + #line 33 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentName)); + + #line default + #line hidden + this.Write(";\r\n"); + + #line 34 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + + } + + + #line default + #line hidden + this.Write(@" } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort("); + + #line 44 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(ComponentId)); + + #line default + #line hidden + this.Write(");\r\n\t\t _server.RemovedComponentsCount++;\r\n\t\t}\r\n\t}\r\n}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Entitas-Sync\Generators\Generators\Generators\Sync\Systems\SyncRemovedComponentSystemGenerator.tt" + +private string _ComponentNameField; + +/// +/// Access the ComponentName parameter of the template. +/// +private string ComponentName +{ + get + { + return this._ComponentNameField; + } +} + +private ushort _ComponentIdField; + +/// +/// Access the ComponentId parameter of the template. +/// +private ushort ComponentId +{ + get + { + return this._ComponentIdField; + } +} + +private bool _IsTagField; + +/// +/// Access the IsTag parameter of the template. +/// +private bool IsTag +{ + get + { + return this._IsTagField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNameValueAcquired = false; +if (this.Session.ContainsKey("ComponentName")) +{ + this._ComponentNameField = ((string)(this.Session["ComponentName"])); + ComponentNameValueAcquired = true; +} +if ((ComponentNameValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentName"); + if ((data != null)) + { + this._ComponentNameField = ((string)(data)); + } +} +bool ComponentIdValueAcquired = false; +if (this.Session.ContainsKey("ComponentId")) +{ + this._ComponentIdField = ((ushort)(this.Session["ComponentId"])); + ComponentIdValueAcquired = true; +} +if ((ComponentIdValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentId"); + if ((data != null)) + { + this._ComponentIdField = ((ushort)(data)); + } +} +bool IsTagValueAcquired = false; +if (this.Session.ContainsKey("IsTag")) +{ + this._IsTagField = ((bool)(this.Session["IsTag"])); + IsTagValueAcquired = true; +} +if ((IsTagValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsTag"); + if ((data != null)) + { + this._IsTagField = ((bool)(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class SyncRemovedComponentSystemGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.tt b/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.tt new file mode 100644 index 0000000..31908aa --- /dev/null +++ b/Generators/Generators/Generators/Sync/Systems/SyncRemovedComponentSystemGenerator.tt @@ -0,0 +1,48 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentName" type="System.String"#> +<#@ parameter name="ComponentId" type="System.UInt16"#> +<#@ parameter name="IsTag" type="System.Boolean"#> +using System.Collections.Generic; +using Entitas; +using Sources.Networking.Server; + +public class ServerCaptureRemoved<#=ComponentName#>System : ReactiveSystem +{ + private readonly ServerNetworkSystem _server; + public ServerCaptureRemoved<#=ComponentName#>System (Contexts contexts, Services services) : base(contexts.game) + { + _server = services.ServerSystem; + } + + protected override ICollector GetTrigger(IContext context) { + return context.CreateCollector(GameMatcher.<#=ComponentName#>.Removed()); + } + + protected override bool Filter(GameEntity entity) + { +<# + if (IsTag) + { +#> + return !entity.isDestroyed && entity.isWasSynced && entity.is<#=ComponentName#>; +<# + } + else + { +#> + return !entity.isDestroyed && entity.isWasSynced && !entity.has<#=ComponentName#>; +<# + } +#> + } + + protected override void Execute(List entities) { + if (_server.State != ServerState.Working) return; + + foreach (var e in entities) { + _server.RemovedComponents.AddUShort(e.id.Value); + _server.RemovedComponents.AddUShort(<#=ComponentId#>); + _server.RemovedComponentsCount++; + } + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.cs b/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.cs new file mode 100644 index 0000000..41c2228 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.cs @@ -0,0 +1,567 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Utility +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class PackEntityUtilityGenerator : PackEntityUtilityGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("using NetStack.Serialization;\r\n\r\npublic static class PackEntityUtility\r\n{\r\n pu" + + "blic static void Pack(GameEntity e, BitBuffer buffer)\r\n {\r\n\t\tushort counter =" + + " 0;\r\n\r\n"); + + #line 13 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + +for (int i = 0; i < ComponentNames.Length; i++) +{ + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; + + + + #line default + #line hidden + this.Write("\t\tvar has"); + + #line 20 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" = false;\r\n"); + + #line 21 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + + if (isTag) + { + + + #line default + #line hidden + this.Write(" if(e.is"); + + #line 26 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(")\r\n"); + + #line 27 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" if(e.has"); + + #line 32 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(")\r\n"); + + #line 33 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + } + + + #line default + #line hidden + this.Write("\t\t{\r\n\t\t\thas"); + + #line 37 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" = true;\r\n\t\t\tcounter++;\r\n\t\t}\r\n\r\n\t"); + + #line 41 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write("\r\n\t\tbuffer.AddUShort(counter);\r\n\r\n"); + + #line 47 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + +for (int i = 0; i < ComponentNames.Length; i++) +{ + var name = ComponentNames[i].Replace("Component", ""); + var firstLowerName = char.ToLowerInvariant(name[0]) + name.Substring(1); + var id = ComponentIds[i]; + var isTag = IsTags[i]; + + + + #line default + #line hidden + this.Write(" if (has"); + + #line 56 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(")\r\n {\r\n"); + + #line 58 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + + if (isTag) + { + + + #line default + #line hidden + this.Write(" buffer.AddUShort("); + + #line 63 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(id)); + + #line default + #line hidden + this.Write(");\r\n"); + + #line 64 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" e."); + + #line 69 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(firstLowerName)); + + #line default + #line hidden + this.Write(".Serialize(buffer);\r\n"); + + #line 70 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n\r\n\t"); + + #line 75 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write("\t}\r\n}\r\n"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\PackEntityUtilityGenerator.tt" + +private string[] _ComponentNamesField; + +/// +/// Access the ComponentNames parameter of the template. +/// +private string[] ComponentNames +{ + get + { + return this._ComponentNamesField; + } +} + +private ushort[] _ComponentIdsField; + +/// +/// Access the ComponentIds parameter of the template. +/// +private ushort[] ComponentIds +{ + get + { + return this._ComponentIdsField; + } +} + +private bool[] _IsTagsField; + +/// +/// Access the IsTags parameter of the template. +/// +private bool[] IsTags +{ + get + { + return this._IsTagsField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNamesValueAcquired = false; +if (this.Session.ContainsKey("ComponentNames")) +{ + this._ComponentNamesField = ((string[])(this.Session["ComponentNames"])); + ComponentNamesValueAcquired = true; +} +if ((ComponentNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentNames"); + if ((data != null)) + { + this._ComponentNamesField = ((string[])(data)); + } +} +bool ComponentIdsValueAcquired = false; +if (this.Session.ContainsKey("ComponentIds")) +{ + this._ComponentIdsField = ((ushort[])(this.Session["ComponentIds"])); + ComponentIdsValueAcquired = true; +} +if ((ComponentIdsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentIds"); + if ((data != null)) + { + this._ComponentIdsField = ((ushort[])(data)); + } +} +bool IsTagsValueAcquired = false; +if (this.Session.ContainsKey("IsTags")) +{ + this._IsTagsField = ((bool[])(this.Session["IsTags"])); + IsTagsValueAcquired = true; +} +if ((IsTagsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsTags"); + if ((data != null)) + { + this._IsTagsField = ((bool[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class PackEntityUtilityGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.tt b/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.tt new file mode 100644 index 0000000..0375488 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Utility/PackEntityUtilityGenerator.tt @@ -0,0 +1,79 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentNames" type="System.String[]"#> +<#@ parameter name="ComponentIds" type="System.UInt16[]"#> +<#@ parameter name="IsTags" type="System.Boolean[]"#> +using NetStack.Serialization; + +public static class PackEntityUtility +{ + public static void Pack(GameEntity e, BitBuffer buffer) + { + ushort counter = 0; + +<# +for (int i = 0; i < ComponentNames.Length; i++) +{ + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; + +#> + var has<#=name#> = false; +<# + + if (isTag) + { +#> + if(e.is<#=name#>) +<# + } + else + { +#> + if(e.has<#=name#>) +<# + } + #> + { + has<#=name#> = true; + counter++; + } + + <# +} +#> + + buffer.AddUShort(counter); + +<# +for (int i = 0; i < ComponentNames.Length; i++) +{ + var name = ComponentNames[i].Replace("Component", ""); + var firstLowerName = char.ToLowerInvariant(name[0]) + name.Substring(1); + var id = ComponentIds[i]; + var isTag = IsTags[i]; + +#> + if (has<#=name#>) + { +<# + + if (isTag) + { +#> + buffer.AddUShort(<#=id#>); +<# + } + else + { +#> + e.<#=firstLowerName#>.Serialize(buffer); +<# + } + #> + } + + <# +} +#> + } +} diff --git a/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.cs b/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.cs new file mode 100644 index 0000000..04b30e2 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.cs @@ -0,0 +1,734 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 15.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace Generators.Sync.Utility +{ + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public partial class UnpackEntityUtilityGenerator : UnpackEntityUtilityGeneratorBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write(@"using System.Text; +using NetStack.Serialization; +using Sources.Tools; + +public static class UnpackEntityUtility +{ + public static void CreateEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var addedComponents = new StringBuilder(128); + + var e = game.CreateEntity(); + + var componentsCount = buffer.ReadUShort(); + + for (int j = 0; j < componentsCount; j++) + { + var componentId = buffer.ReadUShort(); + + switch (componentId) + { +"); + + #line 27 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var fullName = ComponentNames[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; + + + #line default + #line hidden + this.Write(" case "); + + #line 35 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(id)); + + #line default + #line hidden + this.Write(":\r\n\t\t\t\t\t{\r\n\t\t\t\t\t addedComponents.Append(\" "); + + #line 37 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" \");\r\n"); + + #line 38 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +if (isTag) +{ + + + #line default + #line hidden + this.Write(" e.is"); + + #line 42 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" = true;\r\n"); + + #line 43 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} +else +{ + + + #line default + #line hidden + this.Write(" var lookup = GameComponentsLookup."); + + #line 48 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(";\r\n\t\t\t\t\t\tvar comp = e.CreateComponent<"); + + #line 49 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(fullName)); + + #line default + #line hidden + this.Write(">(lookup);\r\n\t\t\t\t\t\tcomp.Deserialize(buffer);\r\n\t\t\t\t\t\te.AddComponent(lookup, comp);\r" + + "\n"); + + #line 52 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write("\t\t\t\t\t}\r\n\t\t\t\t\t break;\r\n"); + + #line 57 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write(@" } + } + Logger.I.Log(""UnpackEntityUtility"", $"" Entity-{e.id.Value}: created - ({addedComponents})""); + } + } + + public static void ChangeComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { +"); + + #line 76 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var fullName = ComponentNames[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; + + + #line default + #line hidden + this.Write(" case "); + + #line 84 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(id)); + + #line default + #line hidden + this.Write(":\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tLogger.I.Log(\"UnpackEntityUtility\", $\" Entity-{entityId}: Change" + + "d "); + + #line 86 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" component\");\r\n"); + + #line 87 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +if (isTag) +{ + + + #line default + #line hidden + this.Write(" e.is"); + + #line 91 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" = true;\r\n"); + + #line 92 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} +else +{ + + + #line default + #line hidden + this.Write(" var lookup = GameComponentsLookup."); + + #line 97 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(";\r\n\t\t\t\t\t\tvar comp = e.CreateComponent<"); + + #line 98 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(fullName)); + + #line default + #line hidden + this.Write(">(lookup);\r\n\t\t\t\t comp.Deserialize(buffer);\r\n\t\t\t\t e.ReplaceComponent" + + "(lookup, comp);\r\n"); + + #line 101 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write("\t\t\t\t\t}\r\n\t\t\t\t\t break;\r\n"); + + #line 106 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write(@" } + } + } + + public static void RemoveComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { +"); + + #line 123 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; + + + #line default + #line hidden + this.Write(" case "); + + #line 130 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(id)); + + #line default + #line hidden + this.Write(":\r\n\t\t\t\t\t{\r\n\t\t\t\t\t Logger.I.Log(\"UnpackEntityUtility\", $\" Entity-{entityId}: Rem" + + "oved "); + + #line 132 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" component\");\r\n"); + + #line 133 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +if (isTag) +{ + + + #line default + #line hidden + this.Write(" e.is"); + + #line 137 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write(" = false;\r\n"); + + #line 138 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} +else +{ + + + #line default + #line hidden + this.Write(" e.Remove"); + + #line 143 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(name)); + + #line default + #line hidden + this.Write("();\r\n"); + + #line 144 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write("\t\t\t\t\t}\r\n\t\t\t\t\t break;\r\n"); + + #line 149 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +} + + + #line default + #line hidden + this.Write(@" } + } + } + + public static void RemoveEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var id = buffer.ReadUShort(); + var e = game.GetEntityWithId(id); + e.isDestroyed = true; + Logger.I.Log(""UnpackEntityUtility"", $"" Entity-{id}: is removed""); + } + } +}"); + return this.GenerationEnvironment.ToString(); + } + + #line 1 "C:\UnityProjects\Coop-JRPG\Generators\Generators\Generators\Sync\Utility\UnpackEntityUtilityGenerator.tt" + +private string[] _ComponentNamesField; + +/// +/// Access the ComponentNames parameter of the template. +/// +private string[] ComponentNames +{ + get + { + return this._ComponentNamesField; + } +} + +private ushort[] _ComponentIdsField; + +/// +/// Access the ComponentIds parameter of the template. +/// +private ushort[] ComponentIds +{ + get + { + return this._ComponentIdsField; + } +} + +private bool[] _IsTagsField; + +/// +/// Access the IsTags parameter of the template. +/// +private bool[] IsTags +{ + get + { + return this._IsTagsField; + } +} + + +/// +/// Initialize the template +/// +public virtual void Initialize() +{ + if ((this.Errors.HasErrors == false)) + { +bool ComponentNamesValueAcquired = false; +if (this.Session.ContainsKey("ComponentNames")) +{ + this._ComponentNamesField = ((string[])(this.Session["ComponentNames"])); + ComponentNamesValueAcquired = true; +} +if ((ComponentNamesValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentNames"); + if ((data != null)) + { + this._ComponentNamesField = ((string[])(data)); + } +} +bool ComponentIdsValueAcquired = false; +if (this.Session.ContainsKey("ComponentIds")) +{ + this._ComponentIdsField = ((ushort[])(this.Session["ComponentIds"])); + ComponentIdsValueAcquired = true; +} +if ((ComponentIdsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("ComponentIds"); + if ((data != null)) + { + this._ComponentIdsField = ((ushort[])(data)); + } +} +bool IsTagsValueAcquired = false; +if (this.Session.ContainsKey("IsTags")) +{ + this._IsTagsField = ((bool[])(this.Session["IsTags"])); + IsTagsValueAcquired = true; +} +if ((IsTagsValueAcquired == false)) +{ + object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IsTags"); + if ((data != null)) + { + this._IsTagsField = ((bool[])(data)); + } +} + + + } +} + + + + #line default + #line hidden + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + public class UnpackEntityUtilityGeneratorBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.tt b/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.tt new file mode 100644 index 0000000..6f45d40 --- /dev/null +++ b/Generators/Generators/Generators/Sync/Utility/UnpackEntityUtilityGenerator.tt @@ -0,0 +1,166 @@ +<#@ template language="C#" #> +<#@ parameter name="ComponentNames" type="System.String[]"#> +<#@ parameter name="ComponentIds" type="System.UInt16[]"#> +<#@ parameter name="IsTags" type="System.Boolean[]"#> +using System.Text; +using NetStack.Serialization; +using Sources.Tools; + +public static class UnpackEntityUtility +{ + public static void CreateEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var addedComponents = new StringBuilder(128); + + var e = game.CreateEntity(); + + var componentsCount = buffer.ReadUShort(); + + for (int j = 0; j < componentsCount; j++) + { + var componentId = buffer.ReadUShort(); + + switch (componentId) + { +<# +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var fullName = ComponentNames[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; +#> + case <#=id#>: + { + addedComponents.Append(" <#=name#> "); +<# +if (isTag) +{ +#> + e.is<#=name#> = true; +<# +} +else +{ +#> + var lookup = GameComponentsLookup.<#=name#>; + var comp = e.CreateComponent<<#=fullName#>>(lookup); + comp.Deserialize(buffer); + e.AddComponent(lookup, comp); +<# +} +#> + } + break; +<# +} +#> + } + } + Logger.I.Log("UnpackEntityUtility", $" Entity-{e.id.Value}: created - ({addedComponents})"); + } + } + + public static void ChangeComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { +<# +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var fullName = ComponentNames[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; +#> + case <#=id#>: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Changed <#=name#> component"); +<# +if (isTag) +{ +#> + e.is<#=name#> = true; +<# +} +else +{ +#> + var lookup = GameComponentsLookup.<#=name#>; + var comp = e.CreateComponent<<#=fullName#>>(lookup); + comp.Deserialize(buffer); + e.ReplaceComponent(lookup, comp); +<# +} +#> + } + break; +<# +} +#> + } + } + } + + public static void RemoveComponents(GameContext game, BitBuffer buffer, ushort componentCount) + { + for (int i = 0; i < componentCount; i++) + { + var entityId = buffer.ReadUShort(); + var componentId = buffer.ReadUShort(); + var e = game.GetEntityWithId(entityId); + + switch (componentId) + { +<# +for (int i = 0; i < ComponentNames.Length; i++) +{ + var id = ComponentIds[i]; + var name = ComponentNames[i].Replace("Component", ""); + var isTag = IsTags[i]; +#> + case <#=id#>: + { + Logger.I.Log("UnpackEntityUtility", $" Entity-{entityId}: Removed <#=name#> component"); +<# +if (isTag) +{ +#> + e.is<#=name#> = false; +<# +} +else +{ +#> + e.Remove<#=name#>(); +<# +} +#> + } + break; +<# +} +#> + } + } + } + + public static void RemoveEntities(GameContext game, BitBuffer buffer, ushort entityCount) + { + for (int i = 0; i < entityCount; i++) + { + var id = buffer.ReadUShort(); + var e = game.GetEntityWithId(id); + e.isDestroyed = true; + Logger.I.Log("UnpackEntityUtility", $" Entity-{id}: is removed"); + } + } +} \ No newline at end of file diff --git a/Generators/Generators/Generators/bin/Debug/Generators.dll b/Generators/Generators/Generators/bin/Debug/Generators.dll new file mode 100644 index 0000000..71c89de Binary files /dev/null and b/Generators/Generators/Generators/bin/Debug/Generators.dll differ diff --git a/Hash.userproperties b/Hash.userproperties new file mode 100644 index 0000000..e69de29 diff --git a/Jenny.properties b/Jenny.properties new file mode 100644 index 0000000..39d050d --- /dev/null +++ b/Jenny.properties @@ -0,0 +1,52 @@ +Jenny.SearchPaths = Assets\Plugins\DesperateDevs\Editor\Plugins, \ + Assets\Plugins\Entitas\Editor\Plugins + +Jenny.Plugins = DesperateDevs.CodeGeneration.Plugins, \ + DesperateDevs.CodeGeneration.Unity.Plugins, \ + Entitas.CodeGeneration.Plugins, \ + Entitas.VisualDebugging.CodeGeneration.Plugins + +Jenny.PreProcessors = DesperateDevs.CodeGeneration.Plugins.ValidateProjectPathPreProcessor, \ + DesperateDevs.CodeGeneration.Unity.Plugins.WarnIfCompilationErrorsPreProcessor, \ + DesperateDevs.CodeGeneration.Plugins.TargetFrameworkProfilePreProcessor + +Jenny.DataProviders = Entitas.CodeGeneration.Plugins.ComponentDataProvider, \ + Entitas.CodeGeneration.Plugins.ContextDataProvider, \ + Entitas.CodeGeneration.Plugins.EntityIndexDataProvider + +Jenny.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator, \ + Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, \ + Entitas.CodeGeneration.Plugins.ComponentEntityApiInterfaceGenerator, \ + Entitas.CodeGeneration.Plugins.ComponentGenerator, \ + Entitas.CodeGeneration.Plugins.ComponentLookupGenerator, \ + Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator, \ + Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, \ + Entitas.CodeGeneration.Plugins.ContextGenerator, \ + Entitas.CodeGeneration.Plugins.ContextMatcherGenerator, \ + Entitas.CodeGeneration.Plugins.ContextsGenerator, \ + Entitas.CodeGeneration.Plugins.EntityGenerator, \ + Entitas.CodeGeneration.Plugins.EntityIndexGenerator, \ + Entitas.CodeGeneration.Plugins.EventEntityApiGenerator, \ + Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator, \ + Entitas.CodeGeneration.Plugins.EventListenertInterfaceGenerator, \ + Entitas.CodeGeneration.Plugins.EventSystemGenerator, \ + Entitas.CodeGeneration.Plugins.EventSystemsGenerator, \ + Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \ + Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator + +Jenny.PostProcessors = DesperateDevs.CodeGeneration.Plugins.AddFileHeaderPostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.CleanTargetDirectoryPostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.MergeFilesPostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.NewLinePostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.WriteToDiskPostProcessor, \ + DesperateDevs.CodeGeneration.Plugins.ConsoleWriteLinePostProcessor, \ + DesperateDevs.CodeGeneration.Unity.Plugins.DebugLogPostProcessor + +Jenny.Server.Port = 3333 +Jenny.Client.Host = localhost +DesperateDevs.CodeGeneration.Plugins.ProjectPath = Assembly-CSharp.csproj +Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll +Entitas.CodeGeneration.Plugins.Contexts = Game +Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false +DesperateDevs.CodeGeneration.Plugins.TargetDirectory = Assets diff --git a/Packages/manifest.json b/Packages/manifest.json new file mode 100644 index 0000000..324d1ed --- /dev/null +++ b/Packages/manifest.json @@ -0,0 +1,41 @@ +{ + "dependencies": { + "com.unity.ads": "2.0.8", + "com.unity.analytics": "3.3.2", + "com.unity.collab-proxy": "1.2.16", + "com.unity.package-manager-ui": "2.1.2", + "com.unity.purchasing": "2.0.6", + "com.unity.textmeshpro": "2.0.0", + "com.unity.timeline": "1.0.0", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..4f31e74 --- /dev/null +++ b/ProjectSettings/AudioManager.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 1024 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_AmbisonicDecoderPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 diff --git a/ProjectSettings/ClusterInputManager.asset b/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..cdc1f3e --- /dev/null +++ b/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_ClothInterCollisionDistance: 0 + m_ClothInterCollisionStiffness: 0 + m_ContactsGeneration: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_AutoSimulation: 1 + m_AutoSyncTransforms: 0 + m_ReuseCollisionCallbacks: 1 + m_ClothInterCollisionSettingsToggle: 0 + m_ContactPairsMode: 0 + m_BroadphaseType: 0 + m_WorldBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 250, y: 250, z: 250} + m_WorldSubdivisions: 8 + m_FrictionType: 0 + m_EnableEnhancedDeterminism: 0 + m_EnableUnifiedHeightmaps: 1 + m_DefaultMaxAngluarSpeed: 7 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..0147887 --- /dev/null +++ b/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: [] + m_configObjects: {} diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..96c6ed5 --- /dev/null +++ b/ProjectSettings/EditorSettings.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_ExternalVersionControlSupport: Hidden Meta Files + m_SerializationMode: 2 + m_LineEndingsForNewScripts: 2 + m_DefaultBehaviorMode: 0 + m_PrefabRegularEnvironment: {fileID: 0} + m_PrefabUIEnvironment: {fileID: 0} + m_SpritePackerMode: 0 + m_SpritePackerPaddingPower: 1 + m_EtcTextureCompressorBehavior: 1 + m_EtcTextureFastCompressor: 1 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 4 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp + m_ProjectGenerationRootNamespace: + m_CollabEditorSettings: + inProgressEnabled: 1 + m_EnableTextureStreamingInEditMode: 1 + m_EnableTextureStreamingInPlayMode: 1 + m_AsyncShaderCompilation: 1 diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..f3874f6 --- /dev/null +++ b/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_CustomRenderPipeline: {fileID: 0} + m_TransparencySortMode: 0 + m_TransparencySortAxis: {x: 0, y: 0, z: 1} + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_InstancingStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepShadowMask: 1 + m_LightmapKeepSubtractive: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 + m_AlbedoSwatchInfos: [] + m_LightsUseLinearIntensity: 0 + m_LightsUseColorTemperature: 0 diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3b0b7c3 --- /dev/null +++ b/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + m_LastAgentTypeID: -887442657 + m_Settings: + - serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.75 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_SettingNames: + - Humanoid diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..4198911 --- /dev/null +++ b/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,56 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 4 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_DefaultContactOffset: 0.01 + m_JobOptions: + serializedVersion: 2 + useMultithreading: 0 + useConsistencySorting: 0 + m_InterpolationPosesPerJob: 100 + m_NewContactsPerJob: 30 + m_CollideContactsPerJob: 100 + m_ClearFlagsPerJob: 200 + m_ClearBodyForcesPerJob: 200 + m_SyncDiscreteFixturesPerJob: 50 + m_SyncContinuousFixturesPerJob: 50 + m_FindNearestContactsPerJob: 100 + m_UpdateTriggerContactsPerJob: 100 + m_IslandSolverCostThreshold: 100 + m_IslandSolverBodyCostScale: 1 + m_IslandSolverContactCostScale: 10 + m_IslandSolverJointCostScale: 10 + m_IslandSolverBodiesPerJob: 50 + m_IslandSolverContactsPerJob: 50 + m_AutoSimulation: 0 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_CallbacksOnDisable: 1 + m_ReuseCollisionCallbacks: 1 + m_AutoSyncTransforms: 0 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/ProjectSettings/PresetManager.asset b/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..636a595 --- /dev/null +++ b/ProjectSettings/PresetManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + m_DefaultList: [] diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..d8bbeb0 --- /dev/null +++ b/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,645 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 16 + productGUID: 28fba416b7246d24f9f5f47fb5a6fa4d + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: DefaultCompany + productName: Entitas-Sync-Framework + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosAppInBackgroundBehavior: 0 + displayResolutionDialog: 1 + iosAllowHTTPDownload: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidBlitType: 0 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 1 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 1 + graphicsJobs: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 1 + allowFullscreenSwitch: 1 + graphicsJobMode: 0 + fullscreenMode: 3 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + vulkanEnableSetSRGBWrite: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleVersion: 0.1 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 1 + xboxOneEnable7thCore: 1 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 + hololens: + depthFormat: 1 + depthBufferSharingEnabled: 1 + lumin: + depthFormat: 0 + frameTiming: 2 + enableGLCache: 0 + glCacheMaxBlobSize: 524288 + glCacheMaxFileSize: 8388608 + oculus: + sharedDepthBuffer: 1 + dashSupport: 1 + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 + protectGraphicsMemory: 0 + enableFrameTimingStats: 0 + useHDRDisplay: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: {} + buildNumber: {} + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 16 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 1 + VertexChannelCompressionMask: 4054 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 9.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 9.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + iPhone65inPortraitSplashScreen: {fileID: 0} + iPhone65inLandscapeSplashScreen: {fileID: 0} + iPhone61inPortraitSplashScreen: {fileID: 0} + iPhone61inLandscapeSplashScreen: {fileID: 0} + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 0 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 + appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 + clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea + templatePackageId: com.unity.template.3d@2.3.1 + templateDefaultScene: Assets/Scenes/SampleScene.unity + AndroidTargetArchitectures: 1 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: '{inproject}: ' + AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 + AndroidTVCompatibility: 0 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + resolutionDialogBanner: {fileID: 0} + m_BuildTargetIcons: [] + m_BuildTargetPlatformIcons: [] + m_BuildTargetBatching: + - m_BuildTarget: Standalone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: tvOS + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: Android + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: iPhone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: WebGL + m_StaticBatching: 0 + m_DynamicBatching: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: AndroidPlayer + m_APIs: 150000000b000000 + m_Automatic: 0 + - m_BuildTarget: iOSSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: AppleTVSupport + m_APIs: 10000000 + m_Automatic: 0 + - m_BuildTarget: WebGLSupport + m_APIs: 0b000000 + m_Automatic: 1 + m_BuildTargetVRSettings: + - m_BuildTarget: Standalone + m_Enabled: 0 + m_Devices: + - Oculus + - OpenVR + m_BuildTargetEnableVuforiaSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + openGLRequireES32: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupLightmapSettings: [] + playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 + switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 11 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 + ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + monoEnv: + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + spritePackerPolicy: + webGLMemorySize: 16 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 1 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLWasmStreaming: 0 + scriptingDefineSymbols: + 1: ODIN_INSPECTOR;NETSTACK_SPAN + platformArchitecture: {} + scriptingBackend: {} + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} + incrementalIl2cppBuild: {} + allowUnsafeCode: 1 + additionalIl2CppArgs: + scriptingRuntimeVersion: 1 + gcIncremental: 0 + gcWBarrierValidation: 0 + apiCompatibilityLevelPerPlatform: + Standalone: 6 + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: Template_3D + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: Template_3D + wsaImages: {} + metroTileShortName: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroTargetDeviceFamilies: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 1 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + xboxOneScriptCompiler: 1 + XboxOneOverrideIdentityName: + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: + UNet: 1 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: + facebookSdkVersion: 7.9.4 + facebookAppId: + facebookCookies: 1 + facebookLogging: 1 + facebookStatus: 1 + facebookXfbml: 0 + facebookFrictionlessRequests: 1 + apiCompatibilityLevel: 6 + cloudProjectId: + framebufferDepthMemorylessMode: 0 + projectName: + organizationId: + cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..241ebd0 --- /dev/null +++ b/ProjectSettings/ProjectVersion.txt @@ -0,0 +1,2 @@ +m_EditorVersion: 2019.1.0f2 +m_EditorVersionWithRevision: 2019.1.0f2 (292b93d75a2c) diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..ed26313 --- /dev/null +++ b/ProjectSettings/QualitySettings.asset @@ -0,0 +1,231 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Very Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Medium + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: High + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Very High + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Ultra + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 16 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + Lumin: 5 + Nintendo 3DS: 5 + Nintendo Switch: 5 + PS4: 5 + PSP2: 2 + Standalone: 5 + WebGL: 3 + Windows Store Apps: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 2 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..1c92a78 --- /dev/null +++ b/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..558a017 --- /dev/null +++ b/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..c3ae9a0 --- /dev/null +++ b/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 1 + m_Enabled: 1 + m_TestMode: 0 + m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events + m_EventUrl: https://cdp.cloud.unity3d.com/v1/events + m_ConfigUrl: https://config.uca.cloud.unity3d.com + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com + m_Enabled: 0 + m_LogBufferSize: 10 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 0 + m_TestMode: 0 + m_InitializeOnStartup: 1 + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/ProjectSettings/VFXManager.asset b/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..6e0eaca --- /dev/null +++ b/ProjectSettings/VFXManager.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/ProjectSettings/XRSettings.asset b/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file