Skip to content

Commit bf2fae2

Browse files
committed
sleeper agent
1 parent 0b730de commit bf2fae2

File tree

10 files changed

+114
-13
lines changed

10 files changed

+114
-13
lines changed

assets/sprites/units/agent-base.png

622 Bytes
Loading

assets/sprites/units/agent-cell.png

379 Bytes
Loading

assets/sprites/units/agent-leg.png

570 Bytes
Loading

assets/sprites/units/agent.png

1.02 KB
Loading
677 Bytes
Loading

src/overblocks/content/OBUnitTypes.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,15 @@
1616

1717
import static arc.graphics.g2d.Draw.*;
1818
import static arc.graphics.g2d.Lines.*;
19-
import static ent.anno.Annotations.EntityDef;
2019

2120
@SuppressWarnings("unused")
2221
public class OBUnitTypes{
23-
//vanilla entities units
2422

25-
//relayer tree
26-
public static @EntityDef({Unitc.class, Mechc.class, Dodgec.class}) UnitType relayer, announcer, agent, spy, undercover;
27-
28-
//mr. boomerang unit?
29-
30-
//radial damage unit?
31-
32-
//steam-based unit?
23+
public static UnitType relayer, announcer, agent, spy, undercover;
3324

3425
public static void load(){
3526

27+
//region patrol
3628
relayer = new OBUnitType("relayer", DodgeMechUnit.class){{
3729
dodge = 0.5f;
3830
speed = 0.5f;
@@ -135,5 +127,40 @@ public static void load(){
135127
}};
136128
}});
137129
}};
130+
131+
/*agent = new OBUnitType("agent", InvisibleMechUnit.class){{
132+
speed = 0.43f;
133+
hitSize = 13f;
134+
rotateSpeed = 3f;
135+
targetAir = false;
136+
health = 900;
137+
armor = 9f;
138+
mechFrontSway = 0.55f;
139+
ammoType = new ItemAmmoType(Items.graphite);
140+
141+
weapons.add(new Weapon(name + "-weapon"){{
142+
top = false;
143+
y = 1f;
144+
x = 9f;
145+
reload = 60f;
146+
recoil = 4f;
147+
shake = 2f;
148+
ejectEffect = Fx.casing2;
149+
shootSound = Sounds.artillery;
150+
bullet = new ArtilleryBulletType(2f, 20, "shell"){{
151+
hitEffect = Fx.blastExplosion;
152+
knockback = 0.8f;
153+
lifetime = 120f;
154+
width = height = 14f;
155+
collides = true;
156+
collidesTiles = true;
157+
splashDamageRadius = 35f;
158+
splashDamage = 80f;
159+
backColor = Pal.bulletYellowBack;
160+
frontColor = Pal.bulletYellow;
161+
}};
162+
}});
163+
}};*/
164+
//endregion
138165
}
139166
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package overblocks.entities;
2+
3+
import ent.anno.Annotations.*;
4+
import mindustry.gen.*;
5+
import overblocks.gen.*;
6+
7+
@SuppressWarnings("unused")
8+
final class EntityDefs<E>{
9+
10+
@EntityDef({Unitc.class, Mechc.class, Dodgec.class}) E dodgeMechUnit;
11+
12+
@EntityDef({Unitc.class, Mechc.class, Invisiblec.class}) E invisibleMechUnit;
13+
}

src/overblocks/entities/DodgeComp.java renamed to src/overblocks/entities/comp/DodgeComp.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
package overblocks.entities;
1+
package overblocks.entities.comp;
22

33
import arc.math.*;
44
import arc.util.*;
5-
import ent.anno.*;
65
import mindustry.*;
76
import mindustry.entities.*;
87
import mindustry.gen.*;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package overblocks.entities.comp;
2+
3+
import arc.math.*;
4+
import arc.util.*;
5+
import ent.anno.Annotations.*;
6+
import mindustry.game.*;
7+
import mindustry.gen.*;
8+
import mindustry.type.*;
9+
10+
@EntityComponent
11+
abstract class InvisibleComp implements Unitc{
12+
@SyncLocal @ReadOnly boolean invisible;
13+
@ReadOnly transient float disabledTime = 120f;
14+
@ReadOnly transient Interval scanInterval = new Interval(2);
15+
@SyncLocal @SyncField(true) float alphaLerp;
16+
17+
@Import UnitType type;
18+
@Import Team team;
19+
@Import float x, y, hitSize, health, maxHealth;
20+
@Import boolean isShooting;
21+
22+
@Override
23+
public void update(){
24+
if(Time.delta > 0.5) Log.info(invisible);
25+
disabledTime = Math.max(disabledTime - Time.delta, 0f);
26+
27+
if(scanInterval.get(0, 5f) && invisible){
28+
hitbox(Tmp.r1);
29+
Groups.bullet.intersect(Tmp.r1.x, Tmp.r1.y, Tmp.r1.width, Tmp.r1.height, b -> {
30+
if(b.team != team) disabledTime = 1.2f * 60;
31+
});
32+
}
33+
if(scanInterval.get(1, 30f)){
34+
float size = hitSize * 2.5f;
35+
Tmp.r1.setCentered(x, y, size * 2f);
36+
Groups.unit.intersect(Tmp.r1.x, Tmp.r1.y, Tmp.r1.width, Tmp.r1.height, u -> {
37+
if(u.team != team && Mathf.within(x, y, u.x, u.y, size)){
38+
disabledTime = 1.2f * 60;
39+
}
40+
});
41+
}
42+
43+
if(!isShooting && health > maxHealth / 2f && disabledTime <= 0f){
44+
alphaLerp = Mathf.lerpDelta(alphaLerp, 1f, 0.1f);
45+
}else{
46+
alphaLerp = Mathf.lerpDelta(alphaLerp, 0f, 0.1f);
47+
}
48+
49+
invisible = alphaLerp >= 0.5f;
50+
}
51+
52+
@Replace(10)
53+
@Override
54+
public boolean targetable(Team targeter){
55+
return !invisible && type.targetable(self(), targeter);
56+
}
57+
58+
@Replace(10)
59+
@Override
60+
public boolean hittable(){
61+
return !invisible && type.hittable(self());
62+
}
63+
}

src/overblocks/type/OBUnitType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public <T extends Unit> OBUnitType(String name, Class<T> type){
2222
if (constructor == null) throw new IllegalArgumentException("Unit entity class `" + type + "` not registered.");
2323
}
2424

25-
2625
@Override
2726
public void setStats(){
2827
super.setStats();

0 commit comments

Comments
 (0)