Commands are now content

This commit is contained in:
Anuken
2023-09-23 17:10:19 -04:00
parent cafec1386c
commit 276245bf3c
7 changed files with 107 additions and 66 deletions

View File

@@ -203,7 +203,7 @@ public class TypeIO{
for(int i = 0; i < objlen; i++) objs[i] = readObjectBoxed(read, box);
yield objs;
}
case 23 -> UnitCommand.all.get(read.us());
case 23 -> content.unitCommand(read.us());
default -> throw new IllegalArgumentException("Unknown object type: " + type);
};
}
@@ -311,7 +311,7 @@ public class TypeIO{
public static @Nullable UnitCommand readCommand(Reads read){
int val = read.ub();
return val == 255 || val >= UnitCommand.all.size ? null : UnitCommand.all.get(val);
return val == 255 ? null : content.unitCommand(val);
}
public static void writeStance(Writes write, @Nullable UnitStance stance){
@@ -321,7 +321,7 @@ public class TypeIO{
public static UnitStance readStance(Reads read){
int val = read.ub();
//never returns null
return val == 255 || val >= UnitStance.all.size ? UnitStance.shoot : UnitStance.all.get(val);
return val == 255 || val >= content.unitStances().size ? UnitStance.shoot : content.unitStance(val);
}
public static void writeEntity(Writes write, Entityc entity){
@@ -576,7 +576,8 @@ public class TypeIO{
if(type == 6 || type == 7 || type == 8){
byte id = read.b();
ai.command = id < 0 ? null : UnitCommand.all.get(id);
ai.command = id < 0 ? null : content.unitCommand(id);
if(ai.command == null) ai.command = UnitCommand.moveCommand;
}
//command queue only in type 7