Fixed setProp x/y not teleporting on strict servers

This commit is contained in:
Anuken
2023-09-22 10:06:43 -04:00
parent 71e049d92d
commit f633fb0af5
13 changed files with 37 additions and 30 deletions

View File

@@ -347,7 +347,7 @@ open = Open
customize = Customize Rules customize = Customize Rules
cancel = Cancel cancel = Cancel
command = Command command = Command
command.queue = [lightgray][Queuing] command.queue = Queue
command.mine = Mine command.mine = Mine
command.repair = Repair command.repair = Repair
command.rebuild = Rebuild command.rebuild = Rebuild

View File

@@ -31,6 +31,14 @@ public class UnitCommand{
switchToMove = false; switchToMove = false;
drawTarget = true; drawTarget = true;
resetTarget = false; resetTarget = false;
}},
loadPayloadCommand = new UnitCommand("loadPayload", "download", u -> null){{
switchToMove = false;
drawTarget = true;
}},
unloadPayloadCommand = new UnitCommand("unloadPayload", "upload", u -> null){{
switchToMove = false;
drawTarget = true;
}}; }};
/** Unique ID number. */ /** Unique ID number. */

View File

@@ -11,9 +11,9 @@ public class UnitStance{
public static final UnitStance public static final UnitStance
stopStance = new UnitStance("stop", "cancel"), //not a real stance, cannot be selected, just cancels ordewrs stop = new UnitStance("stop", "cancel"), //not a real stance, cannot be selected, just cancels ordewrs
shootStance = new UnitStance("shoot", "commandAttack"), shoot = new UnitStance("shoot", "commandAttack"),
holdFireStance = new UnitStance("holdfire", "none"), holdFire = new UnitStance("holdfire", "none"),
pursueTarget = new UnitStance("pursuetarget", "right"), pursueTarget = new UnitStance("pursuetarget", "right"),
patrol = new UnitStance("patrol", "refresh"), patrol = new UnitStance("patrol", "refresh"),
ram = new UnitStance("ram", "rightOpen"); ram = new UnitStance("ram", "rightOpen");

View File

@@ -31,7 +31,7 @@ public class CommandAI extends AIController{
protected boolean flocked; protected boolean flocked;
/** Stance, usually related to firing mode. */ /** Stance, usually related to firing mode. */
public UnitStance stance = UnitStance.shootStance; public UnitStance stance = UnitStance.shoot;
/** Current command this unit is following. */ /** Current command this unit is following. */
public @Nullable UnitCommand command; public @Nullable UnitCommand command;
/** Current controller instance based on command. */ /** Current controller instance based on command. */
@@ -65,7 +65,7 @@ public class CommandAI extends AIController{
@Override @Override
public void updateUnit(){ public void updateUnit(){
//this should not be possible //this should not be possible
if(stance == UnitStance.stopStance) stance = UnitStance.shootStance; if(stance == UnitStance.stop) stance = UnitStance.shoot;
if(stance == UnitStance.pursueTarget && target != null && attackTarget == null && targetPos == null){ if(stance == UnitStance.pursueTarget && target != null && attackTarget == null && targetPos == null){
commandTarget(target, false); commandTarget(target, false);
@@ -279,7 +279,7 @@ public class CommandAI extends AIController{
@Override @Override
public boolean shouldFire(){ public boolean shouldFire(){
return stance != UnitStance.holdFireStance; return stance != UnitStance.holdFire;
} }
@Override @Override

View File

@@ -1285,8 +1285,6 @@ public class UnitTypes{
lowAltitude = true; lowAltitude = true;
ammoType = new PowerAmmoType(900); ammoType = new PowerAmmoType(900);
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.patrol};
mineTier = 2; mineTier = 2;
mineSpeed = 3.5f; mineSpeed = 3.5f;
@@ -1345,7 +1343,6 @@ public class UnitTypes{
isEnemy = false; isEnemy = false;
ammoType = new PowerAmmoType(1100); ammoType = new PowerAmmoType(1100);
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.patrol};
weapons.add( weapons.add(
new Weapon("heal-weapon-mount"){{ new Weapon("heal-weapon-mount"){{

View File

@@ -696,7 +696,6 @@ public class NetServer implements ApplicationListener{
vector.limit(maxMove); vector.limit(maxMove);
float prevx = unit.x, prevy = unit.y; float prevx = unit.x, prevy = unit.y;
//unit.set(con.lastPosition);
if(!unit.isFlying()){ if(!unit.isFlying()){
unit.move(vector.x, vector.y); unit.move(vector.x, vector.y);
}else{ }else{

View File

@@ -269,8 +269,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
} }
} }
case shield -> shield = Math.max((float)value, 0f); case shield -> shield = Math.max((float)value, 0f);
case x -> x = World.unconv((float)value); case x -> {
case y -> y = World.unconv((float)value); x = World.unconv((float)value);
if(!isLocal()) snapInterpolation();
}
case y -> {
y = World.unconv((float)value);
if(!isLocal()) snapInterpolation();
}
case rotation -> rotation = (float)value; case rotation -> rotation = (float)value;
case team -> { case team -> {
if(!net.client()){ if(!net.client()){

View File

@@ -325,7 +325,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
for(int id : unitIds){ for(int id : unitIds){
Unit unit = Groups.unit.getByID(id); Unit unit = Groups.unit.getByID(id);
if(unit != null && unit.team == player.team() && unit.controller() instanceof CommandAI ai){ if(unit != null && unit.team == player.team() && unit.controller() instanceof CommandAI ai){
if(stance == UnitStance.stopStance){ //not a real stance, just cancels orders if(stance == UnitStance.stop){ //not a real stance, just cancels orders
ai.clearCommands(); ai.clearCommands();
}else{ }else{
ai.stance = stance; ai.stance = stance;

View File

@@ -288,23 +288,20 @@ public class MobileInput extends InputHandler implements GestureListener{
t.visible(() -> !showCancel() && block == null && !hasSchem()); t.visible(() -> !showCancel() && block == null && !hasSchem());
t.bottom().left(); t.bottom().left();
t.button("@command.queue", Icon.rightOpen, Styles.clearTogglet, () -> {
queueCommandMode = !queueCommandMode;
}).width(155f).height(48f).margin(12f).checked(b -> queueCommandMode).visible(() -> commandMode).row();
t.button("@command", Icon.units, Styles.clearTogglet, () -> { t.button("@command", Icon.units, Styles.clearTogglet, () -> {
commandMode = !commandMode; commandMode = !commandMode;
}).width(155f).height(56f).margin(12f).checked(b -> { }).width(155f).height(48f).margin(12f).checked(b -> commandMode);
b.setText(queueCommandMode ? bundle.get("command") + "\n" + bundle.get("command.queue") : bundle.get("command"));
return commandMode;
});
t.button(Icon.rightOpen, Styles.clearTogglei, () -> {
queueCommandMode = !queueCommandMode;
}).size(56f).margin(12f).checked(b -> queueCommandMode).visible(() -> commandMode).row();
//for better looking insets //for better looking insets
t.rect((x, y, w, h) -> { t.rect((x, y, w, h) -> {
if(Core.scene.marginBottom > 0){ if(Core.scene.marginBottom > 0){
Tex.paneRight.draw(x, 0, w, y); Tex.paneRight.draw(x, 0, w, y);
} }
}).fillX().colspan(2).row(); }).fillX().row();
}); });
group.fill(t -> { group.fill(t -> {

View File

@@ -321,7 +321,7 @@ public class TypeIO{
public static UnitStance readStance(Reads read){ public static UnitStance readStance(Reads read){
int val = read.ub(); int val = read.ub();
//never returns null //never returns null
return val == 255 ? UnitStance.shootStance : UnitStance.all.get(val); return val == 255 ? UnitStance.shoot : UnitStance.all.get(val);
} }
public static void writeEntity(Writes write, Entityc entity){ public static void writeEntity(Writes write, Entityc entity){

View File

@@ -836,13 +836,13 @@ public class UnitType extends UnlockableContent implements Senseable{
if(stances.length == 0){ if(stances.length == 0){
if(canAttack){ if(canAttack){
Seq<UnitStance> seq = Seq.with(UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.pursueTarget, UnitStance.patrol); Seq<UnitStance> seq = Seq.with(UnitStance.stop, UnitStance.shoot, UnitStance.holdFire, UnitStance.pursueTarget, UnitStance.patrol);
if(crushDamage > 0){ if(crushDamage > 0){
seq.add(UnitStance.ram); seq.add(UnitStance.ram);
} }
stances = seq.toArray(UnitStance.class); stances = seq.toArray(UnitStance.class);
}else{ }else{
stances = new UnitStance[]{UnitStance.stopStance}; stances = new UnitStance[]{UnitStance.stop};
} }
} }

View File

@@ -522,7 +522,7 @@ public class PlacementFragment{
for(var command : commands){ for(var command : commands){
coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> { coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
Call.setUnitCommand(player, units.mapInt(un -> un.id).toArray(), command); Call.setUnitCommand(player, units.mapInt(un -> un.id).toArray(), command);
}).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized()); }).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized(), true);
if(++scol % 6 == 0) coms.row(); if(++scol % 6 == 0) coms.row();
} }
@@ -541,7 +541,7 @@ public class PlacementFragment{
coms.button(Icon.icons.get(stance.icon, Icon.cancel), Styles.clearNoneTogglei, () -> { coms.button(Icon.icons.get(stance.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
Call.setUnitStance(player, units.mapInt(un -> un.id).toArray(), stance); Call.setUnitStance(player, units.mapInt(un -> un.id).toArray(), stance);
}).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized()); }).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized(), true);
if(++scol % 6 == 0) coms.row(); if(++scol % 6 == 0) coms.row();
} }
@@ -597,7 +597,7 @@ public class PlacementFragment{
//not a huge fan of running input logic here, but it's convenient as the stance arrays are all here... //not a huge fan of running input logic here, but it's convenient as the stance arrays are all here...
for(int i = 0; i < Math.min(stanceBindings.length, stances.size); i++){ for(int i = 0; i < Math.min(stanceBindings.length, stances.size); i++){
//first stance must always be the stop stance //first stance must always be the stop stance
if(Core.input.keyTap(stanceBindings[i]) && (i != 0 || stances.get(0) == UnitStance.stopStance)){ if(Core.input.keyTap(stanceBindings[i]) && (i != 0 || stances.get(0) == UnitStance.stop)){
Call.setUnitStance(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), stances.get(i)); Call.setUnitStance(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), stances.get(i));
} }
} }

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=38114a3118 archash=0c61237b32