mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-08-02 16:09:38 +07:00
Improved controls / Re-added engine sprite
This commit is contained in:
@ -487,8 +487,12 @@ public class EntityProcess extends BaseProcessor{
|
||||
}
|
||||
}
|
||||
|
||||
OrderedMap<String, String> res = new OrderedMap<>();
|
||||
res.putAll(map);
|
||||
res.orderedKeys().sort();
|
||||
|
||||
//write assigned IDs
|
||||
PropertiesUtils.store(map, idProps.writer(false), "Maps entity names to IDs. Autogenerated.");
|
||||
PropertiesUtils.store(res, idProps.writer(false), "Maps entity names to IDs. Autogenerated.");
|
||||
|
||||
//build mapping class for sync IDs
|
||||
TypeSpec.Builder idBuilder = TypeSpec.classBuilder("EntityMapping").addModifiers(Modifier.PUBLIC)
|
||||
|
@ -1,15 +1,15 @@
|
||||
#Maps entity names to IDs. Autogenerated.
|
||||
|
||||
mindustry.entities.def.PuddleComp=6
|
||||
mindustry.entities.def.BulletComp=1
|
||||
dagger=0
|
||||
phantom=11
|
||||
mindustry.entities.def.StandardEffectComp=7
|
||||
vanguard=9
|
||||
mindustry.entities.def.PlayerComp=5
|
||||
draug=10
|
||||
mindustry.entities.def.BulletComp=1
|
||||
mindustry.entities.def.DecalComp=2
|
||||
mindustry.entities.def.TileComp=8
|
||||
spirit=12
|
||||
mindustry.entities.def.FireComp=3
|
||||
mindustry.entities.def.GroundEffectComp=4
|
||||
mindustry.entities.def.GroundEffectComp=4
|
||||
mindustry.entities.def.PlayerComp=5
|
||||
mindustry.entities.def.PuddleComp=6
|
||||
mindustry.entities.def.StandardEffectComp=7
|
||||
mindustry.entities.def.TileComp=8
|
||||
phantom=11
|
||||
spirit=12
|
||||
vanguard=9
|
@ -59,8 +59,9 @@ public class UnitTypes implements ContentList{
|
||||
draug = new UnitType("draug"){{
|
||||
flying = true;
|
||||
drag = 0.05f;
|
||||
speed = 1.5f;
|
||||
speed = 2f;
|
||||
range = 50f;
|
||||
accel = 0.2f;
|
||||
health = 80;
|
||||
mineSpeed = 0.9f;
|
||||
engineSize = 1.8f;
|
||||
@ -71,7 +72,8 @@ public class UnitTypes implements ContentList{
|
||||
spirit = new UnitType("spirit"){{
|
||||
flying = true;
|
||||
drag = 0.05f;
|
||||
speed = 1.5f;
|
||||
accel = 0.2f;
|
||||
speed = 2f;
|
||||
range = 50f;
|
||||
health = 100;
|
||||
engineSize = 1.8f;
|
||||
@ -92,6 +94,8 @@ public class UnitTypes implements ContentList{
|
||||
flying = true;
|
||||
drag = 0.05f;
|
||||
mass = 2f;
|
||||
speed = 2f;
|
||||
accel = 0.1f;
|
||||
speed = 1.5f;
|
||||
range = 70f;
|
||||
itemCapacity = 70;
|
||||
|
@ -56,8 +56,8 @@ public abstract class BulletType extends Content{
|
||||
public boolean collidesTiles = true;
|
||||
/** Whether this bullet type collides with tiles that are of the same team. */
|
||||
public boolean collidesTeam = false;
|
||||
/** Whether this bullet type collides with air units. */
|
||||
public boolean collidesAir = true;
|
||||
/** Whether this bullet type collides with air/ground units. */
|
||||
public boolean collidesAir = true, collidesGround = true;
|
||||
/** Whether this bullet types collides with anything at all. */
|
||||
public boolean collides = true;
|
||||
/** Whether velocity is inherited from the shooter. */
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Units;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class FlakBulletType extends BasicBulletType{
|
||||
protected static Rect rect = new Rect();
|
||||
protected float explodeRange = 30f;
|
||||
public float explodeRange = 30f;
|
||||
|
||||
public FlakBulletType(float speed, float damage){
|
||||
super(speed, damage, "shell");
|
||||
@ -17,6 +15,7 @@ public class FlakBulletType extends BasicBulletType{
|
||||
hitEffect = Fx.flakExplosionBig;
|
||||
bulletWidth = 8f;
|
||||
bulletHeight = 10f;
|
||||
collidesGround = false;
|
||||
}
|
||||
|
||||
public FlakBulletType(){
|
||||
@ -29,8 +28,8 @@ public class FlakBulletType extends BasicBulletType{
|
||||
if(b.data() instanceof Integer) return;
|
||||
|
||||
if(b.timer(2, 6)){
|
||||
Units.nearbyEnemies(b.team(), rect.setSize(explodeRange * 2f).setCenter(b.x(), b.y()), unit -> {
|
||||
if(b.data() instanceof Float) return;
|
||||
Units.nearbyEnemies(b.team(), Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x(), b.y()), unit -> {
|
||||
if(b.data() instanceof Float || (unit.isFlying() && !collidesAir) || (unit.isGrounded() && !collidesGround)) return;
|
||||
|
||||
if(unit.dst(b) < explodeRange){
|
||||
b.data(0);
|
||||
|
@ -59,7 +59,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
@Replace
|
||||
@Override
|
||||
public boolean collides(Hitboxc other){
|
||||
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team()) && !(other instanceof Flyingc && ((Flyingc)other).isFlying() && !type.collidesAir);
|
||||
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team())
|
||||
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)));
|
||||
}
|
||||
|
||||
@MethodPriority(100)
|
||||
|
@ -12,7 +12,7 @@ import static mindustry.Vars.net;
|
||||
|
||||
@Component
|
||||
abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
@Import float x, y;
|
||||
@Import float x, y, drag;
|
||||
@Import Vec2 vel;
|
||||
|
||||
float elevation;
|
||||
@ -31,11 +31,24 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
return isGrounded();
|
||||
}
|
||||
|
||||
void wobble(){
|
||||
x += Mathf.sin(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
|
||||
y += Mathf.cos(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
|
||||
}
|
||||
|
||||
void moveAt(Vec2 vector){
|
||||
moveAt(vector, 1f);
|
||||
}
|
||||
|
||||
void moveAt(Vec2 vector, float acceleration){
|
||||
Vec2 t = Tmp.v3.set(vector).scl(floorSpeedMultiplier()); //target vector
|
||||
float mag = Tmp.v3.len();
|
||||
vel.x = Mathf.approach(vel.x, t.x, mag);
|
||||
vel.y = Mathf.approach(vel.y, t.y, mag);
|
||||
Tmp.v1.set(t).sub(vel).limit(acceleration * vector.len()); //delta vector
|
||||
vel.add(Tmp.v1);
|
||||
|
||||
//float mag = Tmp.v3.len() * acceleration;
|
||||
//vel.lerp(t, Tmp.v3.len() * acceleration);
|
||||
//vel.x = Mathf.approach(vel.x, t.x, mag);
|
||||
//vel.y = Mathf.approach(vel.y, t.y, mag);
|
||||
}
|
||||
|
||||
float floorSpeedMultiplier(){
|
||||
@ -47,6 +60,10 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
public void update(){
|
||||
Floor floor = floorOn();
|
||||
|
||||
if(isFlying() && !net.client()){
|
||||
wobble();
|
||||
}
|
||||
|
||||
if(isGrounded() && floor.isLiquid){
|
||||
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){
|
||||
floor.walkEffect.at(x, y, 0, floor.color);
|
||||
|
@ -144,6 +144,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
type.drawEngine(this);
|
||||
type.drawBody(this);
|
||||
type.drawWeapons(this);
|
||||
if(type.drawCell) type.drawCell(this);
|
||||
|
@ -28,6 +28,7 @@ import static mindustry.Vars.*;
|
||||
import static mindustry.input.PlaceMode.*;
|
||||
|
||||
public class DesktopInput extends InputHandler{
|
||||
private Vec2 movement = new Vec2();
|
||||
/** Current cursor type. */
|
||||
private Cursor cursorType = SystemCursor.arrow;
|
||||
/** Position where the player started dragging a line. */
|
||||
@ -501,15 +502,23 @@ public class DesktopInput extends InputHandler{
|
||||
float xa = Core.input.axis(Binding.move_x);
|
||||
float ya = Core.input.axis(Binding.move_y);
|
||||
|
||||
Vec2 movement = Tmp.v1.set(speed * xa, speed * ya).limit(speed);
|
||||
movement.set(xa, ya).nor().scl(speed);
|
||||
float mouseAngle = Angles.mouseAngle(unit.x(), unit.y());
|
||||
boolean aimCursor = omni && isShooting && unit.type().hasWeapons();
|
||||
|
||||
if(aimCursor){
|
||||
unit.lookAt(mouseAngle);
|
||||
}else{
|
||||
if(!unit.vel().isZero(0.01f)) unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
|
||||
if(omni){
|
||||
unit.moveAt(movement);
|
||||
unit.lookAt(Angles.mouseAngle(unit.x(), unit.y()));
|
||||
unit.moveAt(movement, unit.type().accel);
|
||||
}else{
|
||||
if(!unit.vel().isZero(0.01f)) unit.rotation(unit.vel().angle());
|
||||
unit.moveAt(Tmp.v2.trns(unit.rotation(), movement.len()));
|
||||
if(!movement.isZero()) unit.vel().rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta());
|
||||
unit.moveAt(Tmp.v2.trns(unit.rotation(), movement.len()), unit.type().accel);
|
||||
if(!movement.isZero()){
|
||||
unit.vel().rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta());
|
||||
}
|
||||
}
|
||||
|
||||
unit.aim(Core.input.mouseWorld());
|
||||
|
@ -27,8 +27,8 @@ public class UnitType extends UnlockableContent{
|
||||
public @NonNull Prov<? extends UnitController> defaultController = AIController::new;
|
||||
public @NonNull Prov<? extends Unitc> constructor;
|
||||
public boolean flying;
|
||||
public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 10f, baseRotateSpeed = 10f;
|
||||
public float drag = 0.3f, mass = 1f, accel = 0.1f;
|
||||
public float speed = 1.1f, boostSpeed = 0.75f, rotateSpeed = 6f, baseRotateSpeed = 10f;
|
||||
public float drag = 0.3f, mass = 1f, accel = 0.9f;
|
||||
public float health = 200f, range = -1;
|
||||
public boolean targetAir = false, targetGround = false;
|
||||
public boolean faceTarget = true, isCounted = true;
|
||||
@ -37,7 +37,7 @@ public class UnitType extends UnlockableContent{
|
||||
public int drillTier = -1;
|
||||
public float buildSpeed = 1f, mineSpeed = 1f;
|
||||
|
||||
public Color engineColor = Pal.boostTo;
|
||||
public Color engineColor = Pal.engine;
|
||||
public float engineOffset = 5f, engineSize = 2.5f;
|
||||
|
||||
public float hitsize = 6f;
|
||||
@ -46,8 +46,6 @@ public class UnitType extends UnlockableContent{
|
||||
public Color lightColor = Pal.powerLight;
|
||||
public boolean drawCell = true, drawItems = true;
|
||||
|
||||
//public ObjectSet<Item> mineables = new ObjectSet<>();
|
||||
|
||||
public ObjectSet<StatusEffect> immunities = new ObjectSet<>();
|
||||
public Sound deathSound = Sounds.bang;
|
||||
|
||||
@ -75,6 +73,10 @@ public class UnitType extends UnlockableContent{
|
||||
return unit;
|
||||
}
|
||||
|
||||
public boolean hasWeapons(){
|
||||
return weapons.size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayUnit(table, this);
|
||||
@ -156,6 +158,24 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
public void drawEngine(Unitc unit){
|
||||
if(!unit.isFlying()) return;
|
||||
|
||||
Draw.color(engineColor);
|
||||
Fill.circle(
|
||||
unit.x() + Angles.trnsx(unit.rotation() + 180, engineOffset),
|
||||
unit.y() + Angles.trnsy(unit.rotation() + 180, engineOffset),
|
||||
(engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f) * unit.elevation())
|
||||
);
|
||||
Draw.color(Color.white);
|
||||
Fill.circle(
|
||||
unit.x() + Angles.trnsx(unit.rotation() + 180, engineOffset - 1f),
|
||||
unit.y() + Angles.trnsy(unit.rotation() + 180, engineOffset - 1f),
|
||||
(engineSize + Mathf.absin(Time.time(), 2f, engineSize / 4f)) / 2f * unit.elevation()
|
||||
);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public void drawWeapons(Unitc unit){
|
||||
applyColor(unit);
|
||||
|
||||
|
Reference in New Issue
Block a user