This commit is contained in:
Anuken
2023-06-30 22:26:43 -04:00
parent c64b6092d7
commit 129c3f446a
4 changed files with 16 additions and 2 deletions

View File

@@ -1956,6 +1956,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
case health -> {
health = (float)Mathf.clamp(value, 0, maxHealth);
healthChanged();
if(health <= 0f && !dead()){
Call.buildDestroyed(self());
}
}
case team -> {
Team team = Team.get((int)value);

View File

@@ -261,7 +261,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void setProp(LAccess prop, double value){
switch(prop){
case health -> health = (float)Mathf.clamp(value, 0, maxHealth);
case health -> {
health = (float)Mathf.clamp(value, 0, maxHealth);
if(health <= 0f && !dead){
kill();
}
}
case x -> x = World.unconv((float)value);
case y -> y = World.unconv((float)value);
case rotation -> rotation = (float)value;

View File

@@ -189,7 +189,7 @@ public class GameService{
}
});
Events.on(BlockBuildBeginEvent.class, e -> {
Events.on(BlockBuildEndEvent.class, e -> {
if(campaign() && state.rules.sector == SectorPresets.groundZero.sector && e.tile.block() == Blocks.coreNucleus){
nucleusGroundZero.complete();
}

View File

@@ -359,8 +359,14 @@ public class CoreBlock extends StorageBlock{
@Override
public void changeTeam(Team next){
if(this.team == next) return;
state.teams.unregisterCore(this);
super.changeTeam(next);
state.teams.registerCore(this);
Events.fire(new CoreChangeEvent(this));
}