more incremental work
All checks were successful
studiorailgun/highlevel-netcode-gen/pipeline/head This commit looks good
All checks were successful
studiorailgun/highlevel-netcode-gen/pipeline/head This commit looks good
This commit is contained in:
parent
ecab7952b7
commit
e0b914b9b8
@ -3,6 +3,7 @@ package electrosphere.main;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -100,9 +101,12 @@ public class Main {
|
|||||||
content.contains("@SynchronizedBehaviorTree") ||
|
content.contains("@SynchronizedBehaviorTree") ||
|
||||||
isHardCodedAlwaysParse(currentFile.getName())
|
isHardCodedAlwaysParse(currentFile.getName())
|
||||||
){
|
){
|
||||||
|
//get relative path
|
||||||
|
Path relativePath = topLevelFolder.toPath().relativize(currentFile.toPath());
|
||||||
|
String relativePathString = "src/main/java/electrosphere/" + relativePath.toString();
|
||||||
//parse
|
//parse
|
||||||
JavaClassSource source = parseJavaFile(content);
|
JavaClassSource source = parseJavaFile(content);
|
||||||
rVal.add(new TargetFile(currentFile.getAbsolutePath(), content, currentFile.getName(), source));
|
rVal.add(new TargetFile(currentFile.getAbsolutePath(), relativePathString, content, currentFile.getName(), source));
|
||||||
}
|
}
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class ClientSynchronizationManager extends VirtualClass {
|
|||||||
*/
|
*/
|
||||||
public ClientSynchronizationManager(TargetFile file) {
|
public ClientSynchronizationManager(TargetFile file) {
|
||||||
super(
|
super(
|
||||||
"src/main/java/electrosphere/net/synchronization/ClientSynchronizationManager.java",
|
file,
|
||||||
"ClientSynchronizationManager",
|
"ClientSynchronizationManager",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@ -4,13 +4,14 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import electrosphere.main.core.syncfield.SynchronizedField;
|
import electrosphere.main.core.syncfield.SynchronizedField;
|
||||||
|
import electrosphere.main.source.VirtualClass;
|
||||||
import electrosphere.main.targets.TargetFile;
|
import electrosphere.main.targets.TargetFile;
|
||||||
import electrosphere.main.util.TemplateInjectionUtils;
|
import electrosphere.main.util.TemplateInjectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a behavior tree in the source code
|
* Represents a behavior tree in the source code
|
||||||
*/
|
*/
|
||||||
public class BehaviorTree {
|
public class BehaviorTree extends VirtualClass {
|
||||||
|
|
||||||
//id assigned to the tree by this tool
|
//id assigned to the tree by this tool
|
||||||
int id;
|
int id;
|
||||||
@ -49,6 +50,7 @@ public class BehaviorTree {
|
|||||||
boolean isServer,
|
boolean isServer,
|
||||||
TargetFile targetFile
|
TargetFile targetFile
|
||||||
){
|
){
|
||||||
|
super(targetFile,className,true);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.className = className;
|
this.className = className;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.google.common.io.Files;
|
|||||||
import electrosphere.main.core.btree.BehaviorTree;
|
import electrosphere.main.core.btree.BehaviorTree;
|
||||||
import electrosphere.main.project.ProjectStructure;
|
import electrosphere.main.project.ProjectStructure;
|
||||||
import electrosphere.main.source.VirtualClass;
|
import electrosphere.main.source.VirtualClass;
|
||||||
|
import electrosphere.main.targets.TargetFile;
|
||||||
import electrosphere.main.util.ClassSourceUtils;
|
import electrosphere.main.util.ClassSourceUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +21,13 @@ public class BTreeIdEnum extends VirtualClass {
|
|||||||
*/
|
*/
|
||||||
public BTreeIdEnum() {
|
public BTreeIdEnum() {
|
||||||
super(
|
super(
|
||||||
"src/main/java/electrosphere/net/synchronization/BehaviorTreeIdEnums.java",
|
new TargetFile(
|
||||||
|
null,
|
||||||
|
"src/main/java/electrosphere/net/synchronization/BehaviorTreeIdEnums.java",
|
||||||
|
"",
|
||||||
|
"BehaviorTreeIdEnums",
|
||||||
|
null
|
||||||
|
),
|
||||||
"BehaviorTreeIdEnums",
|
"BehaviorTreeIdEnums",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -34,7 +41,7 @@ public class BTreeIdEnum extends VirtualClass {
|
|||||||
public void createFile(ProjectStructure structure){
|
public void createFile(ProjectStructure structure){
|
||||||
|
|
||||||
String source = "";
|
String source = "";
|
||||||
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(this.getLocation()).toFile();
|
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(this.getTargetFile().getRelativePath()).toFile();
|
||||||
source = source + ClassSourceUtils.getPackageDeclaration(structure, ClassSourceUtils.getPackageSourcePath(structure, outFile));
|
source = source + ClassSourceUtils.getPackageDeclaration(structure, ClassSourceUtils.getPackageSourcePath(structure, outFile));
|
||||||
source = source + "\n";
|
source = source + "\n";
|
||||||
source = source + ClassSourceUtils.generateClassHeader("BehaviorTreeIdEnums", "List of enums for each automatically synchronized behavior tree.", true);
|
source = source + ClassSourceUtils.generateClassHeader("BehaviorTreeIdEnums", "List of enums for each automatically synchronized behavior tree.", true);
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.google.common.io.Files;
|
|||||||
import electrosphere.main.core.syncfield.SynchronizedField;
|
import electrosphere.main.core.syncfield.SynchronizedField;
|
||||||
import electrosphere.main.project.ProjectStructure;
|
import electrosphere.main.project.ProjectStructure;
|
||||||
import electrosphere.main.source.VirtualClass;
|
import electrosphere.main.source.VirtualClass;
|
||||||
|
import electrosphere.main.targets.TargetFile;
|
||||||
import electrosphere.main.util.ClassSourceUtils;
|
import electrosphere.main.util.ClassSourceUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +21,13 @@ public class FieldIdEnum extends VirtualClass {
|
|||||||
*/
|
*/
|
||||||
public FieldIdEnum() {
|
public FieldIdEnum() {
|
||||||
super(
|
super(
|
||||||
"src/main/java/electrosphere/net/synchronization/FieldIdEnums.java",
|
new TargetFile(
|
||||||
|
null,
|
||||||
|
"src/main/java/electrosphere/net/synchronization/FieldIdEnums.java",
|
||||||
|
"",
|
||||||
|
"FieldIdEnums",
|
||||||
|
null
|
||||||
|
),
|
||||||
"FieldIdEnums",
|
"FieldIdEnums",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -34,7 +41,7 @@ public class FieldIdEnum extends VirtualClass {
|
|||||||
public void createFile(ProjectStructure structure){
|
public void createFile(ProjectStructure structure){
|
||||||
|
|
||||||
String source = "";
|
String source = "";
|
||||||
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(this.getLocation()).toFile();
|
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(this.getTargetFile().getRelativePath()).toFile();
|
||||||
source = source + ClassSourceUtils.getPackageDeclaration(structure, ClassSourceUtils.getPackageSourcePath(structure, outFile));
|
source = source + ClassSourceUtils.getPackageDeclaration(structure, ClassSourceUtils.getPackageSourcePath(structure, outFile));
|
||||||
source = source + "\n";
|
source = source + "\n";
|
||||||
source = source + ClassSourceUtils.generateClassHeader("FieldIdEnums", "List of enums of all fields and their associated ids.", true);
|
source = source + ClassSourceUtils.generateClassHeader("FieldIdEnums", "List of enums of all fields and their associated ids.", true);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import electrosphere.main.project.ProjectStructure;
|
import electrosphere.main.project.ProjectStructure;
|
||||||
|
import electrosphere.main.targets.TargetFile;
|
||||||
import electrosphere.main.util.ClassSourceUtils;
|
import electrosphere.main.util.ClassSourceUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,12 +12,13 @@ import electrosphere.main.util.ClassSourceUtils;
|
|||||||
*/
|
*/
|
||||||
public abstract class VirtualClass {
|
public abstract class VirtualClass {
|
||||||
|
|
||||||
//the location of the file
|
|
||||||
private String LOCATION;
|
|
||||||
//the class's name
|
//the class's name
|
||||||
private String CLASSNAME;
|
private String CLASSNAME;
|
||||||
//controls whether this class should update or generate from scratch
|
//controls whether this class should update or generate from scratch
|
||||||
private boolean shouldUpdate;
|
private boolean shouldUpdate;
|
||||||
|
|
||||||
|
//The file this type appears in
|
||||||
|
private TargetFile targetFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the imports in this virtual class
|
* All the imports in this virtual class
|
||||||
@ -35,12 +37,12 @@ public abstract class VirtualClass {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param location The location of the file
|
* @param targetFile The target file for this class
|
||||||
* @param name The name of the class
|
* @param name The name of the class
|
||||||
* @param shouldUpdate Controls whether the class should generate the file from scratch or update its existing file
|
* @param shouldUpdate Controls whether the class should generate the file from scratch or update its existing file
|
||||||
*/
|
*/
|
||||||
public VirtualClass(String location, String name, boolean shouldUpdate){
|
public VirtualClass(TargetFile targetFile, String name, boolean shouldUpdate){
|
||||||
this.LOCATION = location;
|
this.targetFile = targetFile;
|
||||||
this.CLASSNAME = name;
|
this.CLASSNAME = name;
|
||||||
this.shouldUpdate = shouldUpdate;
|
this.shouldUpdate = shouldUpdate;
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ public abstract class VirtualClass {
|
|||||||
* @return The qualified path
|
* @return The qualified path
|
||||||
*/
|
*/
|
||||||
public String getQualifiedPath(ProjectStructure structure){
|
public String getQualifiedPath(ProjectStructure structure){
|
||||||
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(LOCATION).toFile();
|
File outFile = new File(structure.getRootFolder().getAbsolutePath()).toPath().resolve(targetFile.getRelativePath()).toFile();
|
||||||
return ClassSourceUtils.getPackageSourcePath(structure, outFile) + "." + CLASSNAME;
|
return ClassSourceUtils.getPackageSourcePath(structure, outFile) + "." + CLASSNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,11 +67,10 @@ public abstract class VirtualClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location of this file
|
* Gets the target file for this class
|
||||||
* @return The location
|
|
||||||
*/
|
*/
|
||||||
public String getLocation(){
|
public TargetFile getTargetFile(){
|
||||||
return this.LOCATION;
|
return this.targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,6 +16,8 @@ public class TargetFile {
|
|||||||
|
|
||||||
//the path of the file
|
//the path of the file
|
||||||
String path;
|
String path;
|
||||||
|
//The path relative to the source directory
|
||||||
|
String relativePath;
|
||||||
//the original content of the file
|
//the original content of the file
|
||||||
String originalContent;
|
String originalContent;
|
||||||
//The content, with any modifications made by the netcode generator
|
//The content, with any modifications made by the netcode generator
|
||||||
@ -35,8 +37,9 @@ public class TargetFile {
|
|||||||
* @param name
|
* @param name
|
||||||
* @param source
|
* @param source
|
||||||
*/
|
*/
|
||||||
public TargetFile(String path, String content, String name, JavaClassSource source){
|
public TargetFile(String path, String relativePath, String content, String name, JavaClassSource source){
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
this.relativePath = relativePath;
|
||||||
this.originalContent = content;
|
this.originalContent = content;
|
||||||
this.modifiedContent = new StringBuilder(content);
|
this.modifiedContent = new StringBuilder(content);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -130,4 +133,20 @@ public class TargetFile {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file path of the target file
|
||||||
|
* @return The file path
|
||||||
|
*/
|
||||||
|
public String getPath(){
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path of the target file relative to the root folder of the project
|
||||||
|
* @return The relative path
|
||||||
|
*/
|
||||||
|
public String getRelativePath(){
|
||||||
|
return this.relativePath;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user