mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
update
This commit is contained in:
parent
89bf620611
commit
9d6a78f08c
@ -163,6 +163,10 @@ namespace DCFApixels.DragonECS
|
||||
private static Dictionary<string, int> _nameIdTable = new Dictionary<string, int>();
|
||||
|
||||
#region Properties
|
||||
public static DebugService Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
public static DebugService CurrentThreadInstance
|
||||
{// ts завист от Set
|
||||
get
|
||||
@ -173,7 +177,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
if (_currentThreadInstance != _instance)
|
||||
{
|
||||
_currentThreadInstanceClone = _instance.Clone();
|
||||
_currentThreadInstanceClone = _instance.CreateThreadInstance();
|
||||
_threadServiceClonesSet.Add(_currentThreadInstanceClone);
|
||||
_currentThreadInstance = _instance;
|
||||
|
||||
@ -187,20 +191,18 @@ namespace DCFApixels.DragonECS
|
||||
return _currentThreadInstanceClone;
|
||||
}
|
||||
}
|
||||
public IEnumerable<MarkerInfo> MarkerInfos
|
||||
{
|
||||
get { return _nameIdTable.Select(o => new MarkerInfo(o.Key, o.Value)); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
static DebugService()
|
||||
{
|
||||
Set(new DefaultDebugService());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Set
|
||||
public static void Set<T>() where T : DebugService, new()
|
||||
{
|
||||
{// ts
|
||||
lock (_lock)
|
||||
{
|
||||
if (CurrentThreadInstance is T == false)
|
||||
@ -221,12 +223,9 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
var oldService = _instance;
|
||||
_instance = service;
|
||||
if (oldService != null)
|
||||
{ //TODO Так, всеже треды влияют друг на друга, скоерее всего проблема в использовании _nameIdTable/ Так вроде пофиксил, но не понял как конкретно
|
||||
foreach (var record in _nameIdTable)
|
||||
{
|
||||
service.OnNewProfilerMark(record.Value, record.Key);
|
||||
}
|
||||
foreach (var record in _nameIdTable)
|
||||
{
|
||||
service.OnNewProfilerMark(record.Value, record.Key);
|
||||
}
|
||||
service.OnServiceSetup(oldService);
|
||||
OnServiceChanged(service);
|
||||
@ -235,9 +234,9 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Setup/Clone
|
||||
#region OnServiceSetup/CreateThreadInstance
|
||||
protected virtual void OnServiceSetup(DebugService oldService) { }
|
||||
protected abstract DebugService Clone();
|
||||
protected abstract DebugService CreateThreadInstance();
|
||||
#endregion
|
||||
|
||||
#region Print/Break
|
||||
@ -351,7 +350,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
public sealed class NullDebugService : DebugService
|
||||
{
|
||||
protected sealed override DebugService Clone() { return this; }
|
||||
protected sealed override DebugService CreateThreadInstance() { return this; }
|
||||
public sealed override void Break() { }
|
||||
public sealed override void Print(string tag, object v) { }
|
||||
public sealed override void ProfilerMarkBegin(int id) { }
|
||||
@ -376,7 +375,7 @@ namespace DCFApixels.DragonECS
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.BackgroundColor = ConsoleColor.Black;
|
||||
}
|
||||
protected sealed override DebugService Clone()
|
||||
protected sealed override DebugService CreateThreadInstance()
|
||||
{
|
||||
return new DefaultDebugService();
|
||||
}
|
||||
|
@ -164,6 +164,24 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
return _world.GetPoolInstance<TPool>();
|
||||
}
|
||||
|
||||
public void Include<T>()
|
||||
{
|
||||
IncludeImplicit(typeof(T));
|
||||
}
|
||||
public void Exclude<T>()
|
||||
{
|
||||
ExcludeImplicit(typeof(T));
|
||||
}
|
||||
public void Include(Type type)
|
||||
{
|
||||
IncludeImplicit(type);
|
||||
}
|
||||
public void Exclude(Type type)
|
||||
{
|
||||
ExcludeImplicit(type);
|
||||
}
|
||||
|
||||
private void IncludeImplicit(Type type)
|
||||
{
|
||||
_maskBuilder.Inc(type);
|
||||
@ -172,6 +190,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
_maskBuilder.Exc(type);
|
||||
}
|
||||
|
||||
public TOtherAspect Combine<TOtherAspect>(int order = 0) where TOtherAspect : EcsAspect, new()
|
||||
{
|
||||
var result = _world.GetAspect<TOtherAspect>();
|
||||
|
@ -675,8 +675,8 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Inc/Exc/Combine
|
||||
[Obsolete("Use Inc(type)")] public Builder Include<T>() { return Inc<T>(); }
|
||||
[Obsolete("Use Exc(type)")] public Builder Exclude<T>() { return Exc<T>(); }
|
||||
[Obsolete("Use Inc<T>()")] public Builder Include<T>() { return Inc<T>(); }
|
||||
[Obsolete("Use Exc<T>()")] public Builder Exclude<T>() { return Exc<T>(); }
|
||||
[Obsolete("Use Inc(type)")] public Builder Include(Type type) { return Inc(type); }
|
||||
[Obsolete("Use Exc(type)")] public Builder Exclude(Type type) { return Exc(type); }
|
||||
|
||||
|
@ -932,7 +932,6 @@ namespace DCFApixels.DragonECS
|
||||
#region AddParams
|
||||
[Serializable]
|
||||
[DataContract]
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct AddParams : IEquatable<AddParams>
|
||||
{
|
||||
public static readonly AddParams Default = new AddParams();
|
||||
|
Loading…
Reference in New Issue
Block a user