You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			108 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			108 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
| //------------------------------------------------------------------------------
 | |
| // <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 GameContext game { get; set; }
 | |
|     public InputContext input { get; set; }
 | |
| 
 | |
|     public Entitas.IContext[] allContexts { get { return new Entitas.IContext [] { game, input }; } }
 | |
| 
 | |
|     public Contexts() {
 | |
|         game = new GameContext();
 | |
|         input = new InputContext();
 | |
| 
 | |
|         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 ID = "ID";
 | |
| 
 | |
|     [Entitas.CodeGeneration.Attributes.PostConstructor]
 | |
|     public void InitializeEntityIndices() {
 | |
|         game.AddEntityIndex(new Entitas.PrimaryEntityIndex<GameEntity, int>(
 | |
|             ID,
 | |
|             game.GetGroup(GameMatcher.ID),
 | |
|             (e, c) => ((IDComponent)c).Value));
 | |
|     }
 | |
| }
 | |
| 
 | |
| public static class ContextsExtensions {
 | |
| 
 | |
|     public static GameEntity GetEntityWithID(this GameContext context, int value) {
 | |
|         return ((Entitas.PrimaryEntityIndex<GameEntity, int>)context.GetEntityIndex(Contexts.ID)).GetEntity(value);
 | |
|     }
 | |
| }
 | |
| //------------------------------------------------------------------------------
 | |
| // <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(game);
 | |
|             CreateContextObserver(input);
 | |
|         } catch(System.Exception) {
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void CreateContextObserver(Entitas.IContext context) {
 | |
|         if (UnityEngine.Application.isPlaying) {
 | |
|             var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context);
 | |
|             UnityEngine.Object.DontDestroyOnLoad(observer.gameObject);
 | |
|         }
 | |
|     }
 | |
| 
 | |
| #endif
 | |
| }
 |