animation updates
This commit is contained in:
parent
2182cc80fa
commit
a26ea92aae
Binary file not shown.
Binary file not shown.
@ -11,6 +11,7 @@
|
|||||||
- @subpage savesindex
|
- @subpage savesindex
|
||||||
- @subpage hitboxesindex
|
- @subpage hitboxesindex
|
||||||
- @subpage drawcell
|
- @subpage drawcell
|
||||||
|
- @subpage scriptengine
|
||||||
|
|
||||||
|
|
||||||
# What is this section
|
# What is this section
|
||||||
|
|||||||
31
docs/src/architecture/scripting/scriptengine.md
Normal file
31
docs/src/architecture/scripting/scriptengine.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@page scriptengine Script Engine
|
||||||
|
|
||||||
|
|
||||||
|
# Potential problems with integrating with the overall game engine
|
||||||
|
A chief problem we want to avoid is allowing people to 'escape' the scripting engine and get access to all objects in the overall engine
|
||||||
|
|
||||||
|
# Roadmap for integrating with the overall game engine
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# On adding different instances of the scripting engine
|
||||||
|
There should be a single monolithic instance of the scripting engine
|
||||||
|
All context-dependent scripts running should have their context provided
|
||||||
|
|
||||||
|
IE, lets say I'm the client and I want to fire an event when a client-side effect completes,
|
||||||
|
I'd provide a copy of the client's scene as a part of the function call on javascript side
|
||||||
|
That way for any unforseen reason the client could still get access to the server's objects
|
||||||
|
|
||||||
|
IE, lets say I'm a script running on a specific scene on the server,
|
||||||
|
I'd provide the specific scene to the function call
|
||||||
|
|
||||||
|
IE, lets say I'm some script firing every time a user logs in,
|
||||||
|
I'd provide the new user object and the global server user tracking service
|
||||||
|
That way you could still drill down to individual scenes on the server if you needed to
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -387,6 +387,20 @@ Fix items falling below the ground
|
|||||||
Fix server always rotating entity to face client camera -- should only be changing movement vector
|
Fix server always rotating entity to face client camera -- should only be changing movement vector
|
||||||
Probably some kind of tutorial text
|
Probably some kind of tutorial text
|
||||||
|
|
||||||
|
(06/??/2024)
|
||||||
|
Start working on script engine documentation/design
|
||||||
|
|
||||||
|
(06/27/2024)
|
||||||
|
Animations
|
||||||
|
- 2H Sword Hold (3rd person)
|
||||||
|
- 2H Sword Attack (3rd person)
|
||||||
|
- 2H Sword Block (3rd person)
|
||||||
|
- 2H Sword Hold (1st person)
|
||||||
|
- 2H Sword Attach (1st person)
|
||||||
|
- 2H Sword Block (1st person)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
|
||||||
@ -394,8 +408,6 @@ Probably some kind of tutorial text
|
|||||||
|
|
||||||
Demo requirements:
|
Demo requirements:
|
||||||
= Assets =
|
= Assets =
|
||||||
Block animation in first person
|
|
||||||
Block animation in third person
|
|
||||||
Fix attack animation bone rotations for hand
|
Fix attack animation bone rotations for hand
|
||||||
Clean up equip state data
|
Clean up equip state data
|
||||||
Audio FX for everything
|
Audio FX for everything
|
||||||
|
|||||||
@ -13,12 +13,23 @@ import org.graalvm.polyglot.Value;
|
|||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for executing scripts in the game engine
|
||||||
|
*/
|
||||||
public class ScriptEngine {
|
public class ScriptEngine {
|
||||||
|
|
||||||
|
//the graal context
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
//the map of script filepaths to parsed, in-memory scripts
|
||||||
Map<String,Source> sourceMap;
|
Map<String,Source> sourceMap;
|
||||||
|
|
||||||
|
//the javascript object that stores values
|
||||||
|
Value jsBindingsObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the engine
|
||||||
|
*/
|
||||||
public void init(){
|
public void init(){
|
||||||
//init datastructures
|
//init datastructures
|
||||||
sourceMap = new HashMap<String,Source>();
|
sourceMap = new HashMap<String,Source>();
|
||||||
@ -28,6 +39,8 @@ public class ScriptEngine {
|
|||||||
context = Context.newBuilder("js").engine(engine).build();
|
context = Context.newBuilder("js").engine(engine).build();
|
||||||
//read scripts into source map
|
//read scripts into source map
|
||||||
readScriptsDirectory("/src/main/sql", FileUtils.getAssetFile("/src/main/sql"));
|
readScriptsDirectory("/src/main/sql", FileUtils.getAssetFile("/src/main/sql"));
|
||||||
|
//save the js bindings object
|
||||||
|
jsBindingsObject = context.getBindings("js");
|
||||||
//create bindings
|
//create bindings
|
||||||
// try {
|
// try {
|
||||||
// String content = FileUtils.getAssetFileAsString("/Scripts/test.js");
|
// String content = FileUtils.getAssetFileAsString("/Scripts/test.js");
|
||||||
@ -40,11 +53,29 @@ public class ScriptEngine {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void createBindings(){
|
/**
|
||||||
Value jsBindings = context.getBindings("js");
|
* Stores a variable at the top level of the js bindings
|
||||||
jsBindings.putMember("name", "somescript");
|
* @param valueName The name of the variable (ie the name of the variable)
|
||||||
|
* @param value The value that is stored at that variable
|
||||||
|
*/
|
||||||
|
public void putTopLevelValue(String valueName, Object value){
|
||||||
|
jsBindingsObject.putMember(valueName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a top level value from the script engine
|
||||||
|
* @param valueName The name of the variable
|
||||||
|
* @return The value of the variable
|
||||||
|
*/
|
||||||
|
public Value getTopLevelValue(String valueName){
|
||||||
|
return jsBindingsObject.getMember(valueName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the scripts directory
|
||||||
|
* @param path The
|
||||||
|
* @param directory
|
||||||
|
*/
|
||||||
void readScriptsDirectory(String path, File directory){
|
void readScriptsDirectory(String path, File directory){
|
||||||
if(directory.exists() && directory.isDirectory()){
|
if(directory.exists() && directory.isDirectory()){
|
||||||
File[] children = directory.listFiles();
|
File[] children = directory.listFiles();
|
||||||
@ -61,6 +92,10 @@ public class ScriptEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a script from disk
|
||||||
|
* @param path The path to the script file
|
||||||
|
*/
|
||||||
public void loadScript(String path){
|
public void loadScript(String path){
|
||||||
String content;
|
String content;
|
||||||
try {
|
try {
|
||||||
@ -73,11 +108,17 @@ public class ScriptEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a script
|
||||||
|
* @param path The filepath of the script
|
||||||
|
*/
|
||||||
public void runScript(String path){
|
public void runScript(String path){
|
||||||
Source source = sourceMap.get(path);
|
Source source = sourceMap.get(path);
|
||||||
if(source != null){
|
if(source != null){
|
||||||
context.eval(source);
|
context.eval(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user