Add setProp of speed/armor

This commit is contained in:
Anuken 2023-10-31 12:20:18 -04:00
parent 3e80541c2d
commit 1d051b5c16
2 changed files with 7 additions and 3 deletions

View File

@ -35,7 +35,7 @@ import static mindustry.logic.GlobalVars.*;
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Displayable, Ranged, Minerc, Builderc, Senseable, Settable{
@Import boolean hovering, dead, disarmed;
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health, shield, ammo, dragMultiplier;
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health, shield, ammo, dragMultiplier, armorOverride, speedMultiplier;
@Import Team team;
@Import int id;
@Import @Nullable Tile mineTile;
@ -229,8 +229,9 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
case mining -> mining() ? 1 : 0;
case mineX -> mining() ? mineTile.x : -1;
case mineY -> mining() ? mineTile.y : -1;
case armor -> armorOverride >= 0f ? armorOverride : armor;
case flag -> flag;
case speed -> type.speed * 60f / tilesize;
case speed -> type.speed * 60f / tilesize * speedMultiplier;
case controlled -> !isValid() ? 0 :
controller instanceof LogicAI ? ctrlProcessor :
controller instanceof Player ? ctrlPlayer :
@ -293,6 +294,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
}
case flag -> flag = value;
case speed -> statusSpeed(Math.max((float)value, 0f));
case armor -> statusArmor(Math.max((float)value, 0f));
}
}

View File

@ -21,6 +21,7 @@ public enum LAccess{
maxHealth,
heat,
shield,
armor,
efficiency,
progress,
timescale,
@ -66,7 +67,7 @@ public enum LAccess{
all = values(),
senseable = Seq.select(all, t -> t.params.length <= 1).toArray(LAccess.class),
controls = Seq.select(all, t -> t.params.length > 0).toArray(LAccess.class),
settable = {x, y, rotation, team, flag, health, totalPower, payloadType};
settable = {x, y, rotation, speed, armor, health, team, flag, totalPower, payloadType};
LAccess(String... params){
this.params = params;