//------------------------------------------------------------------------------
//
// This code was generated by Entitas.CodeGeneration.Plugins.ContextsGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
public partial class Contexts : Entitas.IContexts {
public static Contexts sharedInstance {
get {
if (_sharedInstance == null) {
_sharedInstance = new Contexts();
}
return _sharedInstance;
}
set { _sharedInstance = value; }
}
static Contexts _sharedInstance;
public CombatContext combat { get; set; }
public LogicContext logic { get; set; }
public Entitas.IContext[] allContexts { get { return new Entitas.IContext [] { combat, logic }; } }
public Contexts() {
combat = new CombatContext();
logic = new LogicContext();
var postConstructors = System.Linq.Enumerable.Where(
GetType().GetMethods(),
method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute))
);
foreach (var postConstructor in postConstructors) {
postConstructor.Invoke(this, null);
}
}
public void Reset() {
var contexts = allContexts;
for (int i = 0; i < contexts.Length; i++) {
contexts[i].Reset();
}
}
}
//------------------------------------------------------------------------------
//
// This code was generated by Entitas.CodeGeneration.Plugins.EntityIndexGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
public partial class Contexts {
public const string FactionFaction = "FactionFaction";
public const string FactionSelectUseType = "FactionSelectUseType";
[Entitas.CodeGeneration.Attributes.PostConstructor]
public void InitializeEntityIndices() {
combat.AddEntityIndex(new Entitas.EntityIndex(
FactionFaction,
combat.GetGroup(CombatMatcher.Faction),
(e, c) => ((CoreGame.Render.FactionComponent)c).faction));
combat.AddEntityIndex(new Entitas.EntityIndex(
FactionSelectUseType,
combat.GetGroup(CombatMatcher.Faction),
(e, c) => ((CoreGame.Render.FactionComponent)c).selectUseType));
}
}
public static class ContextsExtensions {
public static System.Collections.Generic.HashSet GetEntitiesWithFactionFaction(this CombatContext context, CoreGame.Render.Faction faction) {
return ((Entitas.EntityIndex)context.GetEntityIndex(Contexts.FactionFaction)).GetEntities(faction);
}
public static System.Collections.Generic.HashSet GetEntitiesWithFactionSelectUseType(this CombatContext context, CoreGame.Render.SelectUseType selectUseType) {
return ((Entitas.EntityIndex)context.GetEntityIndex(Contexts.FactionSelectUseType)).GetEntities(selectUseType);
}
}
//------------------------------------------------------------------------------
//
// This code was generated by Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
public partial class Contexts {
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
[Entitas.CodeGeneration.Attributes.PostConstructor]
public void InitializeContextObservers() {
try {
CreateContextObserver(combat);
CreateContextObserver(logic);
} catch(System.Exception e) {
UnityEngine.Debug.LogError(e);
}
}
public void CreateContextObserver(Entitas.IContext context) {
if (UnityEngine.Application.isPlaying) {
var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context);
UnityEngine.Object.DontDestroyOnLoad(observer.gameObject);
}
}
#endif
}