mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
fix changes
This commit is contained in:
parent
10a35f3a2c
commit
b565510a69
57
src/EcsRelationTable.cs
Normal file
57
src/EcsRelationTable.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using DCFApixels.DragonECS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace DCFApixels.Assets.DragonECS.src
|
||||
{
|
||||
public class EcsRelationTable
|
||||
{
|
||||
public readonly IEcsWorld leftWorld;
|
||||
public readonly IEcsWorld rightWorld;
|
||||
|
||||
|
||||
private int[] _relationEntities; //dense
|
||||
private int[] _leftMapping;
|
||||
private int[] _rgihtMapping;
|
||||
|
||||
private int _relationsCount;
|
||||
|
||||
|
||||
#region Properties
|
||||
public int RelationsCount
|
||||
{
|
||||
get => _relationsCount;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
internal EcsRelationTable(IEcsWorld leftWorld, IEcsWorld rightWorld)
|
||||
{
|
||||
this.leftWorld = leftWorld;
|
||||
this.rightWorld = rightWorld;
|
||||
|
||||
_relationEntities = new int[512];
|
||||
_leftMapping = new int[512];
|
||||
_rgihtMapping = new int[512];
|
||||
|
||||
_relationsCount = 0;
|
||||
}
|
||||
|
||||
public void AddRelation(int leftEnttiyID, int rightEntityID)
|
||||
{
|
||||
|
||||
}
|
||||
public void RemoveRelationLeft(int entityID)
|
||||
{
|
||||
|
||||
}
|
||||
public void RemoveRelationRight(int entityID)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
50
src/Interfaces/IEcsEntityComponentTable.cs
Normal file
50
src/Interfaces/IEcsEntityComponentTable.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public interface IEcsEntityComponentTable
|
||||
{
|
||||
#region Properties
|
||||
public bool IsEmpty { get; }
|
||||
public Type ArchetypeType { get; }
|
||||
//public int ID { get; }
|
||||
public int EntitesCount { get; }
|
||||
public int EntitesCapacity { get; }
|
||||
#endregion
|
||||
|
||||
#region GetterMethods
|
||||
public ReadOnlySpan<IEcsPool> GetAllPools();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public EcsPool<T> GetPool<T>() where T : struct;
|
||||
public EcsPool<T> UncheckedGetPool<T>() where T : struct;
|
||||
|
||||
public EcsFilter Entities<TComponent>() where TComponent : struct;
|
||||
public EcsFilter Filter<TInc>() where TInc : struct, IInc;
|
||||
public EcsFilter Filter<TInc, TExc>() where TInc : struct, IInc where TExc : struct, IExc;
|
||||
|
||||
public ent NewEntity();
|
||||
public void DelEntity(ent entity);
|
||||
public bool EntityIsAlive(int entityID, short gen);
|
||||
public ent GetEntity(int entityID);
|
||||
public void Destroy();
|
||||
|
||||
public bool IsMaskCompatible<TInc>(int entity) where TInc : struct, IInc;
|
||||
public bool IsMaskCompatible<TInc, TExc>(int entity) where TInc : struct, IInc where TExc : struct, IExc;
|
||||
public bool IsMaskCompatible(EcsMask mask, int entity);
|
||||
public bool IsMaskCompatibleWithout(EcsMask mask, int entity, int otherPoolID);
|
||||
|
||||
internal void OnEntityComponentAdded(int entityID, int changedPoolID);
|
||||
internal void OnEntityComponentRemoved(int entityID, int changedPoolID);
|
||||
|
||||
public int GetComponentID<T>();
|
||||
internal void RegisterGroup(EcsGroup group);
|
||||
#endregion
|
||||
}
|
||||
}
|
29
src/rel.cs
Normal file
29
src/rel.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DCFApixels.DragonECS.TODO
|
||||
{
|
||||
//TODO реализовать систему отношений.
|
||||
//идея есть миры-коннекторы, они являются наборами сущьностей-отношений
|
||||
//сущьности отношения, это теже сущьности но их полный идентификатор - это 32 бита - одна сущьность и 32 - другая
|
||||
//айди миров левой и правой части записываются в мир-коннектор и для конвертации айди сущьности в полный идентификатор, надо взять данные из него.
|
||||
//Проблема: если хранить айди мира для левой части отношения в одном месте, а для правого в другом и только раграничивать на лево и право будет проблема с тем что связи работают только в одном направлении
|
||||
//в этом мире вообще не будет вестиь учет гена, потому что для отношений он не нужен
|
||||
|
||||
//миры коннекторы можно назвать Relations или RealtionTable
|
||||
|
||||
|
||||
|
||||
// left entity id - 32 bits
|
||||
// right entity id - 32 bits
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 4, Size = 8)]
|
||||
public struct rel
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public int l;
|
||||
[FieldOffset(1)]
|
||||
public int r;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user