Fixed many multiplayer bugs
This commit is contained in:
@@ -94,6 +94,7 @@ public class Vars{
|
||||
public static float controllerMin = 0.25f;
|
||||
public static float baseControllerSpeed = 11f;
|
||||
public static boolean snapCamera = true;
|
||||
|
||||
public static ContentLoader content;
|
||||
public static GameState state;
|
||||
public static ThreadHandler threads;
|
||||
@@ -162,6 +163,7 @@ public class Vars{
|
||||
});
|
||||
}
|
||||
|
||||
state = new GameState();
|
||||
threads = new ThreadHandler();
|
||||
|
||||
mobile = Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS || testMobile;
|
||||
|
||||
@@ -62,8 +62,9 @@ public class Mechs implements ContentList{
|
||||
drone.leader = player;
|
||||
drone.set(player.x, player.y);
|
||||
drone.add();
|
||||
|
||||
Effects.effect(UnitFx.unitLand, player);
|
||||
}
|
||||
Effects.effect(UnitFx.unitLand, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,12 +178,6 @@ public class Control extends Module{
|
||||
});
|
||||
|
||||
Events.on(WorldLoadEvent.class, event -> threads.runGraphics(() -> Events.fire(new WorldLoadGraphicsEvent())));
|
||||
|
||||
Events.on(TileChangeEvent.class, event -> {
|
||||
if(event.tile.getTeam() == players[0].getTeam() && Recipe.getByResult(event.tile.block()) != null){
|
||||
unlocks.handleContentUsed(Recipe.getByResult(event.tile.block()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addPlayer(int index){
|
||||
|
||||
@@ -10,9 +10,11 @@ import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.Teams;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -35,7 +37,11 @@ public class Logic extends Module{
|
||||
public boolean doUpdate = true;
|
||||
|
||||
public Logic(){
|
||||
state = new GameState();
|
||||
Events.on(TileChangeEvent.class, event -> {
|
||||
if(event.tile.getTeam() == defaultTeam && Recipe.getByResult(event.tile.block()) != null){
|
||||
handleContent(Recipe.getByResult(event.tile.block()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +53,17 @@ public class Logic extends Module{
|
||||
});
|
||||
}
|
||||
|
||||
/**Handles the event of content being used by either the player or some block.*/
|
||||
public void handleContent(UnlockableContent content){
|
||||
if(world.getSector() != null){
|
||||
world.getSector().currentMission().onContentUsed(content);
|
||||
}
|
||||
|
||||
if(!headless){
|
||||
control.unlocks.unlockContent(content);
|
||||
}
|
||||
}
|
||||
|
||||
public void play(){
|
||||
state.set(State.playing);
|
||||
state.wavetime = wavespace * state.difficulty.timeScaling * 2;
|
||||
@@ -145,7 +162,8 @@ public class Logic extends Module{
|
||||
|
||||
world.sectors.completeSector(world.getSector().x, world.getSector().y);
|
||||
world.sectors.save();
|
||||
if(!headless){
|
||||
|
||||
if(!headless && !Net.client()){
|
||||
ui.missions.show(world.getSector());
|
||||
}
|
||||
|
||||
|
||||
@@ -319,6 +319,10 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
TileEntity entity = (TileEntity) target;
|
||||
entity.health += type.healSpeed * Timers.delta();
|
||||
entity.health = Mathf.clamp(entity.health, 0, entity.tile.block().health);
|
||||
|
||||
if(timer.get(timerRepairEffect, 30)){
|
||||
Effects.effect(BlockFx.healBlockFull, Palette.heal, entity.x, entity.y, entity.tile.block().size);
|
||||
}
|
||||
}
|
||||
|
||||
updateBuilding(this);
|
||||
|
||||
@@ -19,14 +19,6 @@ public class Unlocks{
|
||||
Settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]);
|
||||
}
|
||||
|
||||
/**Handles the event of content being used by either the player or some block.*/
|
||||
public void handleContentUsed(UnlockableContent content){
|
||||
if(world.getSector() != null){
|
||||
world.getSector().currentMission().onContentUsed(content);
|
||||
}
|
||||
unlockContent(content);
|
||||
}
|
||||
|
||||
/** Returns whether or not this piece of content is unlocked yet.*/
|
||||
public boolean isUnlocked(UnlockableContent content){
|
||||
return rootSet().isUnlocked(content) || currentSet().isUnlocked(content);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Sectors{
|
||||
|
||||
public Difficulty getDifficulty(Sector sector){
|
||||
if(sector.difficulty == 0){
|
||||
return Difficulty.normal;
|
||||
return Difficulty.hard;
|
||||
}else if(sector.difficulty < 4){
|
||||
return Difficulty.normal;
|
||||
}else if(sector.difficulty < 9){
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TutorialSector{
|
||||
|
||||
return Array.with(
|
||||
//intentionally unlocalized
|
||||
new ItemMission(Items.copper, 10).setMessage("An updated tutorial will return next build.\nFor now, you'll have to deal with... this."),
|
||||
new ItemMission(Items.copper, 50).setMessage("An updated tutorial will return next build.\nFor now, you'll have to deal with... this."),
|
||||
|
||||
new BlockMission(ProductionBlocks.mechanicalDrill),
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.Waves;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -35,7 +36,6 @@ public class WaveMission extends MissionWithStartingCore{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Array<SpawnGroup> getWaves(Sector sector){
|
||||
return Waves.getSpawns();
|
||||
@@ -62,7 +62,7 @@ public class WaveMission extends MissionWithStartingCore{
|
||||
public String displayString(){
|
||||
return state.wave > target ?
|
||||
Bundles.format(
|
||||
Vars.unitGroups[Vars.waveTeam.ordinal()].size() > 1 ?
|
||||
Vars.unitGroups[Vars.waveTeam.ordinal()].size() > 1 && !Net.client() ?
|
||||
"text.mission.wave.enemies" :
|
||||
"text.mission.wave.enemy", target, target, Vars.unitGroups[Vars.waveTeam.ordinal()].size()) :
|
||||
Bundles.format("text.mission.wave", state.wave, target, (int)(state.wavetime/60));
|
||||
|
||||
@@ -230,7 +230,7 @@ public class Block extends BaseBlock {
|
||||
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
||||
public void useContent(Tile tile, UnlockableContent content){
|
||||
if(!headless && tile.getTeam() == players[0].getTeam()){
|
||||
control.unlocks.handleContentUsed(content);
|
||||
logic.handleContent(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user