Skip to content

Commit

Permalink
Parry effect
Browse files Browse the repository at this point in the history
  • Loading branch information
GlennFolker committed Apr 15, 2024
1 parent 182249f commit 9f5610f
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ modArtifact = Confictura
# EntityAnno version, for integrating syntax-downgrader and entity annotation processor.
# The exact version you need should be looked up on the project's `README.md`
# (see https://github.com/GlennFolker/EntityAnno?tab=readme-ov-file#version-compatibility).
entVersion = v146.0.5
entVersion = v146.0.6
# glTFrenzy version, for loading 3D models.
glTFrenzyVersion = c454246ef2590cba33e58d7ef9b02de3556a4aec
# Set to `true` if the mod is compiled against Mindustry bleeding-edge build.
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Dive into the past of a trauma-driven uprising.",
"version": "v0.2.0",
"minGameVersion": "147",
"author": "GlennFolker",
"author": "GlFolker",
"java": true,
"pregenerated": true,
"main": "confictura.ConficturaMod",
Expand Down
40 changes: 39 additions & 1 deletion src/confictura/content/CFx.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import arc.math.*;
import arc.math.geom.*;
import arc.util.pooling.*;
import confictura.graphics.*;
import confictura.entities.effect.*;
import confictura.entities.units.skill.ParrySkill.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
Expand All @@ -29,6 +30,8 @@ public final class CFx{
private static final Vec2 v1 = new Vec2(), v2 = new Vec2();
private static final Color c1 = new Color();

private static int index = 0;

public static final Effect

eneraphyteSteam = new Effect(120f, e -> {
Expand Down Expand Up @@ -147,6 +150,41 @@ public void remove(){
randLenVectors(e.id, 6, 64f, e.rotation, 30f, (x, y) ->
lineAngle(e.x + x * e.fin(pow3Out), e.y + y * e.fin(pow3Out), Mathf.angle(x, y), e.fout(pow2Out) * 8f)
);
}),

parry = new Effect(36f, e -> {
if(!(e.data instanceof FxData fx && fx.data instanceof ParryData data)) return;
float rot = 180f * Mathf.sign(!data.clockwise) * e.fin(pow3Out);

index = 0;
randLenVectors(e.id, 8, data.unit.hitSize + data.offset, 4f, (x, y) -> {
rand.setSeed(e.id + index++);

stroke((1f + rand.range(0.5f)) * e.fout());
color(monolithMid, monolithLight, monolithLighter, rand.random(0f, 1f));
arc(e.x, e.y, Mathf.dst(x, y), 0.2f + rand.range(0.1f), rand.random(360f) + rot + rand.range(45f));
});

z(Layer.flyingUnitLow);
blend(Blending.additive);
color();

for(int i = 0, len = Math.max(Mathf.roundPositive(Angles.angleDist(data.fromRot, data.toRot) / 45f), 2); i < len; i++){
float f = i / (len - 1f);
alpha((i + 1f) / len * 0.5f);

e.scaled(24f * f, s -> {
mixcol(c1.set(monolithDarker).lerp(monolithLighter, f), Color.black, s.fin(pow2In));
Draw.rect(data.unit.type.fullIcon, e.x, e.y, Mathf.slerp(data.fromRot, data.toRot, f) - 90f);
});
}

alpha(e.fin(pow2Out));
e.scaled(24f, s -> {
mixcol(monolithLighter, Color.black, s.fin(pow2In));
Draw.rect(data.unit.type.fullIcon, e.x, e.y, Mathf.slerp(data.fromRot, data.toRot, s.fin(pow3Out)) - 90f);
});
blend();
});

private CFx(){
Expand Down
2 changes: 1 addition & 1 deletion src/confictura/content/CUnitTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void load(){
rotateSpeed = 2.4f;
baseRotateSpeed = 3.6f;
mechStride = 6f;
hitSize = 32f / 4f;
hitSize = 35f / 4f;

canBoost = true;
outlineColor = monolithOutline;
Expand Down
1 change: 1 addition & 0 deletions src/confictura/entities/comp/ParryComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@EntityDef(value = Parryc.class, serialize = false, pooled = true)
abstract class ParryComp implements Drawc, Rotc, Timedc{
ParrySkill skill;
boolean clockwise;

@Override
public void update(){
Expand Down
9 changes: 9 additions & 0 deletions src/confictura/entities/comp/SkillComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import mindustry.gen.*;
import mindustry.type.*;

import static confictura.util.StructUtils.*;

@EntityComponent
abstract class SkillComp implements Unitc{
/** Compared by-reference to see if the unit hasn't setup its skills. */
Expand Down Expand Up @@ -47,6 +49,13 @@ public void remove(){
}
}

@Insert(value = "update()", block = Statusc.class, after = false)
void updateSkillStats(){
var stat = applyDynamicStatus();
stat.speedMultiplier = reducef(skills, 1f, (skill, out) -> out * skill.speedMultiplier());
stat.reloadMultiplier = reducef(skills, 1f, (skill, out) -> out * skill.reloadMultiplier());
}

@Override
public void update(){
for(var skill : skills){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package confictura.graphics;
package confictura.entities.effect;

import arc.func.*;
import arc.graphics.*;
Expand Down
179 changes: 179 additions & 0 deletions src/confictura/entities/effect/FxData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package confictura.entities.effect;

import arc.math.geom.*;
import arc.util.io.*;
import confictura.gen.*;
import ent.anno.Annotations.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;

@EntityPoint
public class FxData implements Posc, Rotc{
public Posc delegate;
public Object data;

public int id = EntityGroup.nextId();

protected FxData(){}

public static FxData create(){
return new FxData();
}

@Override
public Floor floorOn(){
return delegate.floorOn();
}

@Override
public Building buildOn(){
return delegate.buildOn();
}

@Override
public boolean onSolid(){
return delegate.onSolid();
}

@Override
public float getX(){
return delegate.getX();
}

@Override
public float getY(){
return delegate.getY();
}

@Override
public float x(){
return delegate.getX();
}

@Override
public float y(){
return delegate.getY();
}

@Override
public float rotation(){
return delegate instanceof Rotc rot ? rot.rotation() : 0f;
}

@Override
public int tileX(){
return delegate.tileX();
}

@Override
public int tileY(){
return delegate.tileY();
}

@Override
public Block blockOn(){
return delegate.blockOn();
}

@Override
public Tile tileOn(){
return delegate.tileOn();
}

// These setters do nothing; why would anybody want to modify state from effects?
@Override
public void set(Position position){}

@Override
public void set(float x, float y){}

@Override
public void trns(Position position){}

@Override
public void trns(float x, float y){}

@Override
public void x(float x){}

@Override
public void y(float y){}

@Override
public void rotation(float rotation){}

@Override
@SuppressWarnings("unchecked")
public <T extends Entityc> T self(){
return (T)this;
}

@Override
@SuppressWarnings("unchecked")
public <T> T as(){
return (T)this;
}

@Override
public boolean isAdded(){
return delegate.isAdded();
}

@Override
public boolean isLocal(){
return delegate.isLocal();
}

@Override
public boolean isNull(){
return delegate.isNull();
}

@Override
public boolean isRemote(){
return delegate.isRemote();
}

@Override
public boolean serialize(){
return false;
}

@Override
public int classId(){
return EntityRegistry.getID(FxData.class);
}

@Override
public int id(){
return id;
}

@Override
public void id(int id){
this.id = id;
}

@Override
public void add(){}

@Override
public void remove(){}

@Override
public void update(){}

@Override
public void write(Writes writes){}

@Override
public void read(Reads reads){}

@Override
public void afterRead(){}

@Override
public void afterAllRead(){}
}
8 changes: 8 additions & 0 deletions src/confictura/entities/units/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public void updatePassive(){}

public void draw(){}

public float speedMultiplier(){
return 1f;
}

public float reloadMultiplier(){
return 1f;
}

@Override
public boolean canTap(Player player, float x, float y){
return reload >= reloadTime;
Expand Down
Loading

0 comments on commit 9f5610f

Please sign in to comment.