region height work

This commit is contained in:
2023-09-13 21:07:57 -05:00
parent 200318ddcf
commit 9b7fc0a93b
4 changed files with 14 additions and 36 deletions
+8 -33
View File
@@ -9,9 +9,9 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
import engine.objects.*;
import java.lang.reflect.Field;
@@ -25,42 +25,17 @@ public class RegionCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (pc.region == null) {
Regions region = ((AbstractCharacter)target).region;
if (region == null) {
this.throwbackInfo(pc, "No Region Found.");
return;
}
String newLine = System.getProperty("line.separator");
String result = "";
result += (pc.region.getClass().getSimpleName());
result += (" {");
result += (newLine);
Field[] fields = pc.region.getClass().getDeclaredFields();
//print field names paired with their values
for (Field field : fields) {
field.setAccessible(true);
result += (" ");
try {
if (field.getName().contains("Furniture"))
continue;
result += (field.getName());
result += (": ");
//requires access to private field:
result += (field.get(pc.region).toString());
} catch (IllegalAccessException ex) {
System.out.println(ex);
}
result.trim();
result += (newLine);
if(region != null) {
this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName());
this.throwbackInfo(pc, "Region Name: " + region);
this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target));
}
result += ("}");
this.throwbackInfo(pc, result.toString());
}