Fixed #3650
This commit is contained in:
@@ -16,11 +16,13 @@ abstract class BoundedComp implements Velc, Posc, Healthc, Flyingc{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
//repel unit out of bounds
|
if(!net.client() || isLocal()){
|
||||||
if(x < 0) vel.x += (-x/warpDst);
|
//repel unit out of bounds
|
||||||
if(y < 0) vel.y += (-y/warpDst);
|
if(x < 0) vel.x += (-x/warpDst);
|
||||||
if(x > world.unitWidth()) vel.x -= (x - world.unitWidth())/warpDst;
|
if(y < 0) vel.y += (-y/warpDst);
|
||||||
if(y > world.unitHeight()) vel.y -= (y - world.unitHeight())/warpDst;
|
if(x > world.unitWidth()) vel.x -= (x - world.unitWidth())/warpDst;
|
||||||
|
if(y > world.unitHeight()) vel.y -= (y - world.unitHeight())/warpDst;
|
||||||
|
}
|
||||||
|
|
||||||
//clamp position if not flying
|
//clamp position if not flying
|
||||||
if(isGrounded()){
|
if(isGrounded()){
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -28,6 +29,7 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
|||||||
|
|
||||||
@Import float x, y, rotation;
|
@Import float x, y, rotation;
|
||||||
@Import UnitType type;
|
@Import UnitType type;
|
||||||
|
@Import Team team;
|
||||||
|
|
||||||
@SyncLocal Queue<BuildPlan> plans = new Queue<>(1);
|
@SyncLocal Queue<BuildPlan> plans = new Queue<>(1);
|
||||||
@SyncLocal transient boolean updateBuilding = true;
|
@SyncLocal transient boolean updateBuilding = true;
|
||||||
@@ -75,27 +77,27 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
|||||||
Tile tile = world.tile(current.x, current.y);
|
Tile tile = world.tile(current.x, current.y);
|
||||||
|
|
||||||
if(!(tile.block() instanceof ConstructBlock)){
|
if(!(tile.block() instanceof ConstructBlock)){
|
||||||
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team(), current.x, current.y, current.rotation)){
|
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team, current.x, current.y, current.rotation)){
|
||||||
boolean hasAll = infinite || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
boolean hasAll = infinite || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
||||||
|
|
||||||
if(hasAll){
|
if(hasAll){
|
||||||
Call.beginPlace(current.block, team(), current.x, current.y, current.rotation);
|
Call.beginPlace(current.block, team, current.x, current.y, current.rotation);
|
||||||
}else{
|
}else{
|
||||||
current.stuck = true;
|
current.stuck = true;
|
||||||
}
|
}
|
||||||
}else if(!current.initialized && current.breaking && Build.validBreak(team(), current.x, current.y)){
|
}else if(!current.initialized && current.breaking && Build.validBreak(team, current.x, current.y)){
|
||||||
Call.beginBreak(team(), current.x, current.y);
|
Call.beginBreak(team, current.x, current.y);
|
||||||
}else{
|
}else{
|
||||||
plans.removeFirst();
|
plans.removeFirst();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else if(tile.team() != team()){
|
}else if(tile.team() != team){
|
||||||
plans.removeFirst();
|
plans.removeFirst();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.build instanceof ConstructBuild && !current.initialized){
|
if(tile.build instanceof ConstructBuild && !current.initialized){
|
||||||
Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, team(), (Builderc)this, current.breaking)));
|
Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, team, (Builderc)this, current.breaking)));
|
||||||
current.initialized = true;
|
current.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +130,7 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
|||||||
control.input.drawBreaking(request);
|
control.input.drawBreaking(request);
|
||||||
}else{
|
}else{
|
||||||
request.block.drawRequest(request, control.input.allRequests(),
|
request.block.drawRequest(request, control.input.allRequests(),
|
||||||
Build.validPlace(request.block, team(), request.x, request.y, request.rotation) || control.input.requestMatches(request));
|
Build.validPlace(request.block, team, request.x, request.y, request.rotation) || control.input.requestMatches(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +140,7 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
|||||||
/** @return whether this request should be skipped, in favor of the next one. */
|
/** @return whether this request should be skipped, in favor of the next one. */
|
||||||
boolean shouldSkip(BuildPlan request, @Nullable Building core){
|
boolean shouldSkip(BuildPlan request, @Nullable Building core){
|
||||||
//requests that you have at least *started* are considered
|
//requests that you have at least *started* are considered
|
||||||
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
|
if(state.rules.infiniteResources || team.rules().infiniteResources || request.breaking || core == null) return false;
|
||||||
return (request.stuck && !core.items.has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items.has(i.item) && Mathf.round(i.amount * state.rules.buildCostMultiplier) > 0) && !request.initialized);
|
return (request.stuck && !core.items.has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items.has(i.item) && Mathf.round(i.amount * state.rules.buildCostMultiplier) > 0) && !request.initialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f);
|
drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f);
|
||||||
|
|
||||||
//apply knockback based on spawns
|
//apply knockback based on spawns
|
||||||
if(team != state.rules.waveTeam && state.hasSpawns()){
|
if(team != state.rules.waveTeam && state.hasSpawns() && (!net.client() || isLocal())){
|
||||||
float relativeSize = state.rules.dropZoneRadius + hitSize/2f + 1f;
|
float relativeSize = state.rules.dropZoneRadius + hitSize/2f + 1f;
|
||||||
for(Tile spawn : spawner.getSpawns()){
|
for(Tile spawn : spawner.getSpawns()){
|
||||||
if(within(spawn.worldx(), spawn.worldy(), relativeSize)){
|
if(within(spawn.worldx(), spawn.worldy(), relativeSize)){
|
||||||
|
|||||||
Reference in New Issue
Block a user