Skip to content

Commit

Permalink
VERY BROKEN PLEASE HELP
Browse files Browse the repository at this point in the history
The torque is torqueing my head
  • Loading branch information
Twcash committed Jul 31, 2024
1 parent 17d429c commit d7d561c
Show file tree
Hide file tree
Showing 36 changed files with 563 additions and 145 deletions.
20 changes: 20 additions & 0 deletions assets/shaders/normalMap.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#define HIGHP

uniform sampler2D u_texture;
uniform sampler2D u_normalMap;
uniform vec2 u_lightDirection;
uniform float u_lightIntensity;
varying vec2 v_texCoords;

void main() {
vec3 normal = texture2D(u_normalMap, v_texCoords).rgb;
normal = normalize(normal * 2.0 - 1.0); // Transform normal from [0,1] range to [-1,1] range

vec3 lightDir = normalize(vec3(u_lightDirection, 0.0));
float diff = max(dot(normal, lightDir), 0.0);

vec4 color = texture2D(u_texture, v_texCoords);
vec3 diffuse = diff * u_lightIntensity * vec3(1.0, 1.0, 1.0); // Adjust light color as needed

gl_FragColor = vec4(color.rgb * diffuse, color.a);
}
11 changes: 11 additions & 0 deletions assets/shaders/normalMap.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define HIGHP

attribute vec4 a_position;
attribute vec2 a_texCoord;

varying vec2 v_texCoords;

void main() {
v_texCoords = a_texCoord;
gl_Position = a_position;
}
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 modified assets/sprites/blocks/TorqueBlocks/torque-shaft-sheet.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.
Binary file added assets/sprites/blocks/defense/gallium-wall-normal.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/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 added assets/sprites/blocks/defense/gallium-walle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/aquarion/AquaAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
public class AquaAttributes {
public static Attribute
bauxite;
public static void load(){
public static void load(){
bauxite = Attribute.add("bauxite");
}}
}
}
9 changes: 7 additions & 2 deletions src/aquarion/AquarionMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import aquarion.planets.AquaPlanets;
import aquarion.units.AquaUnitTypes;
import arc.Core;
import arc.util.Log;
import mindustry.Vars;
import mindustry.mod.*;
import aquarion.blocks.*;

Expand All @@ -20,17 +23,19 @@ public class AquarionMod extends Mod {
//logic
@Override
public void loadContent() {
AquaAttributes.load();
AquaEffect.loadContent();
AquaLiquid.loadContent();
AquaItems.loadContent();
AquaDistribution.loadContent();
AquaPayload.loadContent();
AquaLiquid.loadContent();
AquaLiquids.loadContent();
AquaEnv.loadContent();
AquaDefense.loadContent();
AquaEffect.loadContent();
AquaUnitTypes.loadContent();
TorqueBlocks.loadContent();
AquaCore.loadContent();
AquaCrafters.loadContent();
AquaPlanets.loadContent();
}
}
16 changes: 16 additions & 0 deletions src/aquarion/LoadRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package aquarion;

import arc.graphics.Color;
import arc.graphics.g2d.Draw;
import arc.util.Disposable;

public class LoadRenderer implements Disposable {
public void draw() {
Draw.color(Color.black);
}

@Override
public void dispose() {
// Dispose of any resources if necessary
}
}
27 changes: 27 additions & 0 deletions src/aquarion/blocks/AquaCrafters.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
package aquarion.blocks;

import aquarion.AquaAttributes;
import aquarion.AquaItems;
import aquarion.world.blocks.rotPower.TorqueWallCrafter;
import mindustry.content.Items;
import mindustry.type.Category;
import mindustry.world.Block;
import mindustry.world.blocks.production.WallCrafter;
import mindustry.world.meta.Env;

import static mindustry.gen.Sounds.drill;
import static mindustry.type.ItemStack.with;

public class AquaCrafters {
public static Block bauxiteHarvester;
public static void loadContent(){
bauxiteHarvester = new TorqueWallCrafter("bauxite-harvester"){{
size = 4;
requirements(Category.production, with(Items.lead, 30, AquaItems.bauxite, 65));
researchCost = with(Items.lead, 15, AquaItems.bauxite, 10);
drillTime = 95;
attribute = AquaAttributes.bauxite;
output = AquaItems.bauxite;
ambientSound = drill;
ambientSoundVolume = 0.04F;
envEnabled|= Env.terrestrial | Env.underwater;
envDisabled|= Env.spores | Env.scorching;
}};
}
}
7 changes: 0 additions & 7 deletions src/aquarion/blocks/AquaDefense.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package aquarion.blocks;

import arc.graphics.Color;
import mindustry.content.Liquids;
import mindustry.graphics.Layer;
import mindustry.type.ItemStack;
import mindustry.world.Block;
import mindustry.world.blocks.defense.ForceProjector;
Expand All @@ -14,15 +11,11 @@
import static mindustry.content.Items.metaglass;
import static mindustry.content.Liquids.hydrogen;
import static mindustry.type.ItemStack.with;
import static mindustry.world.blocks.logic.LogicDisplay.GraphicsType.col;

import mindustry.type.Category;
import mindustry.world.blocks.units.DroneCenter;
import mindustry.world.draw.*;
import mindustry.world.meta.Env;

import javax.print.attribute.standard.Sides;

public class AquaDefense {
public static Block bauxiteWall, duraluminWall, forceBarrier, galliumWall, lithoniteWall, manganeseWall, mendHive, regenPylon, smallBauxiteWall, smallDuraluminWall, smallGalliumWall, smallLithoniteWall, smallManganeseWall;

Expand Down
1 change: 1 addition & 0 deletions src/aquarion/blocks/AquaEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public static void loadContent() {
bauxiticWall = new StaticWall("bauxitic-wall"){{
variants = 3;
itemDrop = bauxite;
attributes.set(AquaAttributes.bauxite, 1f);
}};


Expand Down
4 changes: 3 additions & 1 deletion src/aquarion/blocks/TorqueBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public static void loadContent() {
torqueSource = new TorqueProducer("torque-source"){{
buildVisibility = BuildVisibility.sandboxOnly;
size = 1;
torqueOutput = 30000;
torqueOutput = 10;
warmupRate = 1000f;
ambientSound = Sounds.none;
envEnabled|= Env.terrestrial | Env.underwater;
envDisabled|= Env.spores | Env.scorching;
}};
torqueShaft = new TorqueShaft("torque-shaft"){{
requirements(Category.crafting, with(bauxite, 2));
Expand Down
2 changes: 1 addition & 1 deletion src/aquarion/type/GerbUnitType.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void drawBody(Unit unit) {
TextureRegion[] regions;
TextureRegion armorRegion;

//buh what the hell is this??? I have no words to describe my confusion.
//Why won't this work??? I have no words to describe my confusion.
if (unit.health < unit.maxHealth * severeDamageThreshold) {
// huh huh huh huh
regions = getDamagedVariantRegions();
Expand Down
7 changes: 3 additions & 4 deletions src/aquarion/units/AquaUnitTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,13 @@ public static void loadContent() {
hitSize = 12;
legLength = 14;
legExtension = -2.5f;
flipLegSide = true;
flipBackLegs = true;
lockLegBase = true;
variants = 7;
variants = 7;
rotateSpeed = 6;
legPairOffset = 12f;
legMoveSpace = 1.5f;


}};
}
}

9 changes: 9 additions & 0 deletions src/aquarion/world/TorqueModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package aquarion.world;

import aquarion.world.graphs.TorqueGraph;
import arc.util.io.*;
import mindustry.world.modules.*;

public class TorqueModule{
public TorqueGraph graph = new TorqueGraph();
}
16 changes: 13 additions & 3 deletions src/aquarion/world/blocks/rotPower/TorqueBlock.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package aquarion.world.blocks.rotPower;

public interface TorqueBlock {
/**
* Returns the current amount of torque.
*/
float torque();
public boolean hasTorque = true;
/** @return rotPower as a fraction of max heat */
float torqueFract();

/**
* Sets the current amount of torque.
*/
void setTorque(float newTorque);

/**
* Returns the current amount of torque.
*/
float getTorque();
}
80 changes: 34 additions & 46 deletions src/aquarion/world/blocks/rotPower/TorqueBuildingComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,51 @@
import arc.struct.IntSet;
import arc.util.Nullable;
import mindustry.gen.Building;
import mindustry.world.Tile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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) {
private List<TorqueBlock> connectedTorqueBlocks = new ArrayList<>();
private float sharedTorque = 0f; // Shared torque value

public List<TorqueBlock> getConnectedTorqueBlocks() {
connectedTorqueBlocks.clear();
collectConnectedTorqueBlocks(this, new IntSet());
return connectedTorqueBlocks;
}

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;
}
private void collectConnectedTorqueBlocks(Building start, IntSet cameFrom) {
if (!cameFrom.add(start.id)) return; // Avoid cycles

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

//hehe haha eeh eeh ooh ooh
if (torqueE instanceof TorqueShaft.TorqueShaftBuild cond) {
cond.updateTorque();
}
for (var build : start.proximity) {
if (build != null && build.team == start.team && build instanceof TorqueBlock torqueE) {
if (!build.block.rotate || relativeTo(build) == build.rotation) {
collectConnectedTorqueBlocks((Building) torqueE, cameFrom);
}
}
}
return heat;
}
}

public void setSharedTorque(float torque) {
this.sharedTorque = torque;
// Propagate torque to all connected blocks
for (TorqueBlock block : getConnectedTorqueBlocks()) {
if (block instanceof TorqueShaft.TorqueShaftBuild build) {
build.setTorque(torque);
}
}
}

public float getSharedTorque() {
return sharedTorque;
}
}
Empty file.
2 changes: 1 addition & 1 deletion src/aquarion/world/blocks/rotPower/TorqueConsumer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aquarion.world.blocks.rotPower;

public interface TorqueConsumer{
public interface TorqueConsumer {
float[] torqueSide();
float torqueRequirement();
}
Empty file.
51 changes: 51 additions & 0 deletions src/aquarion/world/blocks/rotPower/TorqueNetwork.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package aquarion.world.blocks.rotPower;

import arc.struct.IntSet;
import mindustry.gen.Building;
import java.util.ArrayList;
import java.util.List;

public class TorqueNetwork {
private List<TorqueBlock> connectedTorqueBlocks = new ArrayList<>();
private float sharedTorque = 0f; // Shared torque value

public List<TorqueBlock> getConnectedTorqueBlocks(Building start) {
connectedTorqueBlocks.clear();
collectConnectedTorqueBlocks(start, new IntSet());
return connectedTorqueBlocks;
}

private void collectConnectedTorqueBlocks(Building start, IntSet cameFrom) {
if (!cameFrom.add(start.id)) return; // Avoid cycles

if (start instanceof TorqueBlock torqueBlock) {
connectedTorqueBlocks.add(torqueBlock);
}

for (var build : start.proximity) {
if (build != null && build.team == start.team && build instanceof TorqueBlock torqueE) {
if (!build.block.rotate || relativeTo(build) == build.rotation) {
collectConnectedTorqueBlocks(build, cameFrom);
}
}
}
}

public void setSharedTorque(Building start, float torque) {
this.sharedTorque = torque;
// Propagate torque to all connected blocks
for (TorqueBlock block : getConnectedTorqueBlocks(start)) {
block.setTorque(torque);
}
}

public float getSharedTorque() {
return sharedTorque;
}

// Helper method to determine relative direction
private int relativeTo(Building build) {
// Implementation of relativeTo method
return 0; // Placeholder
}
}
Loading

0 comments on commit d7d561c

Please sign in to comment.