bugfixes
This commit is contained in:
parent
9f1e5e9ae6
commit
155978662d
@ -134,24 +134,39 @@ public class ProjectStructure {
|
|||||||
for(BehaviorTree tree : behaviorTrees){
|
for(BehaviorTree tree : behaviorTrees){
|
||||||
//server side getter + setter
|
//server side getter + setter
|
||||||
if(tree.isServer){
|
if(tree.isServer){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(SynchronizedField field : tree.synchronizedFields){
|
for(SynchronizedField field : tree.synchronizedFields){
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getGetterName(), field.getServerGetterContent());
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getGetterName(), field.getServerGetterContent());
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getSetterName(), field.getServerSetterContent(this));
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getSetterName(), field.getServerSetterContent(this));
|
||||||
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.server.datacell.utils.DataCellSearchUtils");
|
|
||||||
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.net.parser.net.message.SynchronizationMessage");
|
|
||||||
}
|
}
|
||||||
//attach + detatch methods
|
//attach + detatch methods
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getAttachMethodName(), tree.getAttachMethodContent(true));
|
ClassSourceUtils.addMethodIfAbsent(this, tree.getTargetFile(), tree.getAttachMethodName(), tree.getAttachMethodContent(true));
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getDetachMethodName(), tree.getDetachMethodContent(true));
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getDetachMethodName(), tree.getDetachMethodContent(true));
|
||||||
|
//imports
|
||||||
|
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.server.datacell.utils.DataCellSearchUtils");
|
||||||
|
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.net.parser.net.message.SynchronizationMessage");
|
||||||
|
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.server.datacell.utils.ServerBehaviorTreeUtils");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(SynchronizedField field : tree.synchronizedFields){
|
||||||
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getGetterName(), field.getClientGetterContent());
|
||||||
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), field.getSetterName(), field.getClientSetterContent(this));
|
||||||
|
}
|
||||||
//attach + detatch methods
|
//attach + detatch methods
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getAttachMethodName(), tree.getAttachMethodContent(false));
|
ClassSourceUtils.addMethodIfAbsent(this, tree.getTargetFile(), tree.getAttachMethodName(), tree.getAttachMethodContent(false));
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getDetachMethodName(), tree.getDetachMethodContent(false));
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getDetachMethodName(), tree.getDetachMethodContent(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//guarantee entity fetch method
|
//guarantee entity fetch method
|
||||||
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getEntityFetchMethodName(), tree.getEntityFetchMethodContent());
|
ClassSourceUtils.addOrReplaceMethod(this, tree.getTargetFile(), tree.getEntityFetchMethodName(), tree.getEntityFetchMethodContent());
|
||||||
//guarantee imports of required files (btree enum, etc)
|
//guarantee imports of required files (btree enum, etc)
|
||||||
ClassSourceUtils.importClass(this, tree.getTargetFile(), BTreeIdEnum.getQualifiedPath(this));
|
ClassSourceUtils.importClass(this, tree.getTargetFile(), BTreeIdEnum.getQualifiedPath(this));
|
||||||
|
ClassSourceUtils.importClass(this, tree.getTargetFile(), "electrosphere.entity.EntityDataStrings");
|
||||||
}
|
}
|
||||||
//generate enums for all synchronized types
|
//generate enums for all synchronized types
|
||||||
for(SynchronizedType type : synchronizedTypes){
|
for(SynchronizedType type : synchronizedTypes){
|
||||||
|
|||||||
@ -50,6 +50,11 @@ public class SynchronizedField {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClientGetterContent(){
|
||||||
|
String rVal = TemplateInjectionUtils.getFragmentWithReplacement("/client/Getter.java", fieldName, Utilities.camelCase(fieldName), typeName);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSetterName(){
|
public String getSetterName(){
|
||||||
String rVal = "";
|
String rVal = "";
|
||||||
rVal = "set" + Utilities.camelCase(fieldName);
|
rVal = "set" + Utilities.camelCase(fieldName);
|
||||||
@ -72,4 +77,9 @@ public class SynchronizedField {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClientSetterContent(ProjectStructure structure){
|
||||||
|
String rVal = TemplateInjectionUtils.getFragmentWithReplacement("/client/Setter.java", fieldName, Utilities.camelCase(fieldName), typeName);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,7 @@ public class TargetFile {
|
|||||||
public void setModifiedContent(String content){
|
public void setModifiedContent(String content){
|
||||||
this.setModified(true);
|
this.setModified(true);
|
||||||
this.modifiedContent = new StringBuilder(content);
|
this.modifiedContent = new StringBuilder(content);
|
||||||
|
reparse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -59,6 +59,37 @@ public class ClassSourceUtils {
|
|||||||
targetFile.reparse();
|
targetFile.reparse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds to replaces a method in a given behavior tree
|
||||||
|
* @param structure The project structure
|
||||||
|
* @param targetFile The targetFile
|
||||||
|
* @param methodName The name of the method
|
||||||
|
* @param methodContent The content of the method that you want to insert or replace with
|
||||||
|
*/
|
||||||
|
public static void addMethodIfAbsent(ProjectStructure structure, TargetFile targetFile, String methodName, String methodContent){
|
||||||
|
//search for method
|
||||||
|
List<MethodSource<JavaClassSource>> methods = targetFile.getSource().getMethods();
|
||||||
|
MethodSource<JavaClassSource> methodSource = null;
|
||||||
|
for(MethodSource<JavaClassSource> methodRaw : methods){
|
||||||
|
if(methodRaw.getName().equals(methodName)){
|
||||||
|
if(methodSource != null){
|
||||||
|
throw new UnknownError("Two methods in a source file have the same name. This is unsupported by the addOrReplaceMethod function at this time!");
|
||||||
|
}
|
||||||
|
methodSource = methodRaw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder modifiedContent = targetFile.getModifiedContent();
|
||||||
|
if(methodSource == null){
|
||||||
|
int endOfClass = findEndOfClass(modifiedContent.toString());
|
||||||
|
String indentedFragment = TemplateInjectionUtils.indentFragment(methodContent, DEFAULT_INDENT);
|
||||||
|
//must newline
|
||||||
|
String finalInsertion = indentedFragment + "\n";
|
||||||
|
modifiedContent.insert(endOfClass, finalInsertion);
|
||||||
|
targetFile.setModifiedContent(modifiedContent.toString());
|
||||||
|
targetFile.reparse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the end of a class file
|
* Finds the end of a class file
|
||||||
* @param sourceRaw The raw source
|
* @param sourceRaw The raw source
|
||||||
|
|||||||
@ -15,6 +15,7 @@ public static REPLACE_2_ME attachTree(Entity parent){
|
|||||||
//!!WARNING!! from here below should not be touched
|
//!!WARNING!! from here below should not be touched
|
||||||
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
|
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
|
||||||
parent.putData(EntityDataStrings.REPLACE_1_ME, rVal);
|
parent.putData(EntityDataStrings.REPLACE_1_ME, rVal);
|
||||||
|
Globals.clientScene.registerBehaviorTree(rVal);
|
||||||
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_REPLACE_0_ME_ID);
|
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_REPLACE_0_ME_ID);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
9
src/main/resources/client/Getter.java
Normal file
9
src/main/resources/client/Getter.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* <p> Automatically generated </p>
|
||||||
|
* <p>
|
||||||
|
* Gets REPLACE_0_ME.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public REPLACE_2_ME getREPLACE_1_ME(){
|
||||||
|
return REPLACE_0_ME;
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* <p> Automatically generated </p>
|
* <p> Automatically generated </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Sets REPLACENAMENOTCAMEL and handles the synchronization logic for it.
|
* Sets REPLACE_0_ME and handles the synchronization logic for it.
|
||||||
* </p>
|
* </p>
|
||||||
* @param REPLACENAMENOTCAMEL The value to set REPLACENAMENOTCAMEL to.
|
* @param REPLACE_0_ME The value to set REPLACE_0_ME to.
|
||||||
*/
|
*/
|
||||||
public void setREPLACENAMECAMEL(REPLACETYPE REPLACENAMENOTCAMEL){
|
public void setREPLACE_1_ME(REPLACE_2_ME REPLACE_0_ME){
|
||||||
this.REPLACENAMENOTCAMEL = REPLACENAMENOTCAMEL;
|
this.REPLACE_0_ME = REPLACE_0_ME;
|
||||||
}
|
}
|
||||||
@ -3,4 +3,5 @@ Validation to build into tool
|
|||||||
[ ]Check that behavior trees have corresponding receiver trees
|
[ ]Check that behavior trees have corresponding receiver trees
|
||||||
[ ]Check that all synchronized fields are private
|
[ ]Check that all synchronized fields are private
|
||||||
[ ]If a synchronized field is an enum, check that both the client and server versions use the same enum type so that there isn't misalignment
|
[ ]If a synchronized field is an enum, check that both the client and server versions use the same enum type so that there isn't misalignment
|
||||||
[ ]Check that all synchronized fields have corresponding fields on opposite tree
|
[ ]Check that all synchronized fields have corresponding fields on opposite tree
|
||||||
|
[ ]Check constructors for btrees are private and instead all creation is done through attachTree() method
|
||||||
Loading…
Reference in New Issue
Block a user