Class/Struct Info |
|---|
public class EntityRelationPair : RelationPair<int> 实体与实体关系的关系对,实体ID之间的对应关系。 通常通过GetBeRelatedLinks<TR>结构获取关系结果集使用。 |
Constructor Name And Description |
|---|
EntityRelationPair(int entityId, int targetId) 构造类似A --> B的关系对。 例如:小明拥有苹果。使用关系对表示为: 小明 -has-> 苹果。 |
EntityRelationPair(int entityId, int targetId, object targetObject) 构造类似A --> B(V)的关系对。 例如:小明拥有5苹果。使用关系对表示为: 小明 -has-> 苹果(5)。 |
Name | Type | Description |
|---|---|---|
EntityId | int | 表示关系对中的A的id。 |
RelationTarget | int | 表示关系对中的B的id。 |
TargetObject | object | 表示关系中的值V。 |
Constructor Name And Description |
|---|
void EntityRelationPair(int entityId, int targetId) 构造类似A -> B的关系对。 |
Parameters
Name | Type | Description |
|---|---|---|
entityId | int | 表示关系对中的A的id。 |
targetId | int | 表示关系对中的B的id。 |
Constructor Name And Description |
|---|
void EntityRelationPair(int entityId, int targetId, object targetObject) 构造类似A --> B(V)的关系对。 |
Parameters
Name | Type | Description |
|---|---|---|
entityId | int | 表示关系对中的A的id。 |
targetId | int | 表示关系对中的B的id。 |
targetObject | object | 表示关系中的值V。 |
Method |
|---|
string ToString() 将当前关系对的信息以字符串形式返回。 |
Return
Type | Description |
|---|---|
string | 当前关系对的信息。 |
Sample Code
var world = new IECSWorld();
var entity1 = world.CreateEntity(1);
var entity2 = world.CreateEntity(2);
var entity10 = world.CreateEntity(10);
entity1.AddRelation(new AttackRelation{ target = entity10 }, out _);
entity2.AddRelation(new AttackRelation{ target = entity10 }, out _);
List<EntityRelationPair> entity10RelationPairs = entity10.GetBeRelatedLinks<AttackRelation>();
AreEqual("{ ( 1 -> 10 ), ( 2 -> 10 ) }", CollectionToString.ToString(entity10RelationPairs));