mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 23:37:51 +07:00
Cleanup
This commit is contained in:
@ -0,0 +1 @@
|
||||
{fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:health,type:float},{name:isShooting,type:boolean},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:payloads,type:arc.struct.Seq<mindustry.world.blocks.payloads.Payload>},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
@ -50,7 +50,7 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class}) UnitType quad;
|
||||
|
||||
//air + building + payload + command
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class, Commanderc.class}) UnitType oct;
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class, Commanderc.class, AmmoDistributec.class}) UnitType oct;
|
||||
|
||||
//air + building + mining
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
||||
@ -1315,6 +1315,9 @@ public class UnitTypes implements ContentList{
|
||||
drawShields = false;
|
||||
commandLimit = 6;
|
||||
|
||||
ammoCapacity = 1300;
|
||||
ammoResupplyAmount = 20;
|
||||
|
||||
abilities.add(new ForceFieldAbility(140f, 4f, 7000f, 60f * 8), new HealFieldAbility(130f, 60f * 2, 140f));
|
||||
}};
|
||||
|
||||
|
28
core/src/mindustry/entities/comp/AmmoDistributeComp.java
Normal file
28
core/src/mindustry/entities/comp/AmmoDistributeComp.java
Normal file
@ -0,0 +1,28 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
|
||||
@Component
|
||||
abstract class AmmoDistributeComp implements Unitc{
|
||||
@Import float x, y;
|
||||
@Import UnitType type;
|
||||
@Import Team team;
|
||||
@Import float ammo;
|
||||
|
||||
private transient float ammoCooldown;
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(ammoCooldown > 0f) ammoCooldown -= Time.delta;
|
||||
|
||||
if(ammo > 0 && ammoCooldown <= 0f && ResupplyPoint.resupply(team, x, y, type.ammoResupplyRange, Math.min(type.ammoResupplyAmount, ammo), type.ammoType.color, u -> u != self())){
|
||||
ammo -= Math.min(type.ammoResupplyAmount, ammo);
|
||||
ammoCooldown = 5f;
|
||||
}
|
||||
}
|
||||
}
|
@ -65,6 +65,9 @@ public class UnitType extends UnlockableContent{
|
||||
public float legSplashDamage = 0f, legSplashRange = 5;
|
||||
public boolean flipBackLegs = true;
|
||||
|
||||
public int ammoResupplyAmount = 10;
|
||||
public float ammoResupplyRange = 100f;
|
||||
|
||||
public float mechSideSway = 0.54f, mechFrontSway = 0.1f;
|
||||
public float mechStride = -1f;
|
||||
public float mechStepShake = -1f;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.AmmoTypes.*;
|
||||
@ -51,12 +53,18 @@ public class ResupplyPoint extends Block{
|
||||
|
||||
/** Tries to resupply nearby units.
|
||||
* @return whether resupplying was successful. If unit ammo is disabled, always returns false. */
|
||||
public static boolean resupply(Building tile, float range, int ammoAmount, Color ammoColor){
|
||||
public static boolean resupply(Building tile, float range, float ammoAmount, Color ammoColor){
|
||||
return resupply(tile.team, tile.x, tile.y, range, ammoAmount, ammoColor, u -> true);
|
||||
}
|
||||
|
||||
/** Tries to resupply nearby units.
|
||||
* @return whether resupplying was successful. If unit ammo is disabled, always returns false. */
|
||||
public static boolean resupply(Team team, float x, float y, float range, float ammoAmount, Color ammoColor, Boolf<Unit> valid){
|
||||
if(!state.rules.unitAmmo) return false;
|
||||
|
||||
Unit unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.type().ammoType instanceof ItemAmmoType && u.ammo <= u.type().ammoCapacity - ammoAmount);
|
||||
Unit unit = Units.closest(team, x, y, range, u -> u.type().ammoType instanceof ItemAmmoType && u.ammo <= u.type().ammoCapacity - ammoAmount && valid.get(u));
|
||||
if(unit != null){
|
||||
Fx.itemTransfer.at(tile.x, tile.y, ammoAmount / 2f, ammoColor, unit);
|
||||
Fx.itemTransfer.at(x, y, ammoAmount / 2f, ammoColor, unit);
|
||||
unit.ammo = Math.min(unit.ammo + ammoAmount, unit.type().ammoCapacity);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user