Added more unit configuration options

This commit is contained in:
Anuken
2021-12-04 09:24:40 -05:00
parent f89f460b47
commit 0f23fac963
3 changed files with 10 additions and 7 deletions

View File

@@ -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();
}
}

View File

@@ -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);

View File

@@ -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;