RTS core capture derelict-ize
This commit is contained in:
Binary file not shown.
@@ -152,6 +152,14 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(BlockDestroyEvent.class, e -> {
|
||||||
|
//TODO maybe make it a separate rule?
|
||||||
|
//makes cores go derelict in RTS mode, helps clean things up
|
||||||
|
if(e.tile.build instanceof CoreBuild core && core.team.isAI() && core.team.rules().rtsAi){
|
||||||
|
core.team.data().makeDerelict(core.x, core.y, state.rules.enemyCoreBuildRadius);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//send out items to each client
|
//send out items to each client
|
||||||
Events.on(TurnEvent.class, e -> {
|
Events.on(TurnEvent.class, e -> {
|
||||||
if(net.server() && state.isCampaign()){
|
if(net.server() && state.isCampaign()){
|
||||||
@@ -167,7 +175,9 @@ public class Logic implements ApplicationListener{
|
|||||||
//listen to core changes; if all cores have been destroyed, set to derelict.
|
//listen to core changes; if all cores have been destroyed, set to derelict.
|
||||||
Events.on(CoreChangeEvent.class, e -> Core.app.post(() -> {
|
Events.on(CoreChangeEvent.class, e -> Core.app.post(() -> {
|
||||||
if(state.rules.cleanupDeadTeams && state.rules.pvp && !e.core.isAdded() && e.core.team != Team.derelict && e.core.team.cores().isEmpty()){
|
if(state.rules.cleanupDeadTeams && state.rules.pvp && !e.core.isAdded() && e.core.team != Team.derelict && e.core.team.cores().isEmpty()){
|
||||||
e.core.team.data().destroyToDerelict();
|
Core.app.post(() -> {
|
||||||
|
e.core.team.data().destroyToDerelict();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,12 +272,7 @@ public class Teams{
|
|||||||
|
|
||||||
//convert all team tiles to neutral, randomly killing them
|
//convert all team tiles to neutral, randomly killing them
|
||||||
for(var b : builds){
|
for(var b : builds){
|
||||||
//TODO this may cause a lot of packet spam, optimize?
|
scheduleDerelict(b);
|
||||||
Call.setTeam(b, Team.derelict);
|
|
||||||
|
|
||||||
if(Mathf.chance(0.25)){
|
|
||||||
Time.run(Mathf.random(0f, 60f * 6f), b::kill);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//kill all units randomly
|
//kill all units randomly
|
||||||
@@ -289,6 +284,29 @@ public class Teams{
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Make all buildings within this range derelict / explode. */
|
||||||
|
public void makeDerelict(float x, float y, float range){
|
||||||
|
var builds = new Seq<Building>();
|
||||||
|
if(buildings != null){
|
||||||
|
buildings.intersect(x - range, y - range, range * 2f, range * 2f, builds);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var build : builds){
|
||||||
|
if(build.within(x, y, range)){
|
||||||
|
scheduleDerelict(build);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scheduleDerelict(Building build){
|
||||||
|
//TODO this may cause a lot of packet spam, optimize?
|
||||||
|
Call.setTeam(build, Team.derelict);
|
||||||
|
|
||||||
|
if(Mathf.chance(0.25)){
|
||||||
|
Time.run(Mathf.random(0f, 60f * 6f), build::kill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Seq<Unit> unitCache(UnitType type){
|
public Seq<Unit> unitCache(UnitType type){
|
||||||
if(unitsByType == null || unitsByType.length <= type.id || unitsByType[type.id] == null) return null;
|
if(unitsByType == null || unitsByType.length <= type.id || unitsByType[type.id] == null) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user