work
This commit is contained in:
parent
7e66acab76
commit
e8dc3265d3
@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
Spawn a tree
|
Spawn a tree
|
||||||
Lets say there's a concept of macros within the networking framework
|
Server calls function to spawn entity, passes in identifier for tree type
|
||||||
You call the spawn foliage function specifying the type of tree
|
spawn entity function creates server packets to spawn entity on client(s)
|
||||||
the spawn foliage function manually calls the server side macro to create a tree
|
|
||||||
This macro sends a packet to all clients in the chunk to create this tree entity
|
This macro sends a packet to all clients in the chunk to create this tree entity
|
||||||
Each client creates the tree with the client equivalent of the create tree function
|
Each client creates the tree with the client equivalent of the create entity function
|
||||||
|
|
||||||
Player joins a chunk that has a tree that is on fire
|
Player joins a chunk that has a tree that is on fire
|
||||||
The macro is called to spawn a tree, just for that player (how do we tell to call macro for this entity and not generic spawn entity function?)
|
The macro is called to spawn a tree, just for that player (how do we tell to call macro for this entity and not generic spawn entity function?)
|
||||||
@ -24,3 +23,19 @@ A player joins a chunk with a player entity in it
|
|||||||
The server sends a packet to create a new human
|
The server sends a packet to create a new human
|
||||||
The server sends the human template packet for that entity ID
|
The server sends the human template packet for that entity ID
|
||||||
The server iterates over every synchronized behavior tree and sends the status of each variable that is synchronized within that tree
|
The server iterates over every synchronized behavior tree and sends the status of each variable that is synchronized within that tree
|
||||||
|
|
||||||
|
Writing on a sign in game
|
||||||
|
|
||||||
|
|
||||||
|
Buying an item from a store while another player is also interacting with that store
|
||||||
|
|
||||||
|
|
||||||
|
A chat log
|
||||||
|
A character playing an instrument
|
||||||
|
Creating a particle
|
||||||
|
Playing a sound
|
||||||
|
Creating an effect generally (ie fire)
|
||||||
|
Creating a speech bubble over a character
|
||||||
|
Playing an animation
|
||||||
|
Writing a book on the client side
|
||||||
|
Fetching book contents from server(lazy load?)
|
||||||
11
spawningnotes.md
Normal file
11
spawningnotes.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
~~want to define categories of entities (creature, particle, effect, sound, etc)~~
|
||||||
|
^^ why?
|
||||||
|
categories would make sense within a class based architecture because oop, but we have an ECS
|
||||||
|
instead, having preset entity templates (think human template, oak template, elf template, etc) defined in json that all go into the same entity spawning pipeline
|
||||||
|
this allows more thorough testing of main things (setting model, adding hp, etc), and more unique combinations of things (item that can walk around)
|
||||||
|
|
||||||
|
|
||||||
|
lets say in initial handshake with server, after agreeing with client which mods it needs to have loaded,
|
||||||
|
client runs through those mods entity lists and composes a list of all entity files and iterates through them
|
||||||
|
each entity template it hits is given an integer id that is used for creation packets
|
||||||
|
now, when server spawns an entity it sends that integer id that was automatically generated to the client to spawn it in
|
||||||
@ -11,7 +11,6 @@ import java.util.Map;
|
|||||||
import org.jboss.forge.roaster.Roaster;
|
import org.jboss.forge.roaster.Roaster;
|
||||||
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
||||||
|
|
||||||
import electrosphere.main.codegen.CodeGen;
|
|
||||||
import electrosphere.main.structure.ProjectStructure;
|
import electrosphere.main.structure.ProjectStructure;
|
||||||
import electrosphere.main.targets.TargetFile;
|
import electrosphere.main.targets.TargetFile;
|
||||||
|
|
||||||
@ -20,11 +19,8 @@ import electrosphere.main.targets.TargetFile;
|
|||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
static String topLevelFolderPath = "C:\\Users\\satellite\\Documents\\Renderer\\src\\main\\java\\electrosphere";
|
static String topLevelFolderPathWindows = "C:\\Users\\satellite\\Documents\\Renderer\\src\\main\\java\\electrosphere";
|
||||||
|
static String topLevelFolderPathMac = "/Users/satellite/p/Renderer/src/main/java/electrosphere";
|
||||||
static String[] targetFiles = new String[]{
|
|
||||||
"C:\\Users\\satellite\\Documents\\Renderer\\src\\main\\java\\electrosphere\\entity\\state\\idle\\IdleTree.java",
|
|
||||||
};
|
|
||||||
|
|
||||||
public static int bTreeIterator = 0;
|
public static int bTreeIterator = 0;
|
||||||
|
|
||||||
@ -32,7 +28,7 @@ public class Main {
|
|||||||
public static Map<String,Integer> bTreeIdMap = new HashMap<String,Integer>();
|
public static Map<String,Integer> bTreeIdMap = new HashMap<String,Integer>();
|
||||||
|
|
||||||
public static void main(String args[]){
|
public static void main(String args[]){
|
||||||
List<TargetFile> targets = getFilesToModify(topLevelFolderPath);
|
List<TargetFile> targets = getFilesToModify(topLevelFolderPathMac);
|
||||||
ProjectStructure structure = new ProjectStructure(targets);
|
ProjectStructure structure = new ProjectStructure(targets);
|
||||||
structure.parseRichStructure();
|
structure.parseRichStructure();
|
||||||
structure.generate();
|
structure.generate();
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.main.structure;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import electrosphere.main.targets.TargetFile;
|
import electrosphere.main.targets.TargetFile;
|
||||||
|
import electrosphere.main.util.Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a behavior tree in the source code
|
* Represents a behavior tree in the source code
|
||||||
@ -71,4 +72,36 @@ public class BehaviorTree {
|
|||||||
return targetFile;
|
return targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The attach methods are for server side to enforce packets being sent to client to properly attach/detatch every time
|
||||||
|
*/
|
||||||
|
public String getAttachMethodName(){
|
||||||
|
String rVal = "";
|
||||||
|
rVal = "attach" + Utilities.camelCase(name);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAttachMethodContent(){
|
||||||
|
String rVal = "";
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetachMethodName(){
|
||||||
|
String rVal = "";
|
||||||
|
rVal = "detach" + Utilities.camelCase(name);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetachMethodContent(){
|
||||||
|
String rVal = "";
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
package electrosphere.main.structure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should represent a service placed in project source folder that tracks which trees are attached to which entities and which values they have
|
||||||
|
* This service is principally used for when a player joins a chunk that has already been loaded and we need to know what to send to the new player
|
||||||
|
*/
|
||||||
|
public class EntityValueTrackingService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -9,7 +9,6 @@ import org.jboss.forge.roaster.model.source.FieldSource;
|
|||||||
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
||||||
import org.jboss.forge.roaster.model.source.JavaEnumSource;
|
import org.jboss.forge.roaster.model.source.JavaEnumSource;
|
||||||
import org.jboss.forge.roaster.model.source.JavaSource;
|
import org.jboss.forge.roaster.model.source.JavaSource;
|
||||||
import org.jboss.forge.roaster.model.source.MethodSource;
|
|
||||||
|
|
||||||
import electrosphere.main.targets.TargetFile;
|
import electrosphere.main.targets.TargetFile;
|
||||||
import electrosphere.main.util.ClassSourceUtils;
|
import electrosphere.main.util.ClassSourceUtils;
|
||||||
@ -102,8 +101,11 @@ public class ProjectStructure {
|
|||||||
for(BehaviorTree tree : behaviorTrees){
|
for(BehaviorTree tree : behaviorTrees){
|
||||||
if(tree.isServer){
|
if(tree.isServer){
|
||||||
for(SynchronizedField field : tree.synchronizedFields){
|
for(SynchronizedField field : tree.synchronizedFields){
|
||||||
|
ClassSourceUtils.addOrReplaceMethod(this, tree, field.getGetterName(), field.getServerGetterContent());
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree, field.getSetterName(), field.getServerSetterContent());
|
ClassSourceUtils.addOrReplaceMethod(this, tree, field.getSetterName(), field.getServerSetterContent());
|
||||||
}
|
}
|
||||||
|
ClassSourceUtils.addOrReplaceMethod(this, tree, tree.getAttachMethodName(), tree.getAttachMethodContent());
|
||||||
|
ClassSourceUtils.addOrReplaceMethod(this, tree, tree.getDetachMethodName(), tree.getDetachMethodContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,17 @@ public class SynchronizedField {
|
|||||||
this.targetFile = targetFile;
|
this.targetFile = targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGetterName(){
|
||||||
|
String rVal = "";
|
||||||
|
rVal = "get" + Utilities.camelCase(fieldName);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerGetterContent(){
|
||||||
|
String rVal = "";
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSetterName(){
|
public String getSetterName(){
|
||||||
String rVal = "";
|
String rVal = "";
|
||||||
rVal = "set" + Utilities.camelCase(fieldName);
|
rVal = "set" + Utilities.camelCase(fieldName);
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package electrosphere.main.structure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should represent a file placed in project source that translates enums to ints and vice-versa
|
||||||
|
*/
|
||||||
|
public class TranslatorService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,11 +1,12 @@
|
|||||||
package electrosphere.main.util;
|
package electrosphere.main.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
import org.jboss.forge.roaster.model.source.JavaClassSource;
|
||||||
import org.jboss.forge.roaster.model.source.MethodSource;
|
import org.jboss.forge.roaster.model.source.MethodSource;
|
||||||
|
|
||||||
import electrosphere.main.structure.BehaviorTree;
|
import electrosphere.main.structure.BehaviorTree;
|
||||||
import electrosphere.main.structure.ProjectStructure;
|
import electrosphere.main.structure.ProjectStructure;
|
||||||
import electrosphere.main.targets.TargetFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for modifying the source code of a class
|
* Utilities for modifying the source code of a class
|
||||||
@ -27,10 +28,43 @@ public class ClassSourceUtils {
|
|||||||
if(methodSource == null){
|
if(methodSource == null){
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree, field.getSetterName(), field.getServerSetterContent());
|
throw new UnsupportedOperationException();
|
||||||
System.out.println(new StringBuilder(tree.targetFile.getModifiedContent()).insert(setterMethod.getStartPosition(), "asdf").toString());
|
// ClassSourceUtils.addOrReplaceMethod(this, tree, field.getSetterName(), field.getServerSetterContent());
|
||||||
|
// System.out.println(new StringBuilder(tree.targetFile.getModifiedContent()).insert(setterMethod.getStartPosition(), "asdf").toString());
|
||||||
// System.out.println(setterMethod.getStartPosition());
|
// System.out.println(setterMethod.getStartPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the first part of a class declaration file
|
||||||
|
* @param name The name of the class
|
||||||
|
* @param isPublic True if public, false otherwise
|
||||||
|
* @return The string containing the class header
|
||||||
|
*/
|
||||||
|
public static String generateClassHeader(String name, boolean isPublic){
|
||||||
|
String rVal = "\t";
|
||||||
|
rVal = rVal + (isPublic ? "public " : "");
|
||||||
|
rVal = rVal + "class " + name + " {\n";
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When passed in a file object, returns the package declaration that would be used in code to import that source file
|
||||||
|
* @param fileObj The raw java file object
|
||||||
|
* @return The package declaration
|
||||||
|
*/
|
||||||
|
public static String getPackageSourcePath(File fileObj){
|
||||||
|
String rVal = "";
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the footer of a class declaration file
|
||||||
|
* @return The string containing the class footer
|
||||||
|
*/
|
||||||
|
public static String generateClassEnd(){
|
||||||
|
return "}\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package electrosphere.main.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tools for taking files that represent source file fragments and injecting strings to replace portions of the fragment
|
||||||
|
*/
|
||||||
|
public class TemplateInjectionUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a fragment from a source file and replaces all strings with provided ones
|
||||||
|
* @param sourceFile The source file relative path
|
||||||
|
* @param replaceStrings The list of strings to replace
|
||||||
|
* @return The properly updated string
|
||||||
|
*/
|
||||||
|
public static String getFragmentWithReplacement(String sourceFile, String ... replaceStrings){
|
||||||
|
String rVal = "";
|
||||||
|
List<String> replaceStringList = Arrays.asList(replaceStrings);
|
||||||
|
int iterator = 0;
|
||||||
|
for(String replaceString : replaceStringList){
|
||||||
|
rVal = rVal.replace(iterator + "REPLACE_ME", replaceString);
|
||||||
|
iterator++;
|
||||||
|
}
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user