From 97857453842f5905c5aedcc1642788782c9cd33e Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 7 Nov 2018 20:24:38 -0500 Subject: [PATCH] Fixed many multiplayer bugs --- core/src/io/anuke/mindustry/Vars.java | 2 ++ .../src/io/anuke/mindustry/content/Mechs.java | 3 ++- core/src/io/anuke/mindustry/core/Control.java | 6 ----- core/src/io/anuke/mindustry/core/Logic.java | 22 +++++++++++++++++-- .../mindustry/entities/units/types/Drone.java | 4 ++++ core/src/io/anuke/mindustry/game/Unlocks.java | 8 ------- core/src/io/anuke/mindustry/maps/Sectors.java | 2 +- .../anuke/mindustry/maps/TutorialSector.java | 2 +- .../mindustry/maps/missions/WaveMission.java | 4 ++-- core/src/io/anuke/mindustry/world/Block.java | 2 +- 10 files changed, 33 insertions(+), 22 deletions(-) diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 038a48ee7e..a11a7dbdcb 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -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; diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index 9e7d8ee3fd..88fb7b6a9e 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -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); } } } diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index e55d559ec1..7fec236a56 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -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){ diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index d6659dc925..625e0ec42a 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -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()); } diff --git a/core/src/io/anuke/mindustry/entities/units/types/Drone.java b/core/src/io/anuke/mindustry/entities/units/types/Drone.java index ed5cc2c6fd..d5c3d283f0 100644 --- a/core/src/io/anuke/mindustry/entities/units/types/Drone.java +++ b/core/src/io/anuke/mindustry/entities/units/types/Drone.java @@ -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); diff --git a/core/src/io/anuke/mindustry/game/Unlocks.java b/core/src/io/anuke/mindustry/game/Unlocks.java index 0730c4af64..e2bbd5984b 100644 --- a/core/src/io/anuke/mindustry/game/Unlocks.java +++ b/core/src/io/anuke/mindustry/game/Unlocks.java @@ -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); diff --git a/core/src/io/anuke/mindustry/maps/Sectors.java b/core/src/io/anuke/mindustry/maps/Sectors.java index 984788ae3e..9e372acc43 100644 --- a/core/src/io/anuke/mindustry/maps/Sectors.java +++ b/core/src/io/anuke/mindustry/maps/Sectors.java @@ -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){ diff --git a/core/src/io/anuke/mindustry/maps/TutorialSector.java b/core/src/io/anuke/mindustry/maps/TutorialSector.java index ccc75b38db..f88dbbabc9 100644 --- a/core/src/io/anuke/mindustry/maps/TutorialSector.java +++ b/core/src/io/anuke/mindustry/maps/TutorialSector.java @@ -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), diff --git a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java index 258ae7814d..5a257192a4 100644 --- a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java @@ -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 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)); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 90e513763b..e12050bbb5 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -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); } }