From 0f23fac963790795348f3c97ac0af1ef7de42403 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 4 Dec 2021 09:24:40 -0500 Subject: [PATCH] Added more unit configuration options --- core/src/mindustry/entities/comp/UnitComp.java | 6 +++--- core/src/mindustry/input/InputHandler.java | 8 ++++---- core/src/mindustry/type/UnitType.java | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index e5f72ef202..3ed7b9287d 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -328,7 +328,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I team.data().updateCount(type, 1); //check if over unit cap - if(count() > cap() && !spawnedByCore && !dead && !state.rules.editor){ + if(type.useUnitCap && count() > cap() && !spawnedByCore && !dead && !state.rules.editor){ Call.unitCapDeath(self()); team.data().updateCount(type, -1); } @@ -513,7 +513,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I } //if this unit crash landed (was flying), damage stuff in a radius - if(type.flying && !spawnedByCore){ + if(type.flying && !spawnedByCore && !type.createWreck){ Damage.damage(team, x, y, Mathf.pow(hitSize, 0.94f) * 1.25f, Mathf.pow(hitSize, 0.75f) * type.crashDamageMultiplier * 5f, true, false, true); } @@ -577,7 +577,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I dead = true; //don't waste time when the unit is already on the ground, just destroy it - if(!type.flying){ + if(!type.flying || !type.createWreck){ destroy(); } } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 0bcc17727e..bffd919f7b 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -395,7 +395,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(unit == null){ //just clear the unit (is this used?) player.clearUnit(); //make sure it's AI controlled, so players can't overwrite each other - }else if(unit.isAI() && unit.team == player.team() && !unit.dead){ + }else if(unit.isAI() && unit.team == player.team() && !unit.dead && unit.type.playerControllable){ if(net.client() && player.isLocal()){ player.justSwitchFrom = player.unit(); player.justSwitchTo = unit; @@ -495,7 +495,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ controlledType = player.unit().type; } - if(controlledType != null && player.dead()){ + if(controlledType != null && player.dead() && controlledType.playerControllable){ Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type == controlledType && !u.dead); if(unit != null){ @@ -509,7 +509,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public void checkUnit(){ - if(controlledType != null){ + if(controlledType != null && controlledType.playerControllable){ Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type == controlledType && !u.dead); if(unit == null && controlledType == UnitTypes.block){ unit = world.buildWorld(player.x, player.y) instanceof ControlBlock cont && cont.canControl() ? cont.unit() : null; @@ -1101,7 +1101,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public @Nullable Unit selectedUnit(){ - Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, Unitc::isAI); + Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, u -> u.isAI() && u.type.playerControllable); if(unit != null){ unit.hitbox(Tmp.r1); Tmp.r1.grow(6f); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 2eaf8fbed2..7110505bfb 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -65,7 +65,10 @@ public class UnitType extends UnlockableContent{ public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false, circleTarget = false; public boolean canBoost = false; public boolean logicControllable = true; + public boolean playerControllable = true; public boolean allowedInPayloads = true; + public boolean createWreck = true; + public boolean useUnitCap = true; public boolean destructibleWreck = true; public float groundLayer = Layer.groundUnit; public float payloadCapacity = 8;