Upgradeable cores
This commit is contained in:
@@ -265,10 +265,10 @@ public class Damage{
|
||||
if(scaledDamage <= 0 || tile == null) continue;
|
||||
|
||||
//apply damage to entity if needed
|
||||
if(tile.entity != null && tile.team() != team){
|
||||
int health = (int)tile.entity.health();
|
||||
if(tile.entity.health() > 0){
|
||||
tile.entity.damage(scaledDamage);
|
||||
if(tile.build != null && tile.team() != team){
|
||||
int health = (int)tile.build.health();
|
||||
if(tile.build.health() > 0){
|
||||
tile.build.damage(scaledDamage);
|
||||
scaledDamage -= health;
|
||||
|
||||
if(scaledDamage <= 0) continue;
|
||||
@@ -290,8 +290,8 @@ public class Damage{
|
||||
for(int dx = -trad; dx <= trad; dx++){
|
||||
for(int dy = -trad; dy <= trad; dy++){
|
||||
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
||||
if(tile != null && tile.entity != null && (team == null ||team.isEnemy(tile.team())) && Mathf.dst(dx, dy) <= trad){
|
||||
tile.entity.damage(damage);
|
||||
if(tile != null && tile.build != null && (team == null ||team.isEnemy(tile.team())) && Mathf.dst(dx, dy) <= trad){
|
||||
tile.build.damage(damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Units{
|
||||
/** Returns the neareset damaged tile. */
|
||||
public static Building findDamagedTile(Team team, float x, float y){
|
||||
Tile tile = Geometry.findClosest(x, y, indexer.getDamaged(team));
|
||||
return tile == null ? null : tile.entity;
|
||||
return tile == null ? null : tile.build;
|
||||
}
|
||||
|
||||
/** Returns the neareset ally tile in a range. */
|
||||
|
||||
@@ -100,25 +100,25 @@ abstract class BuilderComp implements Unitc{
|
||||
return;
|
||||
}
|
||||
|
||||
if(tile.entity instanceof BuildEntity && !current.initialized){
|
||||
if(tile.build instanceof BuildEntity && !current.initialized){
|
||||
Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, team(), (Builderc)this, current.breaking)));
|
||||
current.initialized = true;
|
||||
}
|
||||
|
||||
//if there is no core to build with or no build entity, stop building!
|
||||
if((core == null && !infinite) || !(tile.entity instanceof BuildEntity)){
|
||||
if((core == null && !infinite) || !(tile.build instanceof BuildEntity)){
|
||||
return;
|
||||
}
|
||||
|
||||
//otherwise, update it.
|
||||
BuildEntity entity = tile.ent();
|
||||
BuildEntity entity = tile.bc();
|
||||
|
||||
if(current.breaking){
|
||||
entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier);
|
||||
}else{
|
||||
if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
|
||||
if(current.hasConfig){
|
||||
Call.onTileConfig(null, tile.entity, current.config);
|
||||
Call.onTileConfig(null, tile.build, current.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,8 +190,8 @@ abstract class BuilderComp implements Unitc{
|
||||
plans.remove(replace);
|
||||
}
|
||||
Tile tile = world.tile(place.x, place.y);
|
||||
if(tile != null && tile.entity instanceof BuildEntity){
|
||||
place.progress = tile.<BuildEntity>ent().progress;
|
||||
if(tile != null && tile.build instanceof BuildEntity){
|
||||
place.progress = tile.<BuildEntity>bc().progress;
|
||||
}
|
||||
if(tail){
|
||||
plans.addLast(place);
|
||||
|
||||
@@ -400,8 +400,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
int trns = block.size/2 + 1;
|
||||
Tile next = tile.getNearby(Geometry.d4(rotation()).x * trns, Geometry.d4(rotation()).y * trns);
|
||||
|
||||
if(next != null && next.entity != null && next.entity.team() == team && next.entity.acceptPayload(base(), todump)){
|
||||
next.entity.handlePayload(base(), todump);
|
||||
if(next != null && next.build != null && next.build.team() == team && next.build.acceptPayload(base(), todump)){
|
||||
next.build.handlePayload(base(), todump);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -485,8 +485,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
if(next == null) return 0;
|
||||
|
||||
if(next.entity != null){
|
||||
return moveLiquid(next.entity, liquid);
|
||||
if(next.build != null){
|
||||
return moveLiquid(next.build, liquid);
|
||||
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
||||
float leakAmount = liquids.get(liquid) / leakResistance;
|
||||
Puddles.deposit(next, tile, liquid, leakAmount);
|
||||
@@ -673,8 +673,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
power.graph.remove(base());
|
||||
for(int i = 0; i < power.links.size; i++){
|
||||
Tile other = world.tile(power.links.get(i));
|
||||
if(other != null && other.entity != null && other.entity.power != null){
|
||||
other.entity.power.links.removeValue(pos());
|
||||
if(other != null && other.build != null && other.build.power != null){
|
||||
other.build.power.links.removeValue(pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -693,7 +693,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
for(int i = 0; i < power.links.size; i++){
|
||||
Tile link = world.tile(power.links.get(i));
|
||||
if(link != null && link.entity != null && link.entity.power != null) out.add(link.entity);
|
||||
if(link != null && link.build != null && link.build.power != null) out.add(link.build);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -803,8 +803,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
|
||||
if(!tempTiles.isEmpty()){
|
||||
Tile toLink = tempTiles.first();
|
||||
if(!toLink.entity.power.links.contains(pos())){
|
||||
toLink.entity.configureAny(pos());
|
||||
if(!toLink.build.power.links.contains(pos())){
|
||||
toLink.build.configureAny(pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1125,7 +1125,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
@Replace
|
||||
@Override
|
||||
public boolean isValid(){
|
||||
return tile.entity == base() && !dead();
|
||||
return tile.build == base() && !dead();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,7 +49,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
||||
return;
|
||||
}
|
||||
|
||||
Building entity = tile.entity;
|
||||
Building entity = tile.build;
|
||||
boolean damage = entity != null;
|
||||
|
||||
float flammability = baseFlammability + puddleFlammability;
|
||||
@@ -59,7 +59,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
||||
}
|
||||
|
||||
if(baseFlammability < 0 || block != tile.block()){
|
||||
baseFlammability = tile.entity == null ? 0 : tile.entity.getFlammability();
|
||||
baseFlammability = tile.build == null ? 0 : tile.build.getFlammability();
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ abstract class PayloadComp implements Posc, Rotc{
|
||||
Tile on = tileOn();
|
||||
|
||||
//drop off payload on an acceptor if possible
|
||||
if(on != null && on.entity != null && on.entity.acceptPayload(on.entity, payload)){
|
||||
Fx.unitDrop.at(on.entity);
|
||||
on.entity.handlePayload(on.entity, payload);
|
||||
if(on != null && on.build != null && on.build.acceptPayload(on.build, payload)){
|
||||
Fx.unitDrop.at(on.build);
|
||||
on.build.handlePayload(on.build, payload);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||
}
|
||||
});
|
||||
|
||||
if(liquid.temperature > 0.7f && (tile.entity != null) && Mathf.chance(0.3 * Time.delta())){
|
||||
if(liquid.temperature > 0.7f && (tile.build != null) && Mathf.chance(0.3 * Time.delta())){
|
||||
Fires.create(tile);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@ abstract class TrailComp implements Unitc{
|
||||
@Import UnitType type;
|
||||
@Import float x, y, rotation;
|
||||
|
||||
transient Trail trail = new Trail(4);
|
||||
transient Trail trail = new Trail(6);
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
trail.length = type.trailLength;
|
||||
|
||||
float scale = elevation();
|
||||
float offset = type.engineOffset/2f + type.engineOffset/2f*scale;
|
||||
|
||||
|
||||
@@ -181,8 +181,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
if(tile != null && isGrounded()){
|
||||
//unit block update
|
||||
if(tile.entity != null){
|
||||
tile.entity.unitOn(base());
|
||||
if(tile.build != null){
|
||||
tile.build.unitOn(base());
|
||||
}
|
||||
|
||||
//kill when stuck in wall
|
||||
|
||||
@@ -24,12 +24,12 @@ public class AIController implements UnitController{
|
||||
|
||||
protected void targetClosestAllyFlag(BlockFlag flag){
|
||||
Tile target = Geometry.findClosest(unit.x, unit.y, indexer.getAllied(unit.team, flag));
|
||||
if(target != null) this.target = target.entity;
|
||||
if(target != null) this.target = target.build;
|
||||
}
|
||||
|
||||
protected void targetClosestEnemyFlag(BlockFlag flag){
|
||||
Tile target = Geometry.findClosest(unit.x, unit.y, indexer.getEnemy(unit.team, flag));
|
||||
if(target != null) this.target = target.entity;
|
||||
if(target != null) this.target = target.build;
|
||||
}
|
||||
|
||||
protected boolean retarget(){
|
||||
|
||||
Reference in New Issue
Block a user