handle signals passing with no hooks
	
		
			
	
		
	
	
		
	
		
			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
							
								
									c3f824198b
								
							
						
					
					
						commit
						d36b2f3237
					
				| @ -1,8 +1,8 @@ | ||||
| import { Engine } from '/Scripts/engine/engine-interface' | ||||
| import { loggerScripts } from '/Scripts/compiler/host_access' | ||||
| import { Client, NamespaceClient } from '/Scripts/client/client' | ||||
| import { HookManager } from '/Scripts/engine/hooks/hook-manager' | ||||
| import { SceneLoader } from '/Scripts/engine/scene/scene-loader' | ||||
| import { Engine } from '/Scripts/types/engine' | ||||
| 
 | ||||
| /** | ||||
|  * The core engine values | ||||
|  | ||||
| @ -1,7 +1,12 @@ | ||||
| import { Engine } from "/Scripts/engine/engine-interface" | ||||
| import { Engine } from "/Scripts/types/engine" | ||||
| import { Hook } from "/Scripts/types/hook" | ||||
| import { Scene } from "/Scripts/types/scene" | ||||
| import { loggerScripts } from '/Scripts/compiler/host_access' | ||||
| 
 | ||||
| /** | ||||
|  * The global scene id | ||||
|  */ | ||||
| export const GLOBAL_SCENE_ID: number = -1 | ||||
| 
 | ||||
| /** | ||||
|  * The scope that the hook is firing from | ||||
| @ -71,10 +76,10 @@ export class HookManager { | ||||
|         const signalArray: Array<TrackedHook> = this.signalHookMap?.[hookSignal] ? this.signalHookMap?.[hookSignal] : [] | ||||
|         signalArray.push(trackedHook) | ||||
|         this.signalHookMap[hookSignal] = signalArray | ||||
|         console.log('register signal hook map') | ||||
|         console.log(hookSignal) | ||||
|         console.log(Object.keys(this.signalHookMap)) | ||||
|         console.log(this.signalHookMap[hookSignal]) | ||||
|         loggerScripts.DEBUG('register signal hook map') | ||||
|         loggerScripts.DEBUG(hookSignal) | ||||
|         loggerScripts.DEBUG(Object.keys(this.signalHookMap)) | ||||
|         loggerScripts.DEBUG(this.signalHookMap[hookSignal]) | ||||
|         //
 | ||||
|         //Scene related structures
 | ||||
|         //
 | ||||
| @ -117,19 +122,21 @@ export class HookManager { | ||||
|             }) | ||||
|         } else { | ||||
|             //There isn't a hook registered for this signal at the global level
 | ||||
|             console.log("No global hooks for signal " + signal) | ||||
|             loggerScripts.DEBUG("No global hooks for signal " + signal) | ||||
|         } | ||||
| 
 | ||||
|         //try firing at scene scope
 | ||||
|         const scene: Scene = this.engine.sceneLoader.getScene(instanceId) | ||||
|         const sceneHooks: Array<TrackedHook> = scene.signalHookMap[signal] | ||||
|         if(!!sceneHooks){ | ||||
|             sceneHooks.forEach(trackeHook => { | ||||
|                 trackeHook.callback(...argsRaw) | ||||
|             }) | ||||
|         } else { | ||||
|             //There isn't a hook registered for this signal at the scene level
 | ||||
|             console.log("No scene hooks for signal " + signal) | ||||
|         if(instanceId !== GLOBAL_SCENE_ID){ | ||||
|             //try firing at scene scope
 | ||||
|             const scene: Scene = this.engine.sceneLoader.getScene(instanceId) | ||||
|             const sceneHooks: Array<TrackedHook> = scene.signalHookMap[signal] | ||||
|             if(!!sceneHooks){ | ||||
|                 sceneHooks.forEach(trackeHook => { | ||||
|                     trackeHook.callback(...argsRaw) | ||||
|                 }) | ||||
|             } else { | ||||
|                 //There isn't a hook registered for this signal at the scene level
 | ||||
|                 loggerScripts.DEBUG("No scene hooks for signal " + signal) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import { Engine } from "/Scripts/engine/engine-interface"; | ||||
| import { Engine } from "/Scripts/types/engine"; | ||||
| import { Hook } from "/Scripts/types/hook"; | ||||
| import { Scene } from "/Scripts/types/scene"; | ||||
| 
 | ||||
| @ -58,7 +58,7 @@ export class SceneLoader { | ||||
|      * @param scene The scene | ||||
|      * @returns The id assigned to the instance of the scene | ||||
|      */ | ||||
|     createInstance(scene: Scene, isServerScene: boolean): number{ | ||||
|     createInstance(scene: Scene, isServerScene: boolean): number { | ||||
|         //add to the list of tracked scenes
 | ||||
|         const trackedScene: Scene = { | ||||
|             instanceId: this.sceneIdIncrementer++, | ||||
|  | ||||
| @ -28,3 +28,33 @@ export interface Engine { | ||||
|     readonly sceneLoader: SceneLoader, | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * The singletons from the host that are accessible in scripts | ||||
|  */ | ||||
| export interface SingletonsMap { | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Timekeeper that tracks engine time and frame count | ||||
|      */ | ||||
|     timekeeper: any, | ||||
| 
 | ||||
|     /** | ||||
|      * The object for the current player (if in single player non-headless client) | ||||
|      */ | ||||
|     currentPlayer: any, | ||||
| 
 | ||||
|     /** | ||||
|      * The scripts logger | ||||
|      */ | ||||
|     loggerScripts: any, | ||||
| 
 | ||||
|     /** | ||||
|      * The scripts engine | ||||
|      */ | ||||
|     scriptEngine: any, | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| @ -11,3 +11,4 @@ | ||||
|   review effects | ||||
|   review combat code (lifestate, damage calculation, etc) | ||||
|   audio fx for everything | ||||
|   fix rendering pipelines (black when looking at character from angle with item, shadows are not darker color, etc) | ||||
|  | ||||
| @ -30,7 +30,7 @@ public class LoggerInterface { | ||||
|         loggerFileIO = new Logger(LogLevel.WARNING); | ||||
|         loggerGameLogic = new Logger(LogLevel.WARNING); | ||||
|         loggerRenderer = new Logger(LogLevel.WARNING); | ||||
|         loggerEngine = new Logger(LogLevel.INFO); | ||||
|         loggerEngine = new Logger(LogLevel.WARNING); | ||||
|         loggerAuth = new Logger(LogLevel.WARNING); | ||||
|         loggerDB = new Logger(LogLevel.WARNING); | ||||
|         loggerAudio = new Logger(LogLevel.WARNING); | ||||
|  | ||||
| @ -266,25 +266,11 @@ public class ElementManager { | ||||
|         if(el != null){ | ||||
|             elementPropagation.add(el); | ||||
|         } | ||||
|         Element parentElement = null; | ||||
|         Element targetElement = el; | ||||
|         //search all window trees | ||||
|         while(true){ | ||||
|             for(Element window : this.getWindowList()){ | ||||
|                 if(window instanceof ContainerElement){ | ||||
|                     parentElement = recursivelySearchParent((ContainerElement)window,targetElement); | ||||
|                 } | ||||
|             } | ||||
|             if(parentElement == null){ | ||||
|                 if(targetElement instanceof Window){ } else { | ||||
|                     LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Failed to find parent of an element that is not a window!")); | ||||
|                 } | ||||
|                 break; | ||||
|             } else { | ||||
|                 elementPropagation.add(parentElement); | ||||
|                 targetElement = parentElement; | ||||
|                 parentElement = null; | ||||
|             } | ||||
|         while(targetElement.getParent() != null){ | ||||
|             targetElement = targetElement.getParent(); | ||||
|             elementPropagation.add(targetElement); | ||||
|         } | ||||
|         return elementPropagation; | ||||
|     } | ||||
|  | ||||
| @ -28,6 +28,11 @@ public class ScriptEngine { | ||||
|     public static String SCRIPT_NAMESPACE_SCRIPT = "script"; //namespace for the core typescript functionsw | ||||
|     public static String SCRIPT_NAMESPACE_SCENE = "scene"; //namespace for the current scene | ||||
| 
 | ||||
|     /** | ||||
|      * The id for firing signals globally | ||||
|      */ | ||||
|     public static final int GLOBAL_SCENE = -1; | ||||
| 
 | ||||
|     //the graal context | ||||
|     Context context; | ||||
| 
 | ||||
|  | ||||
| @ -8,6 +8,7 @@ import electrosphere.entity.Scene; | ||||
| import electrosphere.game.server.world.ServerWorldData; | ||||
| import electrosphere.logger.LoggerInterface; | ||||
| import electrosphere.net.parser.net.message.NetworkMessage; | ||||
| import electrosphere.script.ScriptEngine; | ||||
| import electrosphere.server.content.ServerContentManager; | ||||
| import electrosphere.server.datacell.interfaces.DataCellManager; | ||||
| 
 | ||||
| @ -246,7 +247,7 @@ public class Realm { | ||||
|         if(this.sceneInstanceId != NO_SCENE_INSTANCE){ | ||||
|             Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args); | ||||
|         } else { | ||||
|             LoggerInterface.loggerScripts.ERROR(new UnsupportedOperationException("Firing a signal in a realm that does not have an associated scene")); | ||||
|             Globals.scriptEngine.fireSignal(signalName, ScriptEngine.GLOBAL_SCENE, args); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user