AI debug menu
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			This commit is contained in:
		
							parent
							
								
									b10b7e8407
								
							
						
					
					
						commit
						9c53027bf0
					
				
							
								
								
									
										55
									
								
								src/main/java/electrosphere/menu/debug/ImGuiAI.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/main/java/electrosphere/menu/debug/ImGuiAI.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,55 @@ | |||||||
|  | package electrosphere.menu.debug; | ||||||
|  | 
 | ||||||
|  | import electrosphere.engine.Globals; | ||||||
|  | import electrosphere.renderer.ui.imgui.ImGuiWindow; | ||||||
|  | import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback; | ||||||
|  | import electrosphere.server.ai.AI; | ||||||
|  | import imgui.ImGui; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * AI debug menus | ||||||
|  |  */ | ||||||
|  | public class ImGuiAI { | ||||||
|  |      | ||||||
|  |     //window for viewing information about the ai state | ||||||
|  |     protected static ImGuiWindow aiWindow; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates the windows in this file | ||||||
|  |      */ | ||||||
|  |     protected static void createAIWindows(){ | ||||||
|  |         createAIDebugWindow(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Client scene entity view | ||||||
|  |      */ | ||||||
|  |     protected static void createAIDebugWindow(){ | ||||||
|  |         aiWindow = new ImGuiWindow("AI"); | ||||||
|  |         aiWindow.setCallback(new ImGuiWindowCallback() { | ||||||
|  |             @Override | ||||||
|  |             public void exec() { | ||||||
|  |                 //ui framework text | ||||||
|  |                 ImGui.text("AI"); | ||||||
|  | 
 | ||||||
|  |                 //ai manager stuff | ||||||
|  |                 ImGui.text("AI Manager active: " + Globals.aiManager.isActive()); | ||||||
|  |                 if(ImGui.button("Toggle AI Manager")){ | ||||||
|  |                     Globals.aiManager.setActive(!Globals.aiManager.isActive()); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if(ImGui.collapsingHeader("AI Statuses")){ | ||||||
|  |                     for(AI ai : Globals.aiManager.getAIList()){ | ||||||
|  |                         if(ai.getCurrentTree() != null){ | ||||||
|  |                             ImGui.text("Entity ID " + ai.getParent().getId() + " - Active Tree: " + ai.getCurrentTree().getCurrentStateName() + " - Priority: " + ai.getCurrentTree().getCurrentStatePriority()); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |         aiWindow.setOpen(false); | ||||||
|  |         Globals.renderingEngine.getImGuiPipeline().addImGuiWindow(aiWindow); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -60,6 +60,7 @@ public class ImGuiWindowMacros { | |||||||
|         ImGuiEntityMacros.createClientEntityWindows(); |         ImGuiEntityMacros.createClientEntityWindows(); | ||||||
|         ImGuiUIFramework.createUIFrameworkWindows(); |         ImGuiUIFramework.createUIFrameworkWindows(); | ||||||
|         ImGuiControls.createControlsWindows(); |         ImGuiControls.createControlsWindows(); | ||||||
|  |         ImGuiAI.createAIDebugWindow(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -279,6 +280,10 @@ public class ImGuiWindowMacros { | |||||||
|                 if(ImGui.button("Control State Debug")){ |                 if(ImGui.button("Control State Debug")){ | ||||||
|                     ImGuiControls.controlsWindow.setOpen(true); |                     ImGuiControls.controlsWindow.setOpen(true); | ||||||
|                 } |                 } | ||||||
|  |                 //controls state debug | ||||||
|  |                 if(ImGui.button("AI State Debug")){ | ||||||
|  |                     ImGuiAI.aiWindow.setOpen(true); | ||||||
|  |                 } | ||||||
|                 //close button |                 //close button | ||||||
|                 if(ImGui.button("Close")){ |                 if(ImGui.button("Close")){ | ||||||
|                     mainDebugWindow.setOpen(false); |                     mainDebugWindow.setOpen(false); | ||||||
|  | |||||||
| @ -36,6 +36,11 @@ public class AI { | |||||||
|      */ |      */ | ||||||
|     List<AITree> trees = new LinkedList<AITree>(); |     List<AITree> trees = new LinkedList<AITree>(); | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * The currently active tree | ||||||
|  |      */ | ||||||
|  |     AITree currentTree = null; | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Constructs an AI from a list of trees that should be present on the ai |      * Constructs an AI from a list of trees that should be present on the ai | ||||||
|      * @param treeData The list of data on trees to be provided |      * @param treeData The list of data on trees to be provided | ||||||
| @ -75,7 +80,6 @@ public class AI { | |||||||
| 
 | 
 | ||||||
|         // |         // | ||||||
|         //Update state and find the highest priority tree |         //Update state and find the highest priority tree | ||||||
|         AITree currentTree = null; |  | ||||||
|         for(AITree tree : trees){ |         for(AITree tree : trees){ | ||||||
|             tree.updateStateAndPriority(); |             tree.updateStateAndPriority(); | ||||||
|             if(currentTree == null){ |             if(currentTree == null){ | ||||||
| @ -134,4 +138,20 @@ public class AI { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Gets the parent entity of this AI | ||||||
|  |      * @return The parent entity | ||||||
|  |      */ | ||||||
|  |     public Entity getParent(){ | ||||||
|  |         return this.parent; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Gets the current highest priority tree | ||||||
|  |      * @return The highest priority tree | ||||||
|  |      */ | ||||||
|  |     public AITree getCurrentTree(){ | ||||||
|  |         return this.currentTree; | ||||||
|  |     } | ||||||
|  |      | ||||||
| } | } | ||||||
|  | |||||||
| @ -68,6 +68,14 @@ public class AIManager { | |||||||
|         return active; |         return active; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Gets the list of all registered AIs | ||||||
|  |      * @return The list of AIs | ||||||
|  |      */ | ||||||
|  |     public List<AI> getAIList(){ | ||||||
|  |         return this.aiList; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Attaches an AI to an entity |      * Attaches an AI to an entity | ||||||
|      * @param entity The entity |      * @param entity The entity | ||||||
|  | |||||||
| @ -6,7 +6,6 @@ import electrosphere.engine.Globals; | |||||||
| import electrosphere.entity.Entity; | import electrosphere.entity.Entity; | ||||||
| import electrosphere.entity.Scene; | import electrosphere.entity.Scene; | ||||||
| import electrosphere.game.server.world.ServerWorldData; | import electrosphere.game.server.world.ServerWorldData; | ||||||
| import electrosphere.logger.LoggerInterface; |  | ||||||
| import electrosphere.net.parser.net.message.NetworkMessage; | import electrosphere.net.parser.net.message.NetworkMessage; | ||||||
| import electrosphere.script.ScriptEngine; | import electrosphere.script.ScriptEngine; | ||||||
| import electrosphere.server.content.ServerContentManager; | import electrosphere.server.content.ServerContentManager; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user