Logic second/minute spent variables

This commit is contained in:
Anuken 2022-03-13 21:39:35 -04:00
parent 5ad5211f97
commit c5bf0f6768
6 changed files with 27 additions and 19 deletions

View File

@ -1,6 +1,6 @@
#define MAX_SHOCKWAVES 64 #define MAX_SHOCKWAVES 64
#define WAVE_RADIUS 4.0 #define WAVE_RADIUS 5.0
#define DIFF_SCL 1 #define DIFF_SCL 1.5
#define WAVE_POW 0.8 #define WAVE_POW 0.8
varying vec2 v_texCoords; varying vec2 v_texCoords;
@ -19,12 +19,12 @@ void main(){
for(int i = 0; i < MAX_SHOCKWAVES; i ++){ for(int i = 0; i < MAX_SHOCKWAVES; i ++){
vec4 wave = u_shockwaves[i]; vec4 wave = u_shockwaves[i];
float radius = wave.z; float radius = wave.z;
float strength = wave.w;
float dst = distance(worldCoords, wave.xy); float dst = distance(worldCoords, wave.xy);
float realStrength = 1.0 - pow(1.0 - strength, 5.0); float strength = wave.w * (1.0 - abs(dst - radius) / WAVE_RADIUS);
if(abs(dst - radius) <= WAVE_RADIUS){ if(abs(dst - radius) <= WAVE_RADIUS){
float diff = dst - radius; float diff = (dst - radius);
float pdiff = 1.0 - pow(abs(diff * DIFF_SCL), WAVE_POW); float pdiff = 1.0 - pow(abs(diff * DIFF_SCL), WAVE_POW);
float diffTime = diff * pdiff; float diffTime = diff * pdiff;
vec2 relative = normalize(worldCoords - wave.xy); vec2 relative = normalize(worldCoords - wave.xy);

View File

@ -387,7 +387,7 @@ public class UnitTypes{
status = StatusEffects.shocked; status = StatusEffects.shocked;
statusDuration = 10f; statusDuration = 10f;
hittable = false; hittable = false;
healPercent = 2f; healPercent = 1.6f;
collidesTeam = true; collidesTeam = true;
}}; }};
}}; }};
@ -632,7 +632,7 @@ public class UnitTypes{
}}; }};
atrax = new UnitType("atrax"){{ atrax = new UnitType("atrax"){{
speed = 0.57f; speed = 0.6f;
drag = 0.4f; drag = 0.4f;
hitSize = 13f; hitSize = 13f;
rotateSpeed = 3f; rotateSpeed = 3f;
@ -672,11 +672,11 @@ public class UnitTypes{
}}; }};
spiroct = new UnitType("spiroct"){{ spiroct = new UnitType("spiroct"){{
speed = 0.52f; speed = 0.54f;
drag = 0.4f; drag = 0.4f;
hitSize = 15f; hitSize = 15f;
rotateSpeed = 3f; rotateSpeed = 3f;
health = 940; health = 1000;
immunities = ObjectSet.with(StatusEffects.burning, StatusEffects.melting); immunities = ObjectSet.with(StatusEffects.burning, StatusEffects.melting);
legCount = 6; legCount = 6;
legLength = 13f; legLength = 13f;
@ -979,7 +979,7 @@ public class UnitTypes{
targetAir = false; targetAir = false;
targetFlags = new BlockFlag[]{BlockFlag.generator, null}; targetFlags = new BlockFlag[]{BlockFlag.generator, null};
hitSize = 7; hitSize = 7;
itemCapacity = 0; itemCapacity = 10;
weapons.add(new Weapon(){{ weapons.add(new Weapon(){{
y = 0f; y = 0f;

View File

@ -48,6 +48,8 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
} }
public void updateBuildLogic(){ public void updateBuildLogic(){
if(type.buildSpeed <= 0f) return;
if(!headless){ if(!headless){
//visual activity update //visual activity update
if(lastActive != null && buildAlpha <= 0.01f){ if(lastActive != null && buildAlpha <= 0.01f){

View File

@ -416,7 +416,7 @@ public class Shaders{
@Override @Override
public void apply(){ public void apply(){
int count = data.size / 4; int count = data.size / size;
setUniformi("u_shockwave_count", count); setUniformi("u_shockwave_count", count);
if(count > 0){ if(count > 0){

View File

@ -25,7 +25,7 @@ public class GlobalConstants{
public static final Rand rand = new Rand(); public static final Rand rand = new Rand();
//non-constants that depend on state //non-constants that depend on state
private static int varTime, varTick, varWave, varWaveTime; private static int varTime, varTick, varSecond, varMinute, varWave, varWaveTime;
private ObjectIntMap<String> namesToIds = new ObjectIntMap<>(); private ObjectIntMap<String> namesToIds = new ObjectIntMap<>();
private Seq<Var> vars = new Seq<>(Var.class); private Seq<Var> vars = new Seq<>(Var.class);
@ -42,6 +42,8 @@ public class GlobalConstants{
//time //time
varTime = put("@time", 0); varTime = put("@time", 0);
varTick = put("@tick", 0); varTick = put("@tick", 0);
varSecond = put("@second", 0);
varMinute = put("@minute", 0);
varWave = put("@waveNumber", 0); varWave = put("@waveNumber", 0);
varWaveTime = put("@waveTime", 0); varWaveTime = put("@waveTime", 0);
@ -120,6 +122,10 @@ public class GlobalConstants{
vars.items[varTime].numval = state.tick / 60.0 * 1000.0; vars.items[varTime].numval = state.tick / 60.0 * 1000.0;
vars.items[varTick].numval = state.tick; vars.items[varTick].numval = state.tick;
//shorthands for seconds/minutes spent in save
vars.items[varSecond].numval = state.tick / 60f;
vars.items[varMinute].numval = state.tick / 60f / 60f;
//wave state //wave state
vars.items[varWave].numval = state.wave; vars.items[varWave].numval = state.wave;
vars.items[varWaveTime].numval = state.wavetime / 60f; vars.items[varWaveTime].numval = state.wavetime / 60f;

View File

@ -6,7 +6,7 @@ import mindustry.*;
import mindustry.ctype.*; import mindustry.ctype.*;
public class PayloadSeq{ public class PayloadSeq{
private ObjectIntMap<UnlockableContent> blocks = new ObjectIntMap<>(); private ObjectIntMap<UnlockableContent> payloads = new ObjectIntMap<>();
private int total; private int total;
public boolean isEmpty(){ public boolean isEmpty(){
@ -26,7 +26,7 @@ public class PayloadSeq{
} }
public void add(UnlockableContent block, int amount){ public void add(UnlockableContent block, int amount){
blocks.increment(block, amount); payloads.increment(block, amount);
total += amount; total += amount;
} }
@ -43,12 +43,12 @@ public class PayloadSeq{
} }
public void clear(){ public void clear(){
blocks.clear(); payloads.clear();
total = 0; total = 0;
} }
public int get(UnlockableContent block){ public int get(UnlockableContent block){
return blocks.get(block); return payloads.get(block);
} }
public boolean contains(Seq<PayloadStack> stacks){ public boolean contains(Seq<PayloadStack> stacks){
@ -70,8 +70,8 @@ public class PayloadSeq{
public void write(Writes write){ public void write(Writes write){
//IMPORTANT NOTICE: size is negated here because I changed the format of this class at some point //IMPORTANT NOTICE: size is negated here because I changed the format of this class at some point
//negated = new format //negated = new format
write.s(-blocks.size); write.s(-payloads.size);
for(var entry : blocks.entries()){ for(var entry : payloads.entries()){
write.b(entry.key.getContentType().ordinal()); write.b(entry.key.getContentType().ordinal());
write.s(entry.key.id); write.s(entry.key.id);
write.i(entry.value); write.i(entry.value);
@ -80,7 +80,7 @@ public class PayloadSeq{
public void read(Reads read){ public void read(Reads read){
total = 0; total = 0;
blocks.clear(); payloads.clear();
short amount = read.s(); short amount = read.s();
if(amount >= 0){ if(amount >= 0){
//old format, block only - can safely ignore, really //old format, block only - can safely ignore, really