mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-12-08 05:49:08 +00:00
提交Unity 联机Pro
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18e04d324d7065944b7459a0f87cb397
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70754482b572b6f45a45b88319aea14a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
public class ContextObserver
|
||||
{
|
||||
public IContext context => _context;
|
||||
public IGroup[] groups => _groups.ToArray();
|
||||
public GameObject gameObject => _gameObject;
|
||||
|
||||
readonly IContext _context;
|
||||
readonly List<IGroup> _groups;
|
||||
readonly GameObject _gameObject;
|
||||
readonly Stack<EntityBehaviour> _entityBehaviourPool = new Stack<EntityBehaviour>();
|
||||
readonly StringBuilder _toStringBuilder = new StringBuilder();
|
||||
|
||||
public ContextObserver(IContext context)
|
||||
{
|
||||
_context = context;
|
||||
_groups = new List<IGroup>();
|
||||
_gameObject = new GameObject();
|
||||
_gameObject.AddComponent<ContextObserverBehaviour>().Init(this);
|
||||
|
||||
_context.OnEntityCreated += onEntityCreated;
|
||||
_context.OnGroupCreated += onGroupCreated;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
_context.OnEntityCreated -= onEntityCreated;
|
||||
_context.OnGroupCreated -= onGroupCreated;
|
||||
}
|
||||
|
||||
void onEntityCreated(IContext context, IEntity entity)
|
||||
{
|
||||
var entityBehaviour = _entityBehaviourPool.Count > 0
|
||||
? _entityBehaviourPool.Pop()
|
||||
: new GameObject().AddComponent<EntityBehaviour>();
|
||||
|
||||
entityBehaviour.Init(context, entity, _entityBehaviourPool);
|
||||
entityBehaviour.transform.SetParent(_gameObject.transform, false);
|
||||
entityBehaviour.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
void onGroupCreated(IContext context, IGroup group) => _groups.Add(group);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
_toStringBuilder.Length = 0;
|
||||
_toStringBuilder
|
||||
.Append(_context.contextInfo.name).Append(" (")
|
||||
.Append(_context.count).Append(" entities, ")
|
||||
.Append(_context.reusableEntitiesCount).Append(" reusable, ");
|
||||
|
||||
if (_context.retainedEntitiesCount != 0)
|
||||
{
|
||||
_toStringBuilder
|
||||
.Append(_context.retainedEntitiesCount).Append(" retained, ");
|
||||
}
|
||||
|
||||
_toStringBuilder
|
||||
.Append(_groups.Count)
|
||||
.Append(" groups)");
|
||||
|
||||
var str = _toStringBuilder.ToString();
|
||||
_gameObject.name = str;
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44106a1d7aa42a645b422dd242c67232
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class ContextObserverBehaviour : MonoBehaviour
|
||||
{
|
||||
public ContextObserver contextObserver => _contextObserver;
|
||||
|
||||
ContextObserver _contextObserver;
|
||||
|
||||
public void Init(ContextObserver contextObserver)
|
||||
{
|
||||
_contextObserver = contextObserver;
|
||||
Update();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_contextObserver == null)
|
||||
gameObject.DestroyGameObject();
|
||||
else if (_contextObserver.gameObject != null)
|
||||
_contextObserver.gameObject.name = _contextObserver.ToString();
|
||||
}
|
||||
|
||||
void OnDestroy() => _contextObserver.Deactivate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 351d49c00c4f09940929062a5cfb321b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
public static class ContextObserverExtension
|
||||
{
|
||||
public static ContextObserverBehaviour FindContextObserver(this IContext context)
|
||||
{
|
||||
var observers = Object.FindObjectsOfType<ContextObserverBehaviour>();
|
||||
for (var i = 0; i < observers.Length; i++)
|
||||
{
|
||||
var observer = observers[i];
|
||||
if (observer.contextObserver.context == context)
|
||||
return observer;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebb82ef8ef760a143803e1ea2eb001c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 033043b62f1e4df46a8e4c816b695a8e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,267 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
public enum AvgResetInterval
|
||||
{
|
||||
Always = 1,
|
||||
VeryFast = 30,
|
||||
Fast = 60,
|
||||
Normal = 120,
|
||||
Slow = 300,
|
||||
Never = int.MaxValue
|
||||
}
|
||||
|
||||
public class DebugSystems : Systems
|
||||
{
|
||||
public static AvgResetInterval avgResetInterval = AvgResetInterval.Never;
|
||||
|
||||
public int totalInitializeSystemsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var system in _initializeSystems)
|
||||
total += system is DebugSystems debugSystems ? debugSystems.totalInitializeSystemsCount : 1;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public int totalExecuteSystemsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var system in _executeSystems)
|
||||
total += system is DebugSystems debugSystems ? debugSystems.totalExecuteSystemsCount : 1;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public int totalCleanupSystemsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var system in _cleanupSystems)
|
||||
total += system is DebugSystems debugSystems ? debugSystems.totalCleanupSystemsCount : 1;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public int totalTearDownSystemsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var system in _tearDownSystems)
|
||||
total += system is DebugSystems debugSystems ? debugSystems.totalTearDownSystemsCount : 1;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public int totalSystemsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var system in _systems)
|
||||
total += system is DebugSystems debugSystems ? debugSystems.totalSystemsCount : 1;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public int initializeSystemsCount => _initializeSystems.Count;
|
||||
public int executeSystemsCount => _executeSystems.Count;
|
||||
public int cleanupSystemsCount => _cleanupSystems.Count;
|
||||
public int tearDownSystemsCount => _tearDownSystems.Count;
|
||||
|
||||
public string name => _name;
|
||||
public GameObject gameObject => _gameObject;
|
||||
public SystemInfo systemInfo => _systemInfo;
|
||||
public double executeDuration => _executeDuration;
|
||||
public double cleanupDuration => _cleanupDuration;
|
||||
|
||||
public SystemInfo[] initializeSystemInfos => _initializeSystemInfos.ToArray();
|
||||
public SystemInfo[] executeSystemInfos => _executeSystemInfos.ToArray();
|
||||
public SystemInfo[] syncSystemInfos => _syncSystemInfos.ToArray();
|
||||
public SystemInfo[] cleanupSystemInfos => _cleanupSystemInfos.ToArray();
|
||||
public SystemInfo[] tearDownSystemInfos => _tearDownSystemInfos.ToArray();
|
||||
|
||||
public bool paused;
|
||||
|
||||
string _name;
|
||||
|
||||
List<ISystem> _systems;
|
||||
GameObject _gameObject;
|
||||
SystemInfo _systemInfo;
|
||||
|
||||
List<SystemInfo> _initializeSystemInfos;
|
||||
List<SystemInfo> _executeSystemInfos;
|
||||
List<SystemInfo> _syncSystemInfos;
|
||||
List<SystemInfo> _cleanupSystemInfos;
|
||||
List<SystemInfo> _tearDownSystemInfos;
|
||||
|
||||
Stopwatch _stopwatch;
|
||||
|
||||
public Stopwatch StopWatch;
|
||||
|
||||
double _executeDuration;
|
||||
double _cleanupDuration;
|
||||
public double SyncDuration;
|
||||
|
||||
public DebugSystems(string name)
|
||||
{
|
||||
initialize(name);
|
||||
}
|
||||
|
||||
protected DebugSystems(bool noInit) { }
|
||||
|
||||
protected void initialize(string name)
|
||||
{
|
||||
_name = name;
|
||||
_gameObject = new GameObject(name);
|
||||
_gameObject.AddComponent<DebugSystemsBehaviour>().Init(this);
|
||||
|
||||
_systemInfo = new SystemInfo(this);
|
||||
|
||||
_systems = new List<ISystem>();
|
||||
_initializeSystemInfos = new List<SystemInfo>();
|
||||
_executeSystemInfos = new List<SystemInfo>();
|
||||
_syncSystemInfos = new List<SystemInfo>();
|
||||
_cleanupSystemInfos = new List<SystemInfo>();
|
||||
_tearDownSystemInfos = new List<SystemInfo>();
|
||||
|
||||
_stopwatch = new Stopwatch();
|
||||
}
|
||||
|
||||
public override Systems Add(ISystem system)
|
||||
{
|
||||
_systems.Add(system);
|
||||
|
||||
SystemInfo childSystemInfo;
|
||||
|
||||
if (system is DebugSystems debugSystems)
|
||||
{
|
||||
childSystemInfo = debugSystems.systemInfo;
|
||||
debugSystems.gameObject.transform.SetParent(_gameObject.transform, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
childSystemInfo = new SystemInfo(system);
|
||||
}
|
||||
|
||||
childSystemInfo.parentSystemInfo = _systemInfo;
|
||||
|
||||
if (childSystemInfo.isInitializeSystems) _initializeSystemInfos.Add(childSystemInfo);
|
||||
if (childSystemInfo.isExecuteSystems || childSystemInfo.isReactiveSystems) _executeSystemInfos.Add(childSystemInfo);
|
||||
if (childSystemInfo.isSyncSystems) _syncSystemInfos.Add(childSystemInfo);
|
||||
if (childSystemInfo.isCleanupSystems) _cleanupSystemInfos.Add(childSystemInfo);
|
||||
if (childSystemInfo.isTearDownSystems) _tearDownSystemInfos.Add(childSystemInfo);
|
||||
|
||||
return base.Add(system);
|
||||
}
|
||||
|
||||
public void ResetDurations()
|
||||
{
|
||||
foreach (var systemInfo in _executeSystemInfos)
|
||||
systemInfo.ResetDurations();
|
||||
|
||||
foreach (var system in _systems)
|
||||
if (system is DebugSystems debugSystems)
|
||||
debugSystems.ResetDurations();
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
for (var i = 0; i < _initializeSystems.Count; i++)
|
||||
{
|
||||
var systemInfo = _initializeSystemInfos[i];
|
||||
if (systemInfo.isActive)
|
||||
{
|
||||
_stopwatch.Reset();
|
||||
_stopwatch.Start();
|
||||
_initializeSystems[i].Initialize();
|
||||
_stopwatch.Stop();
|
||||
systemInfo.initializationDuration = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
if (!paused)
|
||||
StepExecute();
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
if (!paused)
|
||||
StepCleanup();
|
||||
}
|
||||
|
||||
public void StepExecute()
|
||||
{
|
||||
_executeDuration = 0;
|
||||
if (Time.frameCount % (int)avgResetInterval == 0)
|
||||
ResetDurations();
|
||||
|
||||
for (var i = 0; i < _executeSystems.Count; i++)
|
||||
{
|
||||
var systemInfo = _executeSystemInfos[i];
|
||||
if (systemInfo.isActive)
|
||||
{
|
||||
_stopwatch.Reset();
|
||||
_stopwatch.Start();
|
||||
_executeSystems[i].Execute();
|
||||
_stopwatch.Stop();
|
||||
var duration = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
_executeDuration += duration;
|
||||
systemInfo.AddExecutionDuration(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StepCleanup()
|
||||
{
|
||||
_cleanupDuration = 0;
|
||||
for (var i = 0; i < _cleanupSystems.Count; i++)
|
||||
{
|
||||
var systemInfo = _cleanupSystemInfos[i];
|
||||
if (systemInfo.isActive)
|
||||
{
|
||||
_stopwatch.Reset();
|
||||
_stopwatch.Start();
|
||||
_cleanupSystems[i].Cleanup();
|
||||
_stopwatch.Stop();
|
||||
var duration = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
_cleanupDuration += duration;
|
||||
systemInfo.AddCleanupDuration(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void TearDown()
|
||||
{
|
||||
for (var i = 0; i < _tearDownSystems.Count; i++)
|
||||
{
|
||||
var systemInfo = _tearDownSystemInfos[i];
|
||||
if (systemInfo.isActive)
|
||||
{
|
||||
_stopwatch.Reset();
|
||||
_stopwatch.Start();
|
||||
_tearDownSystems[i].TearDown();
|
||||
_stopwatch.Stop();
|
||||
systemInfo.teardownDuration = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc39bdd40a9bf7409103938352fbd72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
public class DebugSystemsBehaviour : MonoBehaviour
|
||||
{
|
||||
public DebugSystems systems => _systems;
|
||||
|
||||
DebugSystems _systems;
|
||||
|
||||
public void Init(DebugSystems systems)
|
||||
{
|
||||
_systems = systems;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdcef5607d436f846829c5ad34cf3008
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using JNGame.Sync;
|
||||
using JNGame.Sync.System;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
[Flags]
|
||||
public enum SystemInterfaceFlags
|
||||
{
|
||||
None = 0,
|
||||
IInitializeSystem = 1 << 1,
|
||||
IExecuteSystem = 1 << 2,
|
||||
ICleanupSystem = 1 << 3,
|
||||
ITearDownSystem = 1 << 4,
|
||||
IReactiveSystem = 1 << 5,
|
||||
ISyncSystem = 1 << 6
|
||||
}
|
||||
|
||||
public class SystemInfo
|
||||
{
|
||||
public ISystem system => _system;
|
||||
public string systemName => _systemName;
|
||||
|
||||
public bool isInitializeSystems => (_interfaceFlags & SystemInterfaceFlags.IInitializeSystem) == SystemInterfaceFlags.IInitializeSystem;
|
||||
public bool isExecuteSystems => (_interfaceFlags & SystemInterfaceFlags.IExecuteSystem) == SystemInterfaceFlags.IExecuteSystem;
|
||||
public bool isCleanupSystems => (_interfaceFlags & SystemInterfaceFlags.ICleanupSystem) == SystemInterfaceFlags.ICleanupSystem;
|
||||
public bool isTearDownSystems => (_interfaceFlags & SystemInterfaceFlags.ITearDownSystem) == SystemInterfaceFlags.ITearDownSystem;
|
||||
public bool isReactiveSystems => (_interfaceFlags & SystemInterfaceFlags.IReactiveSystem) == SystemInterfaceFlags.IReactiveSystem;
|
||||
public bool isSyncSystems => (_interfaceFlags & SystemInterfaceFlags.ISyncSystem) == SystemInterfaceFlags.ISyncSystem;
|
||||
|
||||
public double initializationDuration { get; set; }
|
||||
public double accumulatedExecutionDuration => _accumulatedExecutionDuration;
|
||||
public double minExecutionDuration => _minExecutionDuration;
|
||||
public double maxExecutionDuration => _maxExecutionDuration;
|
||||
public double averageExecutionDuration => _executionDurationsCount == 0 ? 0 : _accumulatedExecutionDuration / _executionDurationsCount;
|
||||
public double minSyncDuration => _minSyncDuration;
|
||||
public double maxSyncDuration => _maxSyncDuration;
|
||||
public double averageSyncDuration => _syncDurationsCount == 0 ? 0 : _accumulatedSyncDuration / _syncDurationsCount;
|
||||
public double accumulatedCleanupDuration => _accumulatedCleanupDuration;
|
||||
public double minCleanupDuration => _minCleanupDuration;
|
||||
public double maxCleanupDuration => _maxCleanupDuration;
|
||||
public double averageCleanupDuration => _cleanupDurationsCount == 0 ? 0 : _accumulatedCleanupDuration / _cleanupDurationsCount;
|
||||
public double cleanupDuration { get; set; }
|
||||
public double teardownDuration { get; set; }
|
||||
|
||||
public bool areAllParentsActive => parentSystemInfo == null || (parentSystemInfo.isActive && parentSystemInfo.areAllParentsActive);
|
||||
|
||||
public SystemInfo parentSystemInfo;
|
||||
public bool isActive;
|
||||
|
||||
readonly ISystem _system;
|
||||
readonly SystemInterfaceFlags _interfaceFlags;
|
||||
readonly string _systemName;
|
||||
|
||||
double _accumulatedExecutionDuration;
|
||||
double _minExecutionDuration;
|
||||
double _maxExecutionDuration;
|
||||
int _executionDurationsCount;
|
||||
|
||||
double _accumulatedSyncDuration;
|
||||
double _minSyncDuration;
|
||||
double _maxSyncDuration;
|
||||
int _syncDurationsCount;
|
||||
|
||||
double _accumulatedCleanupDuration;
|
||||
double _minCleanupDuration;
|
||||
double _maxCleanupDuration;
|
||||
int _cleanupDurationsCount;
|
||||
|
||||
public SystemInfo(ISystem system)
|
||||
{
|
||||
_system = system;
|
||||
_interfaceFlags = getInterfaceFlags(system);
|
||||
|
||||
var debugSystem = system as DebugSystems;
|
||||
_systemName = debugSystem != null
|
||||
? debugSystem.name
|
||||
: system.GetType().Name.RemoveSystemSuffix();
|
||||
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
public void AddExecutionDuration(double executionDuration)
|
||||
{
|
||||
if (executionDuration < _minExecutionDuration || _minExecutionDuration == 0)
|
||||
_minExecutionDuration = executionDuration;
|
||||
|
||||
if (executionDuration > _maxExecutionDuration)
|
||||
_maxExecutionDuration = executionDuration;
|
||||
|
||||
_accumulatedExecutionDuration += executionDuration;
|
||||
_executionDurationsCount += 1;
|
||||
}
|
||||
|
||||
public void AddSyncUpdateDuration(double executionDuration)
|
||||
{
|
||||
if (executionDuration < _minSyncDuration || _minSyncDuration == 0)
|
||||
_minSyncDuration = executionDuration;
|
||||
|
||||
if (executionDuration > _maxSyncDuration)
|
||||
_maxSyncDuration = executionDuration;
|
||||
|
||||
_accumulatedSyncDuration += executionDuration;
|
||||
_syncDurationsCount += 1;
|
||||
}
|
||||
|
||||
public void AddCleanupDuration(double cleanupDuration)
|
||||
{
|
||||
if (cleanupDuration < _minCleanupDuration || _minCleanupDuration == 0)
|
||||
_minCleanupDuration = cleanupDuration;
|
||||
|
||||
if (cleanupDuration > _maxCleanupDuration)
|
||||
_maxCleanupDuration = cleanupDuration;
|
||||
|
||||
_accumulatedCleanupDuration += cleanupDuration;
|
||||
_cleanupDurationsCount += 1;
|
||||
}
|
||||
|
||||
public void ResetDurations()
|
||||
{
|
||||
_accumulatedExecutionDuration = 0;
|
||||
_executionDurationsCount = 0;
|
||||
_accumulatedSyncDuration = 0;
|
||||
_syncDurationsCount = 0;
|
||||
|
||||
_accumulatedCleanupDuration = 0;
|
||||
_cleanupDurationsCount = 0;
|
||||
}
|
||||
|
||||
static SystemInterfaceFlags getInterfaceFlags(ISystem system)
|
||||
{
|
||||
var flags = SystemInterfaceFlags.None;
|
||||
if (system is IInitializeSystem)
|
||||
flags |= SystemInterfaceFlags.IInitializeSystem;
|
||||
|
||||
if (system is IReactiveSystem)
|
||||
flags |= SystemInterfaceFlags.IReactiveSystem;
|
||||
else if (system is IExecuteSystem)
|
||||
flags |= SystemInterfaceFlags.IExecuteSystem;
|
||||
|
||||
if (system is ICleanupSystem)
|
||||
flags |= SystemInterfaceFlags.ICleanupSystem;
|
||||
|
||||
if (system is ITearDownSystem)
|
||||
flags |= SystemInterfaceFlags.ITearDownSystem;
|
||||
|
||||
if (system is IJNSyncCycle)
|
||||
flags |= SystemInterfaceFlags.ISyncSystem;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0ed9e80cae92004cad7049532bf2dc5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41d616c184d2d4d4cb79de55b477a344
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class DontDrawComponentAttribute : Attribute { }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a0252024c73f0540b032d96f952ebd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class EntityBehaviour : MonoBehaviour
|
||||
{
|
||||
public IContext context => _context;
|
||||
public IEntity entity => _entity;
|
||||
|
||||
IContext _context;
|
||||
IEntity _entity;
|
||||
Stack<EntityBehaviour> _entityBehaviourPool;
|
||||
string _cachedName;
|
||||
|
||||
public void Init(IContext context, IEntity entity, Stack<EntityBehaviour> entityBehaviourPool)
|
||||
{
|
||||
_context = context;
|
||||
_entity = entity;
|
||||
_entityBehaviourPool = entityBehaviourPool;
|
||||
_entity.OnEntityReleased += onEntityReleased;
|
||||
gameObject.hideFlags = HideFlags.None;
|
||||
gameObject.SetActive(true);
|
||||
Update();
|
||||
}
|
||||
|
||||
void onEntityReleased(IEntity e)
|
||||
{
|
||||
_entity.OnEntityReleased -= onEntityReleased;
|
||||
gameObject.SetActive(false);
|
||||
gameObject.hideFlags = HideFlags.HideInHierarchy;
|
||||
_entityBehaviourPool.Push(this);
|
||||
_cachedName = null;
|
||||
name = string.Empty;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_entity != null && _cachedName != _entity.ToString())
|
||||
name = _cachedName = _entity.ToString();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_entity != null)
|
||||
_entity.OnEntityReleased -= onEntityReleased;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fa8320db813e7840b41db45b2583e0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entitas.VisualDebugging.Unity
|
||||
{
|
||||
public static class GameObjectDestroyExtension
|
||||
{
|
||||
public static void DestroyGameObject(this GameObject gameObject)
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
Object.Destroy(gameObject);
|
||||
else
|
||||
Object.DestroyImmediate(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 544d80be634caa5438caefb85c51ab0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user