|
|
|
@ -17,6 +17,11 @@ public class TypeEntityInfo : BaseEntityInfo |
|
|
|
|
public bool IsSingleton { get; } |
|
|
|
|
public bool IsRelation { get; } |
|
|
|
|
|
|
|
|
|
// Built-in entities error if they don't exist. |
|
|
|
|
// When a module is built-in, most attributes become descriptive, |
|
|
|
|
// and don't change or affect the entity they're attached to. |
|
|
|
|
public bool IsBuiltIn { get; protected set; } |
|
|
|
|
|
|
|
|
|
public bool IsValueType => Symbol.IsValueType; |
|
|
|
|
public bool IsReferenceType => Symbol.IsReferenceType; |
|
|
|
|
// TODO: Make sure that component has (instance) fields, non-component entity does not have fields. |
|
|
|
@ -30,6 +35,10 @@ public class TypeEntityInfo : BaseEntityInfo |
|
|
|
|
IsComponent = Has("Component"); |
|
|
|
|
IsSingleton = Has("Singleton"); |
|
|
|
|
IsRelation = Has("Relation"); |
|
|
|
|
|
|
|
|
|
IsBuiltIn = !IsModule && !IsEntity && !IsTag |
|
|
|
|
&& !IsComponent && !IsSingleton && !IsRelation |
|
|
|
|
&& (EntityPath != null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override IEnumerable<Diagnostic> ValidateSelf() |
|
|
|
@ -49,7 +58,14 @@ public class TypeEntityInfo : BaseEntityInfo |
|
|
|
|
if (IsComponent) attributeList.Add("Component"); |
|
|
|
|
if (IsSingleton) attributeList.Add("Singleton"); |
|
|
|
|
|
|
|
|
|
switch (attributeList) { |
|
|
|
|
switch (attributeList) |
|
|
|
|
{ |
|
|
|
|
// No attributes are only valid if [Path] is set. |
|
|
|
|
case [ ]: |
|
|
|
|
if (!IsBuiltIn) yield return Diagnostic.Create( |
|
|
|
|
Descriptors.AttributesRequireTypeOrPath, Location, |
|
|
|
|
$"[{string.Join(", ", attributeList)}]"); |
|
|
|
|
break; |
|
|
|
|
// A single attribute is valid. |
|
|
|
|
case [ _ ]: |
|
|
|
|
// The following are valid attribute combinations. |
|
|
|
@ -70,6 +86,10 @@ public class TypeEntityInfo : BaseEntityInfo |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// In in a built-in module, this entity is built-in, too. |
|
|
|
|
if (Parent is ModuleEntityInfo { IsBuiltIn: true }) |
|
|
|
|
IsBuiltIn = true; |
|
|
|
|
|
|
|
|
|
// Singletons are special kinds of components. |
|
|
|
|
if (IsSingleton) IsComponent = true; |
|
|
|
|
} |
|
|
|
|