Skip to content

Commit

Permalink
Torque previews and env reworking
Browse files Browse the repository at this point in the history
  • Loading branch information
Twcash committed Jul 18, 2024
1 parent 4836155 commit baf5052
Show file tree
Hide file tree
Showing 34 changed files with 404 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/TorqueBlocks/torque-source.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/items/talkine.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 added assets/sprites/units/core/glean-crystal1.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 added assets/sprites/units/core/glean-crystal2.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 added assets/sprites/units/core/glean-full.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 added assets/sprites/units/core/glean-mid.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 added assets/sprites/units/core/glean-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/aquarion/AquaAttributes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package aquarion;
import mindustry.world.meta.Attribute;

public class AquaAttributes {
public static Attribute
bauxite;
public static void load(){
bauxite = Attribute.add("bauxite");
}}
1 change: 1 addition & 0 deletions src/aquarion/AquarionMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void loadContent() {
AquaDefense.loadContent();
AquaEffect.loadContent();
AquaUnitTypes.loadContent();
TorqueBlocks.loadContent();
AquaCore.loadContent();
}
}
18 changes: 15 additions & 3 deletions src/aquarion/blocks/AquaEnv.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package aquarion.blocks;

import aquarion.AquaAttributes;
import aquarion.AquaItems;
import aquarion.AquaLiquids;
import aquarion.world.blocks.environment.PineTree;
Expand All @@ -15,6 +16,7 @@
import aquarion.AquaItems.*;
import aquarion.AquaLiquids.*;

import static aquarion.AquaItems.bauxite;
import static mindustry.content.Blocks.*;
import static mindustry.content.Items.lead;
import static mindustry.world.meta.BuildVisibility.sandboxOnly;
Expand All @@ -26,13 +28,13 @@ public class AquaEnv {
public static Block algalBoulder, feldsparBoulder, gabbroBoulder, kelp, rockweed, urchin;

// Floors
public static Block algal_carpet, brine_liquid, coral_floor, feldspar_vent, feldspar, ferric_extrusions, gabbro_extrusions, gabbro_vent, gabbro, geothermal_vent, kelp_floor, roughFeldspar, phylite_floor, slate, shaleVent, andesite, andesiteRubble, andesiteVent;
public static Block andesiteLayers, basaltSpikes ,algal_carpet, brine_liquid, coral_floor, feldspar_vent, feldspar, ferric_extrusions, gabbro_extrusions, gabbro_vent, gabbro, geothermal_vent, kelp_floor, roughFeldspar, phylite_floor, slate, shaleVent, andesite, andesiteRubble, andesiteVent;

// Ore blocks
public static Block leadNodules, oreBauxite, oreGallium, oreLithium, oreManganese;

// Walls
public static Block algalBloom, parzilPine, algalWall, bloom, coralWall, feldsparWall, gabbroWall, andesiteExtrusions;
public static Block bauxiticWall ,algalBloom, parzilPine, algalWall, bloom, coralWall, feldsparWall, gabbroWall, andesiteExtrusions;

public static void loadContent() {

Expand Down Expand Up @@ -64,6 +66,9 @@ public static void loadContent() {
feldspar = new Floor("feldspar", 3) {{
decoration = feldsparBoulder;
}};
andesiteLayers = new Floor("andesite-layers", 4){{

}};

feldspar_vent = new SteamVent("feldspar-vent") {{
attributes.set(Attribute.steam, 1f);
Expand Down Expand Up @@ -195,6 +200,9 @@ public static void loadContent() {
}};
slate = new Floor("slate", 3) {{

}};
basaltSpikes = new Floor("basalt-spikes", 4) {{

}};
andesiteExtrusions = new TallBlock("andesite-extrusions"){{
variants = 2;
Expand All @@ -205,12 +213,16 @@ public static void loadContent() {

// Ore blocks
leadNodules = new OreBlock("lead-nodules", lead);
oreBauxite = new OreBlock("ore-bauxite", AquaItems.bauxite);
oreBauxite = new OreBlock("ore-bauxite", bauxite);
oreGallium= new OreBlock("ore-gallium", AquaItems.gallium);
oreLithium= new OreBlock("ore-lithium", AquaItems.lithium);
oreManganese= new OreBlock("ore-manganese", AquaItems.manganese);

// Walls & blocks
bauxiticWall = new StaticWall("bauxitic-wall"){{
variants = 3;
itemDrop = bauxite;
}};


algalBloom = new StaticWall("algal-bloom") {{
Expand Down
33 changes: 33 additions & 0 deletions src/aquarion/blocks/TorqueBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package aquarion.blocks;

import aquarion.world.blocks.rotPower.TorqueProducer;
import aquarion.world.blocks.rotPower.TorqueShaft;
import mindustry.gen.Sounds;
import mindustry.type.Category;
import mindustry.world.Block;
import mindustry.world.meta.BuildVisibility;
import mindustry.world.meta.Env;

import static aquarion.AquaItems.bauxite;
import static mindustry.type.ItemStack.with;

public class TorqueBlocks {
public static Block torqueSource, torqueShaft;

public static void loadContent() {
torqueSource = new TorqueProducer("torque-source"){{
buildVisibility = BuildVisibility.sandboxOnly;
size = 1;
torqueOutput = 30000;
warmupRate = 1000f;
ambientSound = Sounds.none;
}};
torqueShaft = new TorqueShaft("torque-shaft"){{
requirements(Category.crafting, with(bauxite, 2));
size = 1;
solid = true;
envEnabled|= Env.terrestrial | Env.underwater;
envDisabled|= Env.spores | Env.scorching;
}};
}
}
94 changes: 87 additions & 7 deletions src/aquarion/units/AquaUnitTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static mindustry.Vars.tilePayload;

public class AquaUnitTypes {
public static UnitType cull;
public static UnitType cull, glean;
public static void loadContent() {
cull = new UnitType("cull"){{
constructor = UnitEntity::create;
Expand All @@ -31,6 +31,8 @@ public static void loadContent() {
mineSpeed = 9;
accel = 0.08f;
drag = 0.1f;
mineWalls = true;
mineFloor = true;
buildSpeed = 1.2f;
rotateSpeed = 12;
health = 250;
Expand All @@ -47,22 +49,78 @@ public static void loadContent() {
}},
new RegionPart("-crystal1"){{
moveY = -2;
moveX = 1;
moveX = 0;
mirror = true;
heatColor = Pal.accent;
weaponIndex = 0;
progress = heatProgress = PartProgress.warmup;
}},
new RegionPart("-mid"){{}},
new RegionPart("-side"){{
moveY = -1;
moveX = 1;
moveRot = 10;
moveY = -.25f;
moveX = -.5f;
moveRot = -10;
weaponIndex = 0;
mirror = true;
progress = heatProgress = PartProgress.warmup;
heatColor = Pal.accent;
}},
new RegionPart("-mid"){{}},
new RegionPart("-crystal2"){{
moveY = -0.5f;
moveX = -.5f;
moveRot = -5;
weaponIndex = 0;
progress = heatProgress = PartProgress.warmup;
heatColor = Pal.accent;
mirror = true;
}}
);
weapons.add(
new RepairBeamWeapon("cull-b"){{
mirror = false;
rotate = true;
autoTarget = true;
name = "cull-b";
x = 0;
y = 0;
controllable = false;
targetUnits = true;
targetBuildings = true;
fractionRepairSpeed = 0.02f;
widthSinMag = 0.11f;
healColor = laserColor = Pal.accent;
bullet = new BulletType(){{
maxRange = 60;
}};
}}
);
}};
glean = new UnitType("glean"){{
constructor = UnitEntity::create;
hittable = isEnemy = targetable = drawCell = allowedInPayloads = drawBody = false;
payloadCapacity = (2 *2 ) * tilePayload;
outlineColor = AquaPal.tantDarkerTone;
lowAltitude = flying = coreUnitDock = true;
aiController = BuilderAI::new;
healColor = Pal.accent;
armor = 3;
speed = 15;
fogRadius = 0;
buildRange = 250;
mineSpeed = 12;
accel = 0.12f;
drag = 0.13f;
mineWalls = true;
mineFloor = true;
buildSpeed = 2f;
rotateSpeed = 15;
health = 550;
engineSize = 0;
mineTier = 3;
hitSize = 9;
envEnabled|= Env.terrestrial | Env.underwater;
envDisabled|= Env.spores | Env.scorching;
parts.addAll(
new RegionPart("-crystal2"){{
moveY = -0.5f;
moveX = -1;
Expand All @@ -71,6 +129,28 @@ public static void loadContent() {
progress = heatProgress = PartProgress.warmup;
heatColor = Pal.accent;
mirror = true;
}},
new RegionPart("-mid"){{
progress = PartProgress.warmup;
moveY = 0.5f;
weaponIndex = 0;
}},
new RegionPart("-side"){{
moveY = -1;
moveX = 1;
moveRot = -5;
weaponIndex = 0;
mirror = true;
progress = heatProgress = PartProgress.warmup;
heatColor = Pal.accent;
}},
new RegionPart("-crystal1"){{
moveY = -0.5f;
moveX = -0.5f;
moveRot = -1;
mirror = true;
heatColor = Pal.accent;
weaponIndex = 0;
}}
);
weapons.add(
Expand All @@ -84,7 +164,7 @@ public static void loadContent() {
controllable = false;
targetUnits = true;
targetBuildings = true;
fractionRepairSpeed = 0.02f;
fractionRepairSpeed = 0.04f;
widthSinMag = 0.11f;
healColor = laserColor = Pal.accent;
bullet = new BulletType(){{
Expand Down
2 changes: 1 addition & 1 deletion src/aquarion/world/blocks/environment/PineTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class PineTree extends Block {
public float shadowOffset = -4f;
public float layer = Layer.power + 10;
public Effect effect = Fx.ventSteam;
public Effect effect = Fx.impactReactorExplosion;
public float effectSpacing = 15f;
public float shadowLayer = Layer.power - 1;
public float updateEffectChance = 0.5f;
Expand Down
7 changes: 7 additions & 0 deletions src/aquarion/world/blocks/rotPower/TorqueBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package aquarion.world.blocks.rotPower;

public interface TorqueBlock {
float torque();
/** @return rotPower as a fraction of max heat */
float torqueFract();
}
67 changes: 67 additions & 0 deletions src/aquarion/world/blocks/rotPower/TorqueBuildingComp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package aquarion.world.blocks.rotPower;

import aquarion.blocks.TorqueBlocks;
import arc.math.Mathf;
import arc.struct.IntSet;
import arc.util.Nullable;
import mindustry.gen.Building;

import java.util.Arrays;

import static mindustry.Vars.tilesize;

public class TorqueBuildingComp extends Building {
public float calculateTorque(float[] torqueSide) {
return calculateTorque(torqueSide, null);
}

public float calculateTorque(float[] torqueSide, @Nullable IntSet cameFrom) {
Arrays.fill(torqueSide, 0f);
if (cameFrom != null) cameFrom.clear();

float heat = 0f;

for (var build : proximity) {
if (build != null && build.team == team && build instanceof TorqueBlock torqueE) {


boolean split = build.block instanceof TorqueShaft cond && cond.splitTorque;
// non-routers must face us, routers must face away - next to a redirector, they're forced to face away due to cycles anyway
if (!build.block.rotate || (!split && (relativeTo(build) + 2) % 4 == build.rotation) || (split && relativeTo(build) != build.rotation)) { //TODO hacky

//if there's a cycle, ignore its heat
if (!(build instanceof TorqueShaft.TorqueShaftBuild hc && hc.cameFrom.contains(id()))) {
//x/y coordinate difference across point of contact
float diff = (Math.min(Math.abs(build.x - x), Math.abs(build.y - y)) / tilesize);
//number of points that this block had contact with
int contactPoints = Math.min((int) (block.size / 2f + build.block.size / 2f - diff), Math.min(build.block.size, block.size));

//heat is distributed across building size
float add = torqueE.torque() / build.block.size * contactPoints;
if (split) {
//heat routers split heat across 3 surfaces
add /= 3f;
}

torqueSide[Mathf.mod(relativeTo(build), 4)] += add;
heat += add;
}

//register traversed cycles
if (cameFrom != null) {
cameFrom.add(build.id);
if (build instanceof TorqueShaft.TorqueShaftBuild hc) {
cameFrom.addAll(hc.cameFrom);
}
}

//hehe haha eeh eeh ooh ooh
if (torqueE instanceof TorqueShaft.TorqueShaftBuild cond) {
cond.updateTorque();
}
}
}
}
return heat;
}
}
6 changes: 6 additions & 0 deletions src/aquarion/world/blocks/rotPower/TorqueConsumer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package aquarion.world.blocks.rotPower;

public interface TorqueConsumer{
float[] torqueSide();
float torqueRequirement();
}
Loading

0 comments on commit baf5052

Please sign in to comment.