Skip to content

Commit

Permalink
defense stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Twcash committed Aug 25, 2024
1 parent 187830e commit 3d1b0bc
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 1 deletion.
Binary file modified assets/sprites/blocks/defense/bauxite-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/sprites/blocks/defense/duralumin-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/sprites/blocks/defense/gallium-wall-normal.png
Binary file not shown.
Binary file modified assets/sprites/blocks/defense/gallium-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/sprites/blocks/defense/gallium-walle.png
Binary file not shown.
Binary file modified assets/sprites/blocks/defense/manganese-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/sprites/blocks/defense/small-bauxite-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/sprites/blocks/defense/small-duralumin-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/sprites/blocks/defense/small-gallium-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/sprites/blocks/defense/small-manganese-wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/aquarion/blocks/AquaDefense.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package aquarion.blocks;

import aquarion.world.blocks.defense.BlockingForceProjector;
import mindustry.type.ItemStack;
import mindustry.world.Block;
import mindustry.world.blocks.defense.ForceProjector;
Expand Down Expand Up @@ -130,7 +131,7 @@ public static void loadContent() {
}};


forceBarrier = new ForceProjector("force-barrier"){{
forceBarrier = new BlockingForceProjector("force-barrier"){{
requirements(Category.defense, ItemStack.with(lead,80, duralumin, 120, metaglass, 90, nitride, 150));
consumePower(3f / 60f);
sides = 18;
Expand Down
68 changes: 68 additions & 0 deletions src/aquarion/world/blocks/defense/BlockingForceProjector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package aquarion.world.blocks.defense;

import arc.math.*;
import arc.util.Time;
import arc.util.Tmp;
import arc.util.io.Reads;
import arc.util.io.Writes;
import mindustry.content.Fx;
import mindustry.entities.Units;
import mindustry.gen.*;
import mindustry.type.UnitType;
import mindustry.world.*;
import mindustry.world.blocks.defense.ForceProjector;

public class BlockingForceProjector extends ForceProjector {
public BlockingForceProjector(String name) {
super(name);
}

@Override
public void init() {
super.init();
}

public class BlockingForceBuild extends ForceBuild {
@Override
public void updateTile() {
super.updateTile();
float effectiveRadius = radius(); // Get the correct shield radius

if (!broken && effectiveRadius > 1) {
Units.nearbyEnemies(team, x, y, effectiveRadius + 10f, unit -> {
float overlapDst = (unit.hitSize / 2f + effectiveRadius) - unit.dst(x, y);
if (!unit.isGrounded()){
if (overlapDst > 0) {
unit.vel.setZero(); // Stop units
unit.move(Tmp.v1.set(unit).sub(x, y).setLength(overlapDst + 0.01f)); // Push units out
if (Mathf.chanceDelta(0.12f * Time.delta)) {
Fx.circleColorSpark.at(unit.x, unit.y, team.color);
}
}
}
});
}
}

@Override
public void draw() {
super.draw();
drawShield(); // Draw the shield
}

@Override
public void write(Writes write) {
super.write(write);
}

@Override
public void read(Reads read, byte revision) {
super.read(read, revision);
}

public float radius() {
// Override to ensure it returns the effective shield radius
return realRadius(); // Ensure this matches the logic for effective radius in ForceProjector
}
}
}

0 comments on commit 3d1b0bc

Please sign in to comment.