mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 15:02:03 -08:00
Cleanup
This commit is contained in:
parent
504334999d
commit
9e0b29b3dd
11 changed files with 43 additions and 31 deletions
|
|
@ -473,16 +473,8 @@ requirement.wave = Reach Wave {0} in {1}
|
|||
requirement.core = Destroy Enemy Core in {0}
|
||||
requirement.research = Research {0}
|
||||
requirement.capture = Capture {0}
|
||||
resume = Resume Zone:\n[lightgray]{0}
|
||||
bestwave = [lightgray]Best Wave: {0}
|
||||
#TODO fix/remove this
|
||||
launch = < LAUNCH >
|
||||
launch.text = Launch
|
||||
launch.title = Launch Successful
|
||||
launch.next = [lightgray]next opportunity at wave {0}
|
||||
launch.unable2 = [scarlet]Unable to LAUNCH.[]
|
||||
launch.confirm = This will launch all resources in your core.\nYou will not be able to return to this base.
|
||||
launch.skip.confirm = If you skip now, you will not be able to launch until later waves.
|
||||
campaign.multiplayer = While playing multiplayer in campaign, you can only research using items from [accent]your[] sectors, [scarlet]not[] the host's sector that you are on right now.\n\nTo get items to [accent]your[] sectors in multiplayer, use a [accent]launch pad[].
|
||||
uncover = Uncover
|
||||
configure = Configure Loadout
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ const SaveLoadEvent = Packages.mindustry.game.EventType.SaveLoadEvent
|
|||
const MapPublishEvent = Packages.mindustry.game.EventType.MapPublishEvent
|
||||
const MapMakeEvent = Packages.mindustry.game.EventType.MapMakeEvent
|
||||
const ResizeEvent = Packages.mindustry.game.EventType.ResizeEvent
|
||||
const LaunchEvent = Packages.mindustry.game.EventType.LaunchEvent
|
||||
const LoseEvent = Packages.mindustry.game.EventType.LoseEvent
|
||||
const WinEvent = Packages.mindustry.game.EventType.WinEvent
|
||||
const Trigger = Packages.mindustry.game.EventType.Trigger
|
||||
|
|
|
|||
|
|
@ -10,10 +10,16 @@ import mindustry.async.PhysicsProcess.PhysicsWorld.*;
|
|||
import mindustry.gen.*;
|
||||
|
||||
public class PhysicsProcess implements AsyncProcess{
|
||||
private static final int
|
||||
layers = 3,
|
||||
layerGround = 0,
|
||||
layerLegs = 1,
|
||||
layerFlying = 2;
|
||||
|
||||
private PhysicsWorld physics;
|
||||
private Seq<PhysicRef> refs = new Seq<>(false);
|
||||
//currently only enabled for units
|
||||
private EntityGroup<? extends Physicsc> group = Groups.unit;
|
||||
private EntityGroup<Unit> group = Groups.unit;
|
||||
|
||||
@Override
|
||||
public void begin(){
|
||||
|
|
@ -29,9 +35,8 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
return false;
|
||||
});
|
||||
|
||||
//find entities without bodies and assign them
|
||||
for(Physicsc entity : group){
|
||||
boolean grounded = entity.isGrounded();
|
||||
//find Unit without bodies and assign them
|
||||
for(Unit entity : group){
|
||||
|
||||
if(entity.physref() == null){
|
||||
PhysicsBody body = new PhysicsBody();
|
||||
|
|
@ -39,7 +44,6 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
body.y = entity.y();
|
||||
body.mass = entity.mass();
|
||||
body.radius = entity.hitSize() / 2f;
|
||||
body.flag = grounded ? 1 : 0;
|
||||
|
||||
PhysicRef ref = new PhysicRef(entity, body);
|
||||
refs.add(ref);
|
||||
|
|
@ -52,7 +56,9 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
//save last position
|
||||
PhysicRef ref = entity.physref();
|
||||
|
||||
ref.body.flag = grounded ? 1 : 0;
|
||||
ref.body.layer =
|
||||
entity.type().allowLegStep ? layerLegs :
|
||||
entity.isGrounded() ? layerGround : layerFlying;
|
||||
ref.x = entity.x();
|
||||
ref.y = entity.y();
|
||||
}
|
||||
|
|
@ -116,13 +122,16 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
//how much to soften movement by
|
||||
private static final float scl = 1.25f;
|
||||
|
||||
private final QuadTree<PhysicsBody> tree;
|
||||
private final QuadTree<PhysicsBody>[] trees = new QuadTree[layers];
|
||||
private final Seq<PhysicsBody> bodies = new Seq<>(false, 16, PhysicsBody.class);
|
||||
private final Seq<PhysicsBody> seq = new Seq<>(PhysicsBody.class);
|
||||
private final Rect rect = new Rect();
|
||||
private final Vec2 vec = new Vec2();
|
||||
|
||||
public PhysicsWorld(Rect bounds){
|
||||
tree = new QuadTree<>(new Rect(bounds));
|
||||
for(int i = 0; i < layers; i++){
|
||||
trees[i] = new QuadTree<>(new Rect(bounds));
|
||||
}
|
||||
}
|
||||
|
||||
public void add(PhysicsBody body){
|
||||
|
|
@ -134,18 +143,27 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
}
|
||||
|
||||
public void update(){
|
||||
tree.clear();
|
||||
for(int i = 0; i < layers; i++){
|
||||
trees[i].clear();
|
||||
}
|
||||
|
||||
for(int i = 0; i < bodies.size; i++){
|
||||
PhysicsBody body = bodies.items[i];
|
||||
body.collided = false;
|
||||
tree.insert(body);
|
||||
trees[body.layer].insert(body);
|
||||
}
|
||||
|
||||
for(int i = 0; i < bodies.size; i++){
|
||||
PhysicsBody body = bodies.items[i];
|
||||
body.hitbox(rect);
|
||||
tree.intersect(rect, other -> {
|
||||
if(other.flag != body.flag || other == body || other.collided) return;
|
||||
|
||||
seq.size = 0;
|
||||
trees[body.layer].intersect(rect, seq);
|
||||
|
||||
for(int j = 0; j < seq.size; j++){
|
||||
PhysicsBody other = seq.items[j];
|
||||
|
||||
if(other == body || other.collided) continue;
|
||||
|
||||
float rs = body.radius + other.radius;
|
||||
float dst = Mathf.dst(body.x, body.y, other.x, other.y);
|
||||
|
|
@ -160,14 +178,14 @@ public class PhysicsProcess implements AsyncProcess{
|
|||
other.x -= vec.x * m2 / scl;
|
||||
other.y -= vec.y * m2 / scl;
|
||||
}
|
||||
});
|
||||
}
|
||||
body.collided = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PhysicsBody implements QuadTreeObject{
|
||||
public float x, y, radius, mass;
|
||||
public int flag = 0;
|
||||
public int layer = 0;
|
||||
public boolean collided = false;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -463,6 +463,7 @@ public class UnitTypes implements ContentList{
|
|||
visualElevation = 0.2f;
|
||||
allowLegStep = true;
|
||||
ammoType = AmmoTypes.powerHigh;
|
||||
groundLayer = Layer.legUnit;
|
||||
|
||||
speed = 0.3f;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class GameState{
|
|||
/** Wave countdown in ticks. */
|
||||
public float wavetime;
|
||||
/** Whether the game is in game over state. */
|
||||
public boolean gameOver = false, launched = false, serverPaused = false, wasTimeout;
|
||||
public boolean gameOver = false, serverPaused = false, wasTimeout;
|
||||
/** Map that is currently being played on. */
|
||||
public @NonNull Map map = emptyMap;
|
||||
/** The current game rules. */
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@ public class Lightning{
|
|||
|
||||
/** Create a lighting branch at a location. Use Team.derelict to damage everyone. */
|
||||
public static void create(Team team, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
createLightingInternal(null, lastSeed++, team, color, damage, x, y, targetAngle, length);
|
||||
createLightningInternal(null, lastSeed++, team, color, damage, x, y, targetAngle, length);
|
||||
}
|
||||
|
||||
/** Create a lighting branch at a location. Uses bullet parameters. */
|
||||
public static void create(Bullet bullet, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
createLightingInternal(bullet, lastSeed++, bullet.team, color, damage, x, y, targetAngle, length);
|
||||
createLightningInternal(bullet, lastSeed++, bullet.team, color, damage, x, y, targetAngle, length);
|
||||
}
|
||||
|
||||
//TODO remote method
|
||||
//@Remote(called = Loc.server, unreliable = true)
|
||||
private static void createLightingInternal(Bullet hitter, int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){
|
||||
private static void createLightningInternal(Bullet hitter, int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){
|
||||
random.setSeed(seed);
|
||||
hit.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public class Stats{
|
|||
/** Friendly buildings destroyed. */
|
||||
public int buildingsDestroyed;
|
||||
|
||||
//TODO fix
|
||||
public RankResult calculateRank(Sector zone, boolean launched){
|
||||
float score = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class Sector{
|
|||
|
||||
public boolean isBeingPlayed(){
|
||||
//after the launch dialog, a sector is no longer considered being played
|
||||
return Vars.state.isGame() && Vars.state.rules.sector == this && !Vars.state.launched && !Vars.state.gameOver;
|
||||
return Vars.state.isGame() && Vars.state.rules.sector == this && !Vars.state.gameOver;
|
||||
}
|
||||
|
||||
public boolean isCaptured(){
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class GameOverDialog extends BaseDialog{
|
|||
}
|
||||
|
||||
void rebuild(){
|
||||
title.setText(state.launched ? "@launch.title" : "@gameover");
|
||||
title.setText("@gameover");
|
||||
buttons.clear();
|
||||
cont.clear();
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ public class GameOverDialog extends BaseDialog{
|
|||
}
|
||||
|
||||
if(state.hasSector()){
|
||||
RankResult result = state.stats.calculateRank(state.getSector(), state.launched);
|
||||
RankResult result = state.stats.calculateRank(state.getSector(), true);
|
||||
t.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
|
||||
t.row();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ public class ResearchDialog extends BaseDialog{
|
|||
Core.app.post(() -> {
|
||||
if(net.client()){
|
||||
//TODO make this not display every time
|
||||
//TODO rework this in the future
|
||||
ui.showInfo("campaign.multiplayer");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||
SStat.attacksWon.add();
|
||||
}
|
||||
|
||||
RankResult result = state.stats.calculateRank(state.getSector(), state.launched);
|
||||
RankResult result = state.stats.calculateRank(state.getSector(), true);
|
||||
if(result.rank == Rank.S) earnSRank.complete();
|
||||
if(result.rank == Rank.SS) earnSSRank.complete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue