create has method generator
All checks were successful
studiorailgun/highlevel-netcode-gen/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-05 18:41:52 -04:00
parent 2c638fca2f
commit c719513510
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package electrosphere.main.core.btree.methods;
import java.util.Arrays;
import java.util.List;
import electrosphere.main.project.ProjectStructure;
import electrosphere.main.source.VirtualMethod;
import electrosphere.main.util.TemplateInjectionUtils;
/**
* Check if btree is on entity
*/
public class HasChecker implements VirtualMethod {
//The name of the btree
String name;
//The classname of the btree
String className;
/**
* Constructor
* @param name
* @param className
*/
public HasChecker(String name, String className){
this.name = name;
this.className = className;
}
@Override
public String getName(ProjectStructure projectStructure) {
String rVal = "has" + className;
return rVal;
}
@Override
public String getContent(ProjectStructure projectStructure) {
String rVal = TemplateInjectionUtils.getFragmentWithReplacement("/btree/EntityHasMethod.java", this.className, "TREE_" + this.name.toUpperCase());
return rVal;
}
@Override
public List<String> getImports(ProjectStructure projectStructure) {
List<String> rVal = Arrays.asList(new String[]{
});
return rVal;
}
@Override
public boolean shouldOverwrite(){
return true;
}
}

View File

@ -17,6 +17,7 @@ import electrosphere.main.core.btree.methods.ClientInterrupt;
import electrosphere.main.core.btree.methods.ClientStart; import electrosphere.main.core.btree.methods.ClientStart;
import electrosphere.main.core.btree.methods.Constructor; import electrosphere.main.core.btree.methods.Constructor;
import electrosphere.main.core.btree.methods.Fetch; import electrosphere.main.core.btree.methods.Fetch;
import electrosphere.main.core.btree.methods.HasChecker;
import electrosphere.main.core.btree.methods.ServerAttach; import electrosphere.main.core.btree.methods.ServerAttach;
import electrosphere.main.core.btree.methods.ServerDetach; import electrosphere.main.core.btree.methods.ServerDetach;
import electrosphere.main.targets.TargetFile; import electrosphere.main.targets.TargetFile;
@ -87,6 +88,7 @@ public class BTreeParser {
rVal.addMethod(new Constructor(bTreeName, target.getSource().getName())); rVal.addMethod(new Constructor(bTreeName, target.getSource().getName()));
rVal.addMethod(new Fetch(bTreeName, target.getSource().getName())); rVal.addMethod(new Fetch(bTreeName, target.getSource().getName()));
rVal.addMethod(new HasChecker(bTreeName, target.getSource().getName()));
addOptionalMethods(mainAnnotation,rVal); addOptionalMethods(mainAnnotation,rVal);

View File

@ -0,0 +1,10 @@
/**
* <p>
* Checks if the entity has a REPLACE_0_ME component
* </p>
* @param entity the entity
* @return true if the entity contains the component, false otherwise
*/
public static boolean hasREPLACE_0_ME(Entity entity){
return entity.containsKey(EntityDataStrings.REPLACE_1_ME);
}