mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 04:09:07 +07:00
Unit prefRotation / Class unification (monos will vanish)
This commit is contained in:
parent
84c4e0d74c
commit
ccfc1f57cc
1
annotations/src/main/resources/revisions/block/3.json
Normal file
1
annotations/src/main/resources/revisions/block/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/corvus/3.json
Normal file
1
annotations/src/main/resources/revisions/corvus/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/flare/3.json
Normal file
1
annotations/src/main/resources/revisions/flare/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/mace/3.json
Normal file
1
annotations/src/main/resources/revisions/mace/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:baseRotation,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/oct/2.json
Normal file
1
annotations/src/main/resources/revisions/oct/2.json
Normal file
@ -0,0 +1 @@
|
||||
{version:2,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:payloads,type:arc.struct.Seq<mindustry.world.blocks.payloads.Payload>},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/risso/3.json
Normal file
1
annotations/src/main/resources/revisions/risso/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
1
annotations/src/main/resources/revisions/spiroct/3.json
Normal file
1
annotations/src/main/resources/revisions/spiroct/3.json
Normal file
@ -0,0 +1 @@
|
||||
{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue<mindustry.entities.units.BuildPlan>},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq<mindustry.entities.units.StatusEntry>},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]}
|
BIN
core/assets/sounds/minebeam.ogg
Normal file
BIN
core/assets/sounds/minebeam.ogg
Normal file
Binary file not shown.
Binary file not shown.
@ -104,9 +104,7 @@ public class LogicAI extends AIController{
|
||||
|
||||
//look where moving if there's nothing to aim at
|
||||
if(!shoot){
|
||||
if(unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
unit.lookAt(unit.prefRotation());
|
||||
}else if(unit.hasWeapons()){ //if there is, look at the object
|
||||
unit.lookAt(unit.mounts[0].aimX, unit.mounts[0].aimY);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Mechc.class}) UnitType mace, dagger, crawler, fortress, scepter, reign;
|
||||
|
||||
//mech + builder + miner
|
||||
public static @EntityDef({Unitc.class, Mechc.class, Builderc.class, Minerc.class}) UnitType nova, pulsar, quasar;
|
||||
public static @EntityDef({Unitc.class, Mechc.class, Builderc.class}) UnitType nova, pulsar, quasar;
|
||||
|
||||
//mech
|
||||
public static @EntityDef({Unitc.class, Mechc.class}) UnitType vela;
|
||||
@ -33,16 +33,13 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Legsc.class, Builderc.class}) UnitType spiroct, arkyid, toxopid;
|
||||
|
||||
//air (no special traits)
|
||||
public static @EntityDef({Unitc.class}) UnitType flare, eclipse, horizon, zenith, antumbra;
|
||||
|
||||
//air + mining
|
||||
public static @EntityDef({Unitc.class, Minerc.class}) UnitType mono;
|
||||
public static @EntityDef({Unitc.class}) UnitType flare, eclipse, horizon, zenith, antumbra, mono;
|
||||
|
||||
//air + building + mining
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType poly;
|
||||
public static @EntityDef({Unitc.class, Builderc.class}) UnitType poly;
|
||||
|
||||
//air + building + mining + payload
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class, Payloadc.class}) UnitType mega;
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class}) UnitType mega;
|
||||
|
||||
//air + building + payload
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class}) UnitType quad;
|
||||
@ -51,7 +48,7 @@ public class UnitTypes implements ContentList{
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class, AmmoDistributec.class}) UnitType oct;
|
||||
|
||||
//air + building + mining
|
||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
||||
public static @EntityDef({Unitc.class, Builderc.class,}) UnitType alpha, beta, gamma;
|
||||
|
||||
//water
|
||||
public static @EntityDef({Unitc.class, WaterMovec.class}) UnitType risso, minke, bryde, sei, omura;
|
||||
@ -1214,7 +1211,7 @@ public class UnitTypes implements ContentList{
|
||||
reload = 30f;
|
||||
ejectEffect = Fx.none;
|
||||
recoil = 2f;
|
||||
shootSound = Sounds.pew;
|
||||
shootSound = Sounds.missile;
|
||||
shots = 1;
|
||||
velocityRnd = 0.5f;
|
||||
inaccuracy = 15f;
|
||||
@ -1230,6 +1227,7 @@ public class UnitTypes implements ContentList{
|
||||
smokeEffect = Fx.hitLaser;
|
||||
hitEffect = despawnEffect = Fx.hitLaser;
|
||||
frontColor = Color.white;
|
||||
hitSound = Sounds.none;
|
||||
|
||||
healPercent = 5.5f;
|
||||
collidesTeam = true;
|
||||
|
@ -16,8 +16,8 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
@Import float x, y, rotation;
|
||||
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
|
||||
@Import float x, y, rotation, hitSize;
|
||||
@Import UnitType type;
|
||||
|
||||
transient float mineTimer;
|
||||
@ -28,7 +28,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
}
|
||||
|
||||
public boolean offloadImmediately(){
|
||||
return isPlayer();
|
||||
return this.<Unit>self().isPlayer();
|
||||
}
|
||||
|
||||
boolean mining(){
|
||||
@ -87,13 +87,17 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
mineTimer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(!headless){
|
||||
loops.play(type.mineSound, this, type.mineSoundVolume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(!mining()) return;
|
||||
float focusLen = hitSize() / 2f + Mathf.absin(Time.time(), 1.1f, 0.5f);
|
||||
float focusLen = hitSize / 2f + Mathf.absin(Time.time(), 1.1f, 0.5f);
|
||||
float swingScl = 12f, swingMag = tilesize / 8f;
|
||||
float flashScl = 0.3f;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import mindustry.world.blocks.payloads.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component(base = true)
|
||||
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Commanderc, Displayable, Senseable, Ranged{
|
||||
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Commanderc, Displayable, Senseable, Ranged, Minerc{
|
||||
|
||||
@Import boolean hovering, dead;
|
||||
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health, ammo, minFormationSpeed;
|
||||
@ -88,11 +88,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
public float prefRotation(){
|
||||
if(this instanceof Builderc builder && builder.activelyBuilding()){
|
||||
return angleTo(builder.buildPlan());
|
||||
}else if(this instanceof Minerc miner && miner.mineTile() != null){
|
||||
return angleTo(miner.mineTile());
|
||||
}else{
|
||||
}else if(mineTile() != null){
|
||||
return angleTo(mineTile());
|
||||
}else if(moving()){
|
||||
return vel().angle();
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,9 +65,7 @@ public class AIController implements UnitController{
|
||||
if(unit.isFlying()){
|
||||
unit.wobble();
|
||||
|
||||
if(unit.moving()){
|
||||
unit.lookAt(unit.vel.angle());
|
||||
}
|
||||
unit.lookAt(unit.prefRotation());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,8 +482,8 @@ public class DesktopInput extends InputHandler{
|
||||
deleting = true;
|
||||
}else if(selected != null){
|
||||
//only begin shooting if there's no cursor event
|
||||
if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().plans().size == 0 || !player.builder().updateBuilding()) && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){
|
||||
if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !player.builder().activelyBuilding() && !droppingItem &&
|
||||
!tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){
|
||||
player.shooting = shouldShoot;
|
||||
}
|
||||
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
|
||||
@ -621,9 +621,7 @@ public class DesktopInput extends InputHandler{
|
||||
if(aimCursor){
|
||||
unit.lookAt(mouseAngle);
|
||||
}else{
|
||||
if(!movement.isZero()){
|
||||
unit.lookAt(unit.vel.isZero() ? movement.angle() : unit.vel.angle());
|
||||
}
|
||||
unit.lookAt(unit.prefRotation());
|
||||
}
|
||||
|
||||
if(omni){
|
||||
|
@ -931,11 +931,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
boolean canMine(Tile tile){
|
||||
return !Core.scene.hasMouse()
|
||||
&& tile.drop() != null
|
||||
&& player.miner().validMine(tile)
|
||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||
&& player.unit().acceptsItem(tile.drop())
|
||||
&& tile.block() == Blocks.air;
|
||||
&& tile.drop() != null
|
||||
&& player.miner().validMine(tile)
|
||||
&& !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null)
|
||||
&& player.unit().acceptsItem(tile.drop())
|
||||
&& tile.block() == Blocks.air;
|
||||
}
|
||||
|
||||
/** Returns the tile at the specified MOUSE coordinates. */
|
||||
@ -1042,7 +1042,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public boolean canShoot(){
|
||||
return block == null && !onConfigurable() && !isDroppingItem() && !(player.builder().updateBuilding() && player.builder().isBuilding()) &&
|
||||
return block == null && !onConfigurable() && !isDroppingItem() && !player.builder().activelyBuilding() &&
|
||||
!(player.unit() instanceof Mechc && player.unit().isFlying());
|
||||
}
|
||||
|
||||
|
@ -866,9 +866,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(aimCursor){
|
||||
unit.lookAt(mouseAngle);
|
||||
}else{
|
||||
if(unit.moving()){
|
||||
unit.lookAt(unit.vel.angle());
|
||||
}
|
||||
unit.lookAt(unit.prefRotation());
|
||||
}
|
||||
|
||||
if(payloadTarget != null && unit instanceof Payloadc pay){
|
||||
|
@ -81,6 +81,8 @@ public class UnitType extends UnlockableContent{
|
||||
public AmmoType ammoType = AmmoTypes.copper;
|
||||
public int mineTier = -1;
|
||||
public float buildSpeed = 1f, mineSpeed = 1f;
|
||||
public Sound mineSound = Sounds.minebeam;
|
||||
public float mineSoundVolume = 0.6f;
|
||||
|
||||
/** This is a VERY ROUGH estimate of unit DPS. */
|
||||
public float dpsEstimate = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user