mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
add PoolsCore namespace, add IEcsComponentType
This commit is contained in:
parent
d87e0fa948
commit
d2f761a884
@ -1,4 +1,6 @@
|
|||||||
namespace DCFApixels.DragonECS
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public sealed class EmptyAspect : EcsAspect { }
|
public sealed class EmptyAspect : EcsAspect { }
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace DCFApixels.DragonECS
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public partial class EcsWorld
|
public partial class EcsWorld
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -6,6 +7,8 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
/// <summary>Standard component</summary>
|
||||||
|
public interface IEcsComponent : IEcsComponentType { }
|
||||||
#if ENABLE_IL2CPP
|
#if ENABLE_IL2CPP
|
||||||
using Unity.IL2CPP.CompilerServices;
|
using Unity.IL2CPP.CompilerServices;
|
||||||
[Il2CppSetOption (Option.NullChecks, false)]
|
[Il2CppSetOption (Option.NullChecks, false)]
|
||||||
@ -297,8 +300,6 @@ namespace DCFApixels.DragonECS
|
|||||||
public static implicit operator EcsPool<T>(OptionalMarker a) { return a.GetInstance<EcsPool<T>>(); }
|
public static implicit operator EcsPool<T>(OptionalMarker a) { return a.GetInstance<EcsPool<T>>(); }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
/// <summary>Standard component</summary>
|
|
||||||
public interface IEcsComponent { }
|
|
||||||
public static class EcsPoolExt
|
public static class EcsPoolExt
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -1,67 +1,21 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS.PoolsCore
|
||||||
{
|
{
|
||||||
public interface IEcsReadonlyPool
|
public interface IEcsComponentType { }
|
||||||
{
|
|
||||||
#region Properties
|
|
||||||
int ComponentTypeID { get; }
|
|
||||||
Type ComponentType { get; }
|
|
||||||
EcsWorld World { get; }
|
|
||||||
int Count { get; }
|
|
||||||
bool IsReadOnly { get; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
bool Has(int entityID);
|
|
||||||
object GetRaw(int entityID);
|
|
||||||
void Copy(int fromEntityID, int toEntityID);
|
|
||||||
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Add/Remove Listeners
|
|
||||||
void AddListener(IEcsPoolEventListener listener);
|
|
||||||
void RemoveListener(IEcsPoolEventListener listener);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
public interface IEcsPool : IEcsReadonlyPool
|
|
||||||
{
|
|
||||||
#region Methods
|
|
||||||
void AddRaw(int entityID, object dataRaw);
|
|
||||||
void SetRaw(int entityID, object dataRaw);
|
|
||||||
void Del(int entityID);
|
|
||||||
void ClearAll();
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
/// <summary>A pool for struct components.</summary>
|
|
||||||
public interface IEcsStructPool<T> : IEcsPool where T : struct
|
|
||||||
{
|
|
||||||
ref T Add(int entityID);
|
|
||||||
ref readonly T Read(int entityID);
|
|
||||||
ref T Get(int entityID);
|
|
||||||
}
|
|
||||||
/// <summary>A pool for reference components of type T that instantiates components itself.</summary>
|
|
||||||
public interface IEcsClassPool<T> : IEcsPool where T : class
|
|
||||||
{
|
|
||||||
T Add(int entityID);
|
|
||||||
T Get(int entityID);
|
|
||||||
}
|
|
||||||
/// <summary>A pool for reference components of type T, which does not instantiate components itself but receives components from external sources..</summary>
|
|
||||||
public interface IEcsHybridPool<T> : IEcsPool where T : class
|
|
||||||
{
|
|
||||||
void Add(int entityID, T component);
|
|
||||||
T Get(int entityID);
|
|
||||||
}
|
|
||||||
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
||||||
public interface IEcsPoolImplementation : IEcsPool
|
public interface IEcsPoolImplementation : IEcsPool
|
||||||
{
|
{
|
||||||
|
#region Methods
|
||||||
void OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID);
|
void OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID);
|
||||||
void OnWorldResize(int newSize);
|
void OnWorldResize(int newSize);
|
||||||
void OnReleaseDelEntityBuffer(ReadOnlySpan<int> buffer);
|
void OnReleaseDelEntityBuffer(ReadOnlySpan<int> buffer);
|
||||||
void OnWorldDestroy();
|
void OnWorldDestroy();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
||||||
/// <typeparam name="T">Component type</typeparam>
|
/// <typeparam name="T">Component type</typeparam>
|
||||||
@ -90,18 +44,10 @@ namespace DCFApixels.DragonECS
|
|||||||
throw new ArgumentNullException("listener is null");
|
throw new ArgumentNullException("listener is null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class IEcsPoolImplementationExtensions
|
}
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static bool IsNullOrDummy(this IEcsPool self)
|
|
||||||
{
|
|
||||||
return self == null || self == EcsNullPool.instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Dummy EcsNullPool
|
namespace DCFApixels.DragonECS.Internal
|
||||||
namespace Internal
|
{
|
||||||
{
|
|
||||||
public struct NullComponent { }
|
public struct NullComponent { }
|
||||||
public sealed class EcsNullPool : IEcsPoolImplementation<NullComponent>
|
public sealed class EcsNullPool : IEcsPoolImplementation<NullComponent>
|
||||||
{
|
{
|
||||||
@ -188,6 +134,77 @@ namespace DCFApixels.DragonECS
|
|||||||
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
|
{
|
||||||
|
#region Interfaces
|
||||||
|
public interface IEcsReadonlyPool
|
||||||
|
{
|
||||||
|
#region Properties
|
||||||
|
int ComponentTypeID { get; }
|
||||||
|
Type ComponentType { get; }
|
||||||
|
EcsWorld World { get; }
|
||||||
|
int Count { get; }
|
||||||
|
bool IsReadOnly { get; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
bool Has(int entityID);
|
||||||
|
object GetRaw(int entityID);
|
||||||
|
void Copy(int fromEntityID, int toEntityID);
|
||||||
|
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Add/Remove Listeners
|
||||||
|
void AddListener(IEcsPoolEventListener listener);
|
||||||
|
void RemoveListener(IEcsPoolEventListener listener);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
public interface IEcsPool : IEcsReadonlyPool
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
void AddRaw(int entityID, object dataRaw);
|
||||||
|
void SetRaw(int entityID, object dataRaw);
|
||||||
|
void Del(int entityID);
|
||||||
|
void ClearAll();
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
/// <summary>A pool for struct components.</summary>
|
||||||
|
public interface IEcsStructPool<T> : IEcsPool where T : struct
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
ref T Add(int entityID);
|
||||||
|
ref readonly T Read(int entityID);
|
||||||
|
ref T Get(int entityID);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
/// <summary>A pool for reference components of type T that instantiates components itself.</summary>
|
||||||
|
public interface IEcsClassPool<T> : IEcsPool where T : class
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
T Add(int entityID);
|
||||||
|
T Get(int entityID);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
/// <summary>A pool for reference components of type T, which does not instantiate components itself but receives components from external sources..</summary>
|
||||||
|
public interface IEcsHybridPool<T> : IEcsPool where T : class
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
void Add(int entityID, T component);
|
||||||
|
T Get(int entityID);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Extensions
|
||||||
|
public static class IEcsPoolImplementationExtensions
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool IsNullOrDummy(this IEcsPool self)
|
||||||
|
{
|
||||||
|
return self == null || self == EcsNullPool.instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -6,6 +7,8 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
/// <summary>Component without data</summary>
|
||||||
|
public interface IEcsTagComponent : IEcsComponentType { }
|
||||||
#if ENABLE_IL2CPP
|
#if ENABLE_IL2CPP
|
||||||
using Unity.IL2CPP.CompilerServices;
|
using Unity.IL2CPP.CompilerServices;
|
||||||
[Il2CppSetOption (Option.NullChecks, false)]
|
[Il2CppSetOption (Option.NullChecks, false)]
|
||||||
@ -255,9 +258,6 @@ namespace DCFApixels.DragonECS
|
|||||||
public static implicit operator EcsTagPool<T>(OptionalMarker a) { return a.GetInstance<EcsTagPool<T>>(); }
|
public static implicit operator EcsTagPool<T>(OptionalMarker a) { return a.GetInstance<EcsTagPool<T>>(); }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Component without data</summary>
|
|
||||||
public interface IEcsTagComponent { }
|
|
||||||
public static class EcsTagPoolExt
|
public static class EcsTagPoolExt
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
Loading…
Reference in New Issue
Block a user