Browse Source

Remove Svelto.Context and Svelto.Factories

tags/Rel2b2
sebas77 6 years ago
parent
commit
92143d906e
43 changed files with 7 additions and 296 deletions
  1. +0
    -75
      Svelto.ECS/Context/ContextNotifier.cs
  2. +0
    -65
      Svelto.ECS/Context/Factories/GameObjectFactory.cs
  3. +0
    -21
      Svelto.ECS/Context/Factories/MonoBehaviourFactory.cs
  4. +0
    -11
      Svelto.ECS/Context/ICompositionRoot.cs
  5. +0
    -11
      Svelto.ECS/Context/IContextNotifer.cs
  6. +0
    -11
      Svelto.ECS/Context/IUnityCompositionRoot.cs
  7. +0
    -8
      Svelto.ECS/Context/IWaitForFrameworkDestruction.cs
  8. +0
    -8
      Svelto.ECS/Context/IWaitForFrameworkInitialization.cs
  9. +0
    -51
      Svelto.ECS/Context/UnityContext.cs
  10. +0
    -0
      Svelto.ECS/DataStructures/TypeSafeDictionary.cs
  11. +0
    -0
      Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs
  12. +0
    -0
      Svelto.ECS/Dispatcher/DispatchOnChange.cs
  13. +0
    -0
      Svelto.ECS/Dispatcher/DispatcherOnSet.cs
  14. +0
    -0
      Svelto.ECS/EnginesRootEngines.cs
  15. +4
    -4
      Svelto.ECS/EnginesRootEntities.cs
  16. +0
    -0
      Svelto.ECS/EnginesRootSubmission.cs
  17. +0
    -0
      Svelto.ECS/EntityDescriptor.cs
  18. +0
    -0
      Svelto.ECS/EntitySubmissionScheduler.cs
  19. +0
    -0
      Svelto.ECS/EntityView.cs
  20. +0
    -0
      Svelto.ECS/EntityViewBuilder.cs
  21. +0
    -0
      Svelto.ECS/EntityViewsDB.cs
  22. +0
    -0
      Svelto.ECS/Experimental/StructNodeCollections.cs
  23. +0
    -0
      Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs
  24. +0
    -0
      Svelto.ECS/Extensions/Unity/UnitySumbmissionEntityViewScheduler .cs
  25. +0
    -14
      Svelto.ECS/Factories/IGameObjectFactory.cs
  26. +0
    -14
      Svelto.ECS/Factories/IMonoBehaviourFactory.cs
  27. +0
    -0
      Svelto.ECS/GenericEntityDescriptor.cs
  28. +0
    -0
      Svelto.ECS/IEngine.cs
  29. +3
    -3
      Svelto.ECS/IEnginesInterfaces.cs
  30. +0
    -0
      Svelto.ECS/IEntityDescriptorHolder.cs
  31. +0
    -0
      Svelto.ECS/IEntityViewsDB.cs
  32. +0
    -0
      Svelto.ECS/MixedEntityDescriptor.cs
  33. +0
    -0
      Svelto.ECS/MultiEntityViewsEngine.cs
  34. +0
    -0
      Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs
  35. +0
    -0
      Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerMenuItem.cs
  36. +0
    -0
      Svelto.ECS/Profiler/Editor/EngineProfiler/EnginesMonitor.cs
  37. +0
    -0
      Svelto.ECS/Profiler/Editor/EngineProfiler/ProfilerEditorLayout.cs
  38. +0
    -0
      Svelto.ECS/Profiler/EngineInfo.cs
  39. +0
    -0
      Svelto.ECS/Profiler/EngineProfiler.cs
  40. +0
    -0
      Svelto.ECS/Profiler/EngineProfilerBehaviour.cs
  41. +0
    -0
      Svelto.ECS/RemoveEntityImplementor.cs
  42. +0
    -0
      Svelto.ECS/Sequencer.cs
  43. +0
    -0
      Svelto.ECS/SingleEntityViewEngine.cs

+ 0
- 75
Svelto.ECS/Context/ContextNotifier.cs View File

@@ -1,75 +0,0 @@
using System;
using System.Collections.Generic;
using WeakReferenceI = Svelto.DataStructures.WeakReference<Svelto.Context.IWaitForFrameworkInitialization>;
using WeakReferenceD = Svelto.DataStructures.WeakReference<Svelto.Context.IWaitForFrameworkDestruction>;

namespace Svelto.Context
{
public class ContextNotifier : IContextNotifer
{
public ContextNotifier()
{
_toInitialize = new List<WeakReferenceI>();
_toDeinitialize = new List<WeakReferenceD>();
}

public void AddFrameworkDestructionListener(IWaitForFrameworkDestruction obj)
{
if (_toDeinitialize != null)
_toDeinitialize.Add(new WeakReferenceD(obj));
else
throw new Exception("An object is expected to be initialized after the framework has been deinitialized. Type: " + obj.GetType());
}

public void AddFrameworkInitializationListener(IWaitForFrameworkInitialization obj)
{
if (_toInitialize != null)
_toInitialize.Add(new WeakReferenceI(obj));
else
throw new Exception("An object is expected to be initialized after the framework has been initialized. Type: " + obj.GetType());
}

/// <summary>
/// A Context is meant to be deinitialized only once in its timelife
/// </summary>
public void NotifyFrameworkDeinitialized()
{
for (var i = _toDeinitialize.Count - 1; i >= 0; --i)
try
{
var obj = _toDeinitialize[i];
if (obj.IsAlive)
obj.Target.OnFrameworkDestroyed();
}
catch (Exception e)
{
Utility.Console.LogException(e);
}

_toDeinitialize = null;
}

/// <summary>
/// A Context is meant to be initialized only once in its timelife
/// </summary>
public void NotifyFrameworkInitialized()
{
for (var i = _toInitialize.Count - 1; i >= 0; --i)
try
{
var obj = _toInitialize[i];
if (obj.IsAlive)
obj.Target.OnFrameworkInitialized();
}
catch (Exception e)
{
Utility.Console.LogException(e);
}

_toInitialize = null;
}

List<WeakReferenceD> _toDeinitialize;
List<WeakReferenceI> _toInitialize;
}
}

+ 0
- 65
Svelto.ECS/Context/Factories/GameObjectFactory.cs View File

@@ -1,65 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
using System.Collections.Generic;
using UnityEngine;

namespace Svelto.Context
{
public class GameObjectFactory : Factories.IGameObjectFactory
{
public GameObjectFactory()
{
_prefabs = new Dictionary<string, GameObject[]>();
}

public GameObject Build(string prefabName)
{
DesignByContract.Check.Require(_prefabs.ContainsKey(prefabName), "Svelto.Factories.IGameObjectFactory -prefab was not found:" + prefabName);

var go = Build(_prefabs[prefabName][0]);

GameObject parent = _prefabs[prefabName][1];

if (parent != null)
{
Transform transform = go.transform;

var scale = transform.localScale;
var rotation = transform.localRotation;
var position = transform.localPosition;

parent.SetActive(true);

transform.parent = parent.transform;

transform.localPosition = position;
transform.localRotation = rotation;
transform.localScale = scale;
}

return go;
}

public virtual GameObject Build(GameObject prefab)
{
var copy = Object.Instantiate(prefab) as GameObject;

return copy;
}

/// <summary>
/// Register a prefab to be built later using a string ID.
/// </summary>
/// <param name="prefab">original prefab</param>
public void RegisterPrefab(GameObject prefab, string prefabName, GameObject parent = null)
{
var objects = new GameObject[2];

objects[0] = prefab; objects[1] = parent;

_prefabs.Add(prefabName, objects);
}

Dictionary<string, GameObject[]> _prefabs;
}
}
#endif

+ 0
- 21
Svelto.ECS/Context/Factories/MonoBehaviourFactory.cs View File

@@ -1,21 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
#region

using System;
using UnityEngine;

#endregion

namespace Svelto.Context
{
public class MonoBehaviourFactory : Factories.IMonoBehaviourFactory
{
virtual public M Build<M>(Func<M> constructor) where M : MonoBehaviour
{
var mb = constructor();

return mb;
}
}
}
#endif

+ 0
- 11
Svelto.ECS/Context/ICompositionRoot.cs View File

@@ -1,11 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
namespace Svelto.Context
{
public interface ICompositionRoot
{
void OnContextCreated(UnityContext contextHolder);
void OnContextInitialized();
void OnContextDestroyed();
}
}
#endif

+ 0
- 11
Svelto.ECS/Context/IContextNotifer.cs View File

@@ -1,11 +0,0 @@
namespace Svelto.Context
{
public interface IContextNotifer
{
void NotifyFrameworkInitialized();
void NotifyFrameworkDeinitialized();

void AddFrameworkInitializationListener(IWaitForFrameworkInitialization obj);
void AddFrameworkDestructionListener(IWaitForFrameworkDestruction obj);
}
}

+ 0
- 11
Svelto.ECS/Context/IUnityCompositionRoot.cs View File

@@ -1,11 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
namespace Svelto.Context
{
public interface IUnityCompositionRoot
{
void OnContextCreated(UnityContext contextHolder);
void OnContextInitialized();
void OnContextDestroyed();
}
}
#endif

+ 0
- 8
Svelto.ECS/Context/IWaitForFrameworkDestruction.cs View File

@@ -1,8 +0,0 @@
namespace Svelto.Context
{
public interface IWaitForFrameworkDestruction
{
void OnFrameworkDestroyed();
}
}


+ 0
- 8
Svelto.ECS/Context/IWaitForFrameworkInitialization.cs View File

@@ -1,8 +0,0 @@
namespace Svelto.Context
{
public interface IWaitForFrameworkInitialization
{
void OnFrameworkInitialized();
}
}


+ 0
- 51
Svelto.ECS/Context/UnityContext.cs View File

@@ -1,51 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
using System.Collections;
using Svelto.Context;
using UnityEngine;

public abstract class UnityContext:MonoBehaviour
{
protected abstract void OnAwake();

void Awake()
{
OnAwake();
}
}

//a Unity context is a platform specific context wrapper.
//Unity will drive the ICompositionRoot interface.
//OnContextCreated is called during the Awake of this MB
//OnContextInitialized is called one frame after the MB started
//OnContextDestroyed is called when the MB is destroyed
public class UnityContext<T>: UnityContext where T:class, ICompositionRoot, new()
{
protected override void OnAwake()
{
_applicationRoot = new T();

_applicationRoot.OnContextCreated(this);
}

void OnDestroy()
{
_applicationRoot.OnContextDestroyed();
}

void Start()
{
if (Application.isPlaying == true)
StartCoroutine(WaitForFrameworkInitialization());
}

IEnumerator WaitForFrameworkInitialization()
{
//let's wait until the end of the frame, so we are sure that all the awake and starts are called
yield return new WaitForEndOfFrame();

_applicationRoot.OnContextInitialized();
}

T _applicationRoot;
}
#endif

Svelto.ECS/ECS/DataStructures/TypeSafeDictionary.cs → Svelto.ECS/DataStructures/TypeSafeDictionary.cs View File


Svelto.ECS/ECS/DataStructures/TypeSafeFasterListForECS.cs → Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs View File


Svelto.ECS/ECS/Dispatcher/DispatchOnChange.cs → Svelto.ECS/Dispatcher/DispatchOnChange.cs View File


Svelto.ECS/ECS/Dispatcher/DispatcherOnSet.cs → Svelto.ECS/Dispatcher/DispatcherOnSet.cs View File


Svelto.ECS/ECS/EnginesRootEngines.cs → Svelto.ECS/EnginesRootEngines.cs View File


Svelto.ECS/ECS/EnginesRootEntities.cs → Svelto.ECS/EnginesRootEntities.cs View File

@@ -306,7 +306,7 @@ namespace Svelto.ECS
_weakEngine = weakReference;
}

public void BuildEntity<T>(int entityID, object[] implementors = null) where T : IEntityDescriptor, new()
public void BuildEntity<T>(int entityID, object[] implementors) where T : IEntityDescriptor, new()
{
_weakEngine.Target.BuildEntity<T>(entityID, implementors);
}
@@ -316,17 +316,17 @@ namespace Svelto.ECS
_weakEngine.Target.BuildEntity(entityID, entityDescriptor, implementors);
}

public void BuildMetaEntity<T>(int metaEntityID, object[] implementors = null) where T : IEntityDescriptor, new()
public void BuildMetaEntity<T>(int metaEntityID, object[] implementors) where T : IEntityDescriptor, new()
{
_weakEngine.Target.BuildMetaEntity<T>(metaEntityID, implementors);
}

public void BuildEntityInGroup<T>(int entityID, int groupID, object[] implementors = null) where T : IEntityDescriptor, new()
public void BuildEntityInGroup<T>(int entityID, int groupID, object[] implementors) where T : IEntityDescriptor, new()
{
_weakEngine.Target.BuildEntityInGroup<T>(entityID, groupID, implementors);
}

public void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, object[] implementors = null)
public void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, object[] implementors)
{
_weakEngine.Target.BuildEntityInGroup(entityID, groupID, entityDescriptor, implementors);
}

Svelto.ECS/ECS/EnginesRootSubmission.cs → Svelto.ECS/EnginesRootSubmission.cs View File


Svelto.ECS/ECS/EntityDescriptor.cs → Svelto.ECS/EntityDescriptor.cs View File


Svelto.ECS/ECS/EntitySubmissionScheduler.cs → Svelto.ECS/EntitySubmissionScheduler.cs View File


Svelto.ECS/ECS/EntityView.cs → Svelto.ECS/EntityView.cs View File


Svelto.ECS/ECS/EntityViewBuilder.cs → Svelto.ECS/EntityViewBuilder.cs View File


Svelto.ECS/ECS/EntityViewsDB.cs → Svelto.ECS/EntityViewsDB.cs View File


Svelto.ECS/ECS/Experimental/StructNodeCollections.cs → Svelto.ECS/Experimental/StructNodeCollections.cs View File


Svelto.ECS/ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs → Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs View File


Svelto.ECS/ECS/Extensions/Unity/UnitySumbmissionEntityViewScheduler .cs → Svelto.ECS/Extensions/Unity/UnitySumbmissionEntityViewScheduler .cs View File


+ 0
- 14
Svelto.ECS/Factories/IGameObjectFactory.cs View File

@@ -1,14 +0,0 @@
#if UNITY_5_3_OR_NEWER || UNITY_5
using UnityEngine;

namespace Svelto.Factories
{
public interface IGameObjectFactory
{
void RegisterPrefab(GameObject prefab, string type, GameObject parent = null);

GameObject Build(string type);
GameObject Build(GameObject prefab);
}
}
#endif

+ 0
- 14
Svelto.ECS/Factories/IMonoBehaviourFactory.cs View File

@@ -1,14 +0,0 @@
#if UNITY_5_3_OR_NEWER || UNITY_5

using System;
using UnityEngine;

namespace Svelto.Factories
{
public interface IMonoBehaviourFactory
{
M Build<M>(Func<M> constructor) where M:MonoBehaviour;
}
}

#endif

Svelto.ECS/ECS/GenericEntityDescriptor.cs → Svelto.ECS/GenericEntityDescriptor.cs View File


Svelto.ECS/ECS/IEngine.cs → Svelto.ECS/IEngine.cs View File


Svelto.ECS/ECS/IEnginesInterfaces.cs → Svelto.ECS/IEnginesInterfaces.cs View File

@@ -4,12 +4,12 @@ namespace Svelto.ECS
{
void Preallocate<T>(int size) where T : IEntityDescriptor, new();

void BuildEntity<T>(int entityID, object[] implementors = null) where T:IEntityDescriptor, new();
void BuildEntity<T>(int entityID, object[] implementors) where T:IEntityDescriptor, new();
void BuildEntity(int entityID, IEntityDescriptorInfo entityDescriptorInfo, object[] implementors);

void BuildMetaEntity<T>(int metaEntityID, object[] implementors = null) where T:IEntityDescriptor, new();
void BuildMetaEntity<T>(int metaEntityID, object[] implementors) where T:IEntityDescriptor, new();

void BuildEntityInGroup<T>(int entityID, int groupID, object[] implementors = null) where T:IEntityDescriptor, new();
void BuildEntityInGroup<T>(int entityID, int groupID, object[] implementors) where T:IEntityDescriptor, new();
void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, object[] implementors);
}

Svelto.ECS/ECS/IEntityDescriptorHolder.cs → Svelto.ECS/IEntityDescriptorHolder.cs View File


Svelto.ECS/ECS/IEntityViewsDB.cs → Svelto.ECS/IEntityViewsDB.cs View File


Svelto.ECS/ECS/MixedEntityDescriptor.cs → Svelto.ECS/MixedEntityDescriptor.cs View File


Svelto.ECS/ECS/MultiEntityViewsEngine.cs → Svelto.ECS/MultiEntityViewsEngine.cs View File


Svelto.ECS/ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs → Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs View File


Svelto.ECS/ECS/Profiler/Editor/EngineProfiler/EngineProfilerMenuItem.cs → Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerMenuItem.cs View File


Svelto.ECS/ECS/Profiler/Editor/EngineProfiler/EnginesMonitor.cs → Svelto.ECS/Profiler/Editor/EngineProfiler/EnginesMonitor.cs View File


Svelto.ECS/ECS/Profiler/Editor/EngineProfiler/ProfilerEditorLayout.cs → Svelto.ECS/Profiler/Editor/EngineProfiler/ProfilerEditorLayout.cs View File


Svelto.ECS/ECS/Profiler/EngineInfo.cs → Svelto.ECS/Profiler/EngineInfo.cs View File


Svelto.ECS/ECS/Profiler/EngineProfiler.cs → Svelto.ECS/Profiler/EngineProfiler.cs View File


Svelto.ECS/ECS/Profiler/EngineProfilerBehaviour.cs → Svelto.ECS/Profiler/EngineProfilerBehaviour.cs View File


Svelto.ECS/ECS/RemoveEntityImplementor.cs → Svelto.ECS/RemoveEntityImplementor.cs View File


Svelto.ECS/ECS/Sequencer.cs → Svelto.ECS/Sequencer.cs View File


Svelto.ECS/ECS/SingleEntityViewEngine.cs → Svelto.ECS/SingleEntityViewEngine.cs View File


Loading…
Cancel
Save