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 { loggerScripts } from '/Scripts/compiler/host_access'
|
||||||
import { Client, NamespaceClient } from '/Scripts/client/client'
|
import { Client, NamespaceClient } from '/Scripts/client/client'
|
||||||
import { HookManager } from '/Scripts/engine/hooks/hook-manager'
|
import { HookManager } from '/Scripts/engine/hooks/hook-manager'
|
||||||
import { SceneLoader } from '/Scripts/engine/scene/scene-loader'
|
import { SceneLoader } from '/Scripts/engine/scene/scene-loader'
|
||||||
|
import { Engine } from '/Scripts/types/engine'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core engine values
|
* 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 { Hook } from "/Scripts/types/hook"
|
||||||
import { Scene } from "/Scripts/types/scene"
|
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
|
* 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] : []
|
const signalArray: Array<TrackedHook> = this.signalHookMap?.[hookSignal] ? this.signalHookMap?.[hookSignal] : []
|
||||||
signalArray.push(trackedHook)
|
signalArray.push(trackedHook)
|
||||||
this.signalHookMap[hookSignal] = signalArray
|
this.signalHookMap[hookSignal] = signalArray
|
||||||
console.log('register signal hook map')
|
loggerScripts.DEBUG('register signal hook map')
|
||||||
console.log(hookSignal)
|
loggerScripts.DEBUG(hookSignal)
|
||||||
console.log(Object.keys(this.signalHookMap))
|
loggerScripts.DEBUG(Object.keys(this.signalHookMap))
|
||||||
console.log(this.signalHookMap[hookSignal])
|
loggerScripts.DEBUG(this.signalHookMap[hookSignal])
|
||||||
//
|
//
|
||||||
//Scene related structures
|
//Scene related structures
|
||||||
//
|
//
|
||||||
@ -117,19 +122,21 @@ export class HookManager {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
//There isn't a hook registered for this signal at the global level
|
//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
|
if(instanceId !== GLOBAL_SCENE_ID){
|
||||||
const scene: Scene = this.engine.sceneLoader.getScene(instanceId)
|
//try firing at scene scope
|
||||||
const sceneHooks: Array<TrackedHook> = scene.signalHookMap[signal]
|
const scene: Scene = this.engine.sceneLoader.getScene(instanceId)
|
||||||
if(!!sceneHooks){
|
const sceneHooks: Array<TrackedHook> = scene.signalHookMap[signal]
|
||||||
sceneHooks.forEach(trackeHook => {
|
if(!!sceneHooks){
|
||||||
trackeHook.callback(...argsRaw)
|
sceneHooks.forEach(trackeHook => {
|
||||||
})
|
trackeHook.callback(...argsRaw)
|
||||||
} else {
|
})
|
||||||
//There isn't a hook registered for this signal at the scene level
|
} else {
|
||||||
console.log("No scene hooks for signal " + signal)
|
//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 { Hook } from "/Scripts/types/hook";
|
||||||
import { Scene } from "/Scripts/types/scene";
|
import { Scene } from "/Scripts/types/scene";
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export class SceneLoader {
|
|||||||
* @param scene The scene
|
* @param scene The scene
|
||||||
* @returns The id assigned to the instance of 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
|
//add to the list of tracked scenes
|
||||||
const trackedScene: Scene = {
|
const trackedScene: Scene = {
|
||||||
instanceId: this.sceneIdIncrementer++,
|
instanceId: this.sceneIdIncrementer++,
|
||||||
|
|||||||
@ -28,3 +28,33 @@ export interface Engine {
|
|||||||
readonly sceneLoader: SceneLoader,
|
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 effects
|
||||||
review combat code (lifestate, damage calculation, etc)
|
review combat code (lifestate, damage calculation, etc)
|
||||||
audio fx for everything
|
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);
|
loggerFileIO = new Logger(LogLevel.WARNING);
|
||||||
loggerGameLogic = new Logger(LogLevel.WARNING);
|
loggerGameLogic = new Logger(LogLevel.WARNING);
|
||||||
loggerRenderer = new Logger(LogLevel.WARNING);
|
loggerRenderer = new Logger(LogLevel.WARNING);
|
||||||
loggerEngine = new Logger(LogLevel.INFO);
|
loggerEngine = new Logger(LogLevel.WARNING);
|
||||||
loggerAuth = new Logger(LogLevel.WARNING);
|
loggerAuth = new Logger(LogLevel.WARNING);
|
||||||
loggerDB = new Logger(LogLevel.WARNING);
|
loggerDB = new Logger(LogLevel.WARNING);
|
||||||
loggerAudio = new Logger(LogLevel.WARNING);
|
loggerAudio = new Logger(LogLevel.WARNING);
|
||||||
|
|||||||
@ -266,25 +266,11 @@ public class ElementManager {
|
|||||||
if(el != null){
|
if(el != null){
|
||||||
elementPropagation.add(el);
|
elementPropagation.add(el);
|
||||||
}
|
}
|
||||||
Element parentElement = null;
|
|
||||||
Element targetElement = el;
|
Element targetElement = el;
|
||||||
//search all window trees
|
//search all window trees
|
||||||
while(true){
|
while(targetElement.getParent() != null){
|
||||||
for(Element window : this.getWindowList()){
|
targetElement = targetElement.getParent();
|
||||||
if(window instanceof ContainerElement){
|
elementPropagation.add(targetElement);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return elementPropagation;
|
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_SCRIPT = "script"; //namespace for the core typescript functionsw
|
||||||
public static String SCRIPT_NAMESPACE_SCENE = "scene"; //namespace for the current scene
|
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
|
//the graal context
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import electrosphere.entity.Scene;
|
|||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||||
|
import electrosphere.script.ScriptEngine;
|
||||||
import electrosphere.server.content.ServerContentManager;
|
import electrosphere.server.content.ServerContentManager;
|
||||||
import electrosphere.server.datacell.interfaces.DataCellManager;
|
import electrosphere.server.datacell.interfaces.DataCellManager;
|
||||||
|
|
||||||
@ -246,7 +247,7 @@ public class Realm {
|
|||||||
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
|
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
|
||||||
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
|
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
|
||||||
} else {
|
} 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