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