File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,21 @@ public void RegisterRelation<T, TKey>()
188188 } ;
189189 }
190190 }
191+
192+ public void RegisterLinkRelation < T > ( )
193+ where T : struct , ILinkRelation
194+ {
195+ InitSchema ( ) ;
196+ if ( typeSet . Add ( typeof ( T ) ) )
197+ {
198+ AddType ( typeof ( T ) , SchemaTypeKind . Component ) ;
199+ RelationUtils . GetRelationKey < T , Entity > ( default ) ; // dummy call to prevent trimming required type info
200+ SchemaUtils . CreateRelationType < T > ( 0 , null , null ) ; // dummy call to prevent trimming required type info
201+ AbstractEntityRelations . CreateEntityRelationsNativeAot [ typeof ( T ) ] = ( componentType , archetype , heap ) => {
202+ return new EntityLinkRelations < T > ( componentType , archetype , heap ) ;
203+ } ;
204+ }
205+ }
191206
192207 public void RegisterTag < T > ( ) where T : struct , ITag
193208 {
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ public void Test_AOT_AddComponent_unknown()
8888 entity . AddComponent ( new MyComponent2 ( ) ) ;
8989 } ) ;
9090 }
91-
91+ #region IIndexedComponent<>
9292 [ TestMethod ]
9393 public void Test_AOT_IndexedComponents_class ( )
9494 {
@@ -161,8 +161,10 @@ public void Test_AOT_LinkComponents()
161161 entity3 . DeleteEntity ( ) ; // 1 2
162162 entity2 . HasComponent < AttackComponent > ( ) ; // false
163163 }
164-
165- // [TestMethod] TODO
164+ #endregion
165+
166+ #region IRelation<>
167+ [ TestMethod ]
166168 public void Test_AOT_LinkRelations ( )
167169 {
168170 var store = new EntityStore ( ) ;
@@ -212,6 +214,7 @@ public void Test_AOT_Relations()
212214 entity . RemoveRelation < InventoryItem , InventoryItemType > ( InventoryItemType . Axe ) ;
213215 entity . GetRelations < InventoryItem > ( ) ; // { Coin }
214216 }
217+ #endregion
215218
216219 struct Player : IIndexedComponent < string > // indexed field type: string
217220 {
@@ -249,7 +252,7 @@ private static EntitySchema CreateSchema()
249252 aot . RegisterIndexedComponentEntity < AttackComponent > ( ) ;
250253
251254 aot . RegisterRelation < InventoryItem , InventoryItemType > ( ) ;
252-
255+ aot . RegisterLinkRelation < AttackRelation > ( ) ;
253256
254257 return schemaCreated = aot . CreateSchema ( ) ;
255258 }
You can’t perform that action at this time.
0 commit comments