You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.5 KiB
119 lines
4.5 KiB
1 month ago
|
//------------------------------------------------------------------------------
|
||
|
// <auto-generated>
|
||
|
// 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.
|
||
|
// </auto-generated>
|
||
|
//------------------------------------------------------------------------------
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
// <auto-generated>
|
||
|
// 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.
|
||
|
// </auto-generated>
|
||
|
//------------------------------------------------------------------------------
|
||
|
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<CombatEntity, CoreGame.Render.Faction>(
|
||
|
FactionFaction,
|
||
|
combat.GetGroup(CombatMatcher.Faction),
|
||
|
(e, c) => ((CoreGame.Render.FactionComponent)c).faction));
|
||
|
|
||
|
combat.AddEntityIndex(new Entitas.EntityIndex<CombatEntity, CoreGame.Render.SelectUseType>(
|
||
|
FactionSelectUseType,
|
||
|
combat.GetGroup(CombatMatcher.Faction),
|
||
|
(e, c) => ((CoreGame.Render.FactionComponent)c).selectUseType));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static class ContextsExtensions {
|
||
|
|
||
|
public static System.Collections.Generic.HashSet<CombatEntity> GetEntitiesWithFactionFaction(this CombatContext context, CoreGame.Render.Faction faction) {
|
||
|
return ((Entitas.EntityIndex<CombatEntity, CoreGame.Render.Faction>)context.GetEntityIndex(Contexts.FactionFaction)).GetEntities(faction);
|
||
|
}
|
||
|
|
||
|
public static System.Collections.Generic.HashSet<CombatEntity> GetEntitiesWithFactionSelectUseType(this CombatContext context, CoreGame.Render.SelectUseType selectUseType) {
|
||
|
return ((Entitas.EntityIndex<CombatEntity, CoreGame.Render.SelectUseType>)context.GetEntityIndex(Contexts.FactionSelectUseType)).GetEntities(selectUseType);
|
||
|
}
|
||
|
}
|
||
|
//------------------------------------------------------------------------------
|
||
|
// <auto-generated>
|
||
|
// 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.
|
||
|
// </auto-generated>
|
||
|
//------------------------------------------------------------------------------
|
||
|
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
|
||
|
}
|