1using System.Globalization;
25 return $
"local:{m_componentReference}";
28 return $
"id:{m_entityReference}:{m_componentReference}";
31 return $
"name:{m_entityReference}:{m_componentReference}";
33 throw new Exception(
"Unknown entity reference type.");
53 throw new Exception(
"Unknown entity reference type.");
60 if (throwIfNotFound) {
61 throw new Exception($
"Required entity \"{ReferenceString}\" not found.");
89 result.m_componentReference = component !=
null ? component.ValuesDictionary.DatabaseObject.Name :
string.Empty;
94 if (component?.
Entity ==
null) {
98 result.m_componentReference = component !=
null ? component.ValuesDictionary.DatabaseObject.Name :
string.Empty;
106 result.m_entityReference = num.ToString(CultureInfo.InvariantCulture);
107 result.m_componentReference =
string.Empty;
119 result.m_entityReference = entityReference;
120 result.m_componentReference = component !=
null ? component.ValuesDictionary.DatabaseObject.Name :
string.Empty;
128 result.m_entityReference = entityReference;
129 result.m_componentReference =
string.Empty;
137 result.m_entityReference =
string.Empty;
138 result.m_componentReference =
string.Empty;
141 string[] array = referenceString.Split(
':');
142 if (array.Length == 1) {
144 result.m_entityReference =
string.Empty;
145 result.m_componentReference = array[0];
148 if (array.Length != 2
149 && array.Length != 3) {
150 throw new Exception(
"Invalid entity reference. Too many tokens.");
152 if (array[0] ==
"null"
153 && array.Length == 2) {
155 result.m_entityReference =
string.Empty;
156 result.m_componentReference =
string.Empty;
158 else if (array[0] ==
"local"
159 && array.Length == 2) {
161 result.m_componentReference = array[1];
163 else if (array[0] ==
"id") {
165 result.m_entityReference = array[1];
166 result.m_componentReference = array.Length == 3 ? array[2] :
string.Empty;
169 if (!(array[0] ==
"name")) {
170 throw new Exception(
"Unknown entity reference type.");
173 result.m_entityReference = array[1];
174 result.m_componentReference = array.Length == 3 ? array[2] :
string.Empty;
Component FindComponent(Type type, string name, bool throwOnError)
virtual Entity FindEntity(int EntityID)
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
static EntityReference FromName(Entity entity)
static EntityReference Null
static EntityReference FromId(Component component)
static EntityReference FromReferenceString(string referenceString)
static EntityReference FromId(Entity entity)
static EntityReference FromId(Entity entity, EntityToIdMap entityToIdMap)
Entity GetEntity(Entity localEntity, IdToEntityMap idToEntityMap, bool throwIfNotFound)
ReferenceType m_referenceType
static EntityReference FromName(Component component)
static EntityReference FromId(Component component, EntityToIdMap entityToIdMap)
T GetComponent< T >(Entity localEntity, IdToEntityMap idToEntityMap, bool throwIfNotFound)
string m_componentReference
static EntityReference Local(Component component)