More multiplayer bugfixes
This commit is contained in:
@@ -2,6 +2,7 @@ package mindustry.entities;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -15,6 +16,11 @@ public class Units{
|
||||
private static float cdist;
|
||||
private static boolean boolResult;
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitDeath(Unitc unit){
|
||||
unit.killed();
|
||||
}
|
||||
|
||||
/** @return whether a new instance of a unit of this team can be created. */
|
||||
public static boolean canCreate(Team team){
|
||||
return teamIndex.count(team) < getCap(team);
|
||||
|
||||
@@ -29,8 +29,8 @@ abstract class BlockUnitComp implements Unitc{
|
||||
}
|
||||
}
|
||||
|
||||
@Replace
|
||||
public void kill(){
|
||||
@Override
|
||||
public void killed(){
|
||||
tile.kill();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ import static mindustry.Vars.*;
|
||||
@Component
|
||||
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Displayable{
|
||||
|
||||
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize;
|
||||
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health;
|
||||
@Import boolean dead;
|
||||
|
||||
private UnitController controller;
|
||||
private UnitType type;
|
||||
@@ -191,7 +192,10 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
}
|
||||
}
|
||||
|
||||
controller.update();
|
||||
//AI only updates on the server
|
||||
if(!net.client()){
|
||||
controller.updateUnit();
|
||||
}
|
||||
|
||||
//remove units spawned by the core
|
||||
if(spawnedByCore && !isPlayer()){
|
||||
@@ -227,6 +231,9 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
@Override
|
||||
public void killed(){
|
||||
health = 0;
|
||||
dead = true;
|
||||
|
||||
float explosiveness = 2f + item().explosiveness * stack().amount;
|
||||
float flammability = item().flammability * stack().amount;
|
||||
Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame);
|
||||
@@ -241,6 +248,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
if(explosiveness > 7f && isLocal()){
|
||||
Events.fire(Trigger.suicideBomb);
|
||||
}
|
||||
|
||||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Replace
|
||||
public void kill(){
|
||||
if(dead || net.client()) return;
|
||||
|
||||
//deaths are synced; this calls killed()
|
||||
Call.onUnitDeath(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
static int sequenceNum = 0;
|
||||
|
||||
/** weapon mount array, never null */
|
||||
@ReadOnly transient WeaponMount[] mounts = {};
|
||||
@ReadOnly @SyncLocal WeaponMount[] mounts = {};
|
||||
@ReadOnly transient float range, aimX, aimY;
|
||||
@ReadOnly transient boolean isRotate;
|
||||
boolean isShooting;
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface UnitController{
|
||||
|
||||
}
|
||||
|
||||
default void update(){
|
||||
default void updateUnit(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user