Logic explosion statement
This commit is contained in:
@@ -109,7 +109,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
|
|
||||||
set(tile.drawx(), tile.drawy());
|
set(tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
if(shouldAdd && shouldUpdate()){
|
if(shouldAdd){
|
||||||
add();
|
add();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether this block is allowed to update based on team/environment */
|
/** @return whether this block is allowed to update based on team/environment */
|
||||||
public boolean shouldUpdate(){
|
public boolean allowUpdate(){
|
||||||
return team != Team.derelict && block.supportsEnv(state.rules.environment);
|
return team != Team.derelict && block.supportsEnv(state.rules.environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,7 +524,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
/** Call when this entity is updating. This wakes it up. */
|
/** Call when this entity is updating. This wakes it up. */
|
||||||
public void noSleep(){
|
public void noSleep(){
|
||||||
sleepTime = 0f;
|
sleepTime = 0f;
|
||||||
if(sleeping && shouldUpdate()){
|
if(sleeping){
|
||||||
add();
|
add();
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
sleepingEntities--;
|
sleepingEntities--;
|
||||||
@@ -1508,10 +1508,6 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
this.team = next;
|
this.team = next;
|
||||||
indexer.addIndex(tile);
|
indexer.addIndex(tile);
|
||||||
Events.fire(teamChangeEvent.set(last, self()));
|
Events.fire(teamChangeEvent.set(last, self()));
|
||||||
|
|
||||||
if(!shouldUpdate()){
|
|
||||||
remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPickup(){
|
public boolean canPickup(){
|
||||||
@@ -1783,6 +1779,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
timeScale = 1f;
|
timeScale = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!allowUpdate()){
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO unacceptable overhead?
|
//TODO unacceptable overhead?
|
||||||
if(!enabled && block.autoResetEnabled){
|
if(!enabled && block.autoResetEnabled){
|
||||||
noSleep();
|
noSleep();
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
if(build != null && build.team == player.team()){
|
if(build != null && build.team == player.team()){
|
||||||
build.drawSelect();
|
build.drawSelect();
|
||||||
if((!build.enabled && build.block.drawDisabled) || !build.shouldUpdate()){
|
if(!build.enabled && build.block.drawDisabled){
|
||||||
build.drawDisabled();
|
build.drawDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1234,7 +1234,7 @@ public class LExecutor{
|
|||||||
public static class SpawnUnitI implements LInstruction{
|
public static class SpawnUnitI implements LInstruction{
|
||||||
public int type, x, y, rotation, team, result;
|
public int type, x, y, rotation, team, result;
|
||||||
|
|
||||||
public SpawnUnitI(int type, int x, int y, int rotation, int team, boolean effect, int result){
|
public SpawnUnitI(int type, int x, int y, int rotation, int team, int result){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -1356,7 +1356,6 @@ public class LExecutor{
|
|||||||
|
|
||||||
@Remote(called = Loc.server, unreliable = true)
|
@Remote(called = Loc.server, unreliable = true)
|
||||||
public static void logicExplosion(Team team, float x, float y, float radius, float damage, boolean air, boolean ground, boolean pierce){
|
public static void logicExplosion(Team team, float x, float y, float radius, float damage, boolean air, boolean ground, boolean pierce){
|
||||||
|
|
||||||
Damage.damage(team, x, y, radius, damage, pierce, air, ground);
|
Damage.damage(team, x, y, radius, damage, pierce, air, ground);
|
||||||
if(pierce){
|
if(pierce){
|
||||||
Fx.spawnShockwave.at(x, y, World.conv(radius));
|
Fx.spawnShockwave.at(x, y, World.conv(radius));
|
||||||
|
|||||||
@@ -1191,7 +1191,6 @@ public class LStatements{
|
|||||||
@RegisterStatement("spawn")
|
@RegisterStatement("spawn")
|
||||||
public static class SpawnUnitStatement extends LStatement{
|
public static class SpawnUnitStatement extends LStatement{
|
||||||
public String type = "@dagger", x = "10", y = "10", rotation = "90", team = "@sharded", result = "result";
|
public String type = "@dagger", x = "10", y = "10", rotation = "90", team = "@sharded", result = "result";
|
||||||
public boolean effect = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
@@ -1217,10 +1216,6 @@ public class LStatements{
|
|||||||
|
|
||||||
table.add(" rot ");
|
table.add(" rot ");
|
||||||
fields(table, rotation, str -> rotation = str).left();
|
fields(table, rotation, str -> rotation = str).left();
|
||||||
|
|
||||||
//effect mostly unnecessary and looks bad
|
|
||||||
//row(table);
|
|
||||||
//table.check("effect", effect, val -> effect = val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1235,7 +1230,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new SpawnUnitI(builder.var(type), builder.var(x), builder.var(y), builder.var(rotation), builder.var(team), effect, builder.var(result));
|
return new SpawnUnitI(builder.var(type), builder.var(x), builder.var(y), builder.var(rotation), builder.var(team), builder.var(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1373,4 +1368,39 @@ public class LStatements{
|
|||||||
return new CutsceneI(action, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
|
return new CutsceneI(action, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RegisterStatement("explosion")
|
||||||
|
public static class ExplosionStatement extends LStatement{
|
||||||
|
public String team = "@crux", x = "0", y = "0", radius = "5", damage = "50", air = "true", ground = "true", pierce = "false";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Table table){
|
||||||
|
fields(table, "team", team, str -> team = str);
|
||||||
|
fields(table, "x", x, str -> x = str);
|
||||||
|
row(table);
|
||||||
|
fields(table, "y", y, str -> y = str);
|
||||||
|
fields(table, "radius", radius, str -> radius = str);
|
||||||
|
table.row();
|
||||||
|
fields(table, "damage", damage, str -> damage = str);
|
||||||
|
fields(table, "air", air, str -> air = str);
|
||||||
|
row(table);
|
||||||
|
fields(table, "ground", ground, str -> ground = str);
|
||||||
|
fields(table, "pierce", pierce, str -> pierce = str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean privileged(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color color(){
|
||||||
|
return Pal.logicWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LInstruction build(LAssembler b){
|
||||||
|
return new ExplosionI(b.var(team), b.var(x), b.var(y), b.var(radius), b.var(damage), b.var(air), b.var(ground), b.var(pierce));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user