-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
404 additions
and
11 deletions.
There are no files selected for viewing
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
67
src/aquarion/world/blocks/rotPower/TorqueBuildingComp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
Oops, something went wrong.