From 50104d2532d758f0f72b40b44164f20a96fbfe34 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 14 Jun 2019 13:29:40 -0400 Subject: [PATCH] Fixed door toggle --- .../mindustry/world/blocks/defense/Door.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java index 04da951cff..34a855dae8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java @@ -1,17 +1,16 @@ package io.anuke.mindustry.world.blocks.defense; +import io.anuke.annotations.Annotations.*; import io.anuke.arc.Core; import io.anuke.arc.Graphics.Cursor; import io.anuke.arc.Graphics.Cursor.SystemCursor; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.geom.Rectangle; import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.Effects.Effect; -import io.anuke.mindustry.entities.Units; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.mindustry.entities.type.*; +import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.world.Tile; import java.io.*; @@ -33,6 +32,22 @@ public class Door extends Wall{ consumesTap = true; } + @Remote(called = Loc.server) + public static void onDoorToggle(Player player, Tile tile, boolean open){ + DoorEntity entity = tile.entity(); + if(entity != null){ + entity.open = open; + Door door = (Door)tile.block(); + + world.pathfinder.updateSolid(tile); + if(!entity.open){ + Effects.effect(door.openfx, tile.drawx(), tile.drawy()); + }else{ + Effects.effect(door.closefx, tile.drawx(), tile.drawy()); + } + } + } + @Override public void load(){ super.load(); @@ -69,13 +84,7 @@ public class Door extends Wall{ return; } - entity.open = !entity.open; - world.pathfinder.updateSolid(tile); - if(!entity.open){ - Effects.effect(closefx, tile.drawx(), tile.drawy()); - }else{ - Effects.effect(openfx, tile.drawx(), tile.drawy()); - } + Call.onDoorToggle(null, tile, !entity.open); } @Override