This commit is contained in:
Virizion 2015-12-09 21:14:45 -05:00
parent be6f9ac6dc
commit 0ff87cf134

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.speedbuilder; package nautilus.game.arcade.game.games.speedbuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -85,6 +86,7 @@ public class SpeedBuilder extends SoloGame
private ArmorStand _judgeEntity; private ArmorStand _judgeEntity;
private DisguiseGuardian _judgeDisguise; private DisguiseGuardian _judgeDisguise;
private Location _judgeSpawn; private Location _judgeSpawn;
private ArmorStand _judgeLaserHelper;
private ArmorStand _judgeLaserTarget; private ArmorStand _judgeLaserTarget;
private ArrayList<RecreationData> _toEliminate = new ArrayList<RecreationData>(); private ArrayList<RecreationData> _toEliminate = new ArrayList<RecreationData>();
@ -123,7 +125,7 @@ public class SpeedBuilder extends SoloGame
{ {
_buildMiddle = WorldData.GetDataLocs("RED").get(0).clone().subtract(0.5, 0, 0.5); _buildMiddle = WorldData.GetDataLocs("RED").get(0).clone().subtract(0.5, 0, 0.5);
_judgeSpawn = _buildMiddle.clone().add(0, 5, 0); _judgeSpawn = _buildMiddle.clone().add(0.5, 5, 0.5);
Location groundMin = _buildMiddle.clone().subtract(2, 1, 2); Location groundMin = _buildMiddle.clone().subtract(2, 1, 2);
@ -251,12 +253,12 @@ public class SpeedBuilder extends SoloGame
if (_judgeLaserTarget == null) if (_judgeLaserTarget == null)
return; return;
_judgeDisguise.setTarget(0); Manager.GetDisguise().undisguise(_judgeLaserHelper);
Manager.GetDisguise().updateDisguise(_judgeDisguise);
_judgeLaserHelper.remove();
_judgeLaserTarget.remove(); _judgeLaserTarget.remove();
_judgeLaserHelper = null;
_judgeLaserTarget = null; _judgeLaserTarget = null;
} }
else else
@ -266,20 +268,27 @@ public class SpeedBuilder extends SoloGame
CreatureAllowOverride = true; CreatureAllowOverride = true;
_judgeLaserHelper = _judgeEntity.getWorld().spawn(_judgeEntity.getLocation().subtract(_judgeEntity.getLocation().getDirection()), ArmorStand.class);
_judgeLaserTarget = _judgeEntity.getWorld().spawn(loc, ArmorStand.class); _judgeLaserTarget = _judgeEntity.getWorld().spawn(loc, ArmorStand.class);
CreatureAllowOverride = false; CreatureAllowOverride = false;
_judgeLaserHelper.setVisible(false);
_judgeLaserHelper.setGravity(false);
_judgeLaserHelper.setSmall(true);
_judgeLaserTarget.setVisible(false); _judgeLaserTarget.setVisible(false);
_judgeLaserTarget.setGravity(false); _judgeLaserTarget.setGravity(false);
_judgeLaserTarget.setSmall(true); _judgeLaserTarget.setSmall(true);
_judgeLaserTarget.setGhost(true);
UtilEnt.CreatureLook(_judgeEntity, _judgeLaserTarget.getLocation()); UtilEnt.CreatureLook(_judgeEntity, _judgeLaserTarget.getLocation());
_judgeDisguise.setTarget(_judgeLaserTarget.getEntityId()); DisguiseGuardian disguise = new DisguiseGuardian(_judgeLaserHelper);
Manager.GetDisguise().updateDisguise(_judgeDisguise); disguise.setTarget(_judgeLaserTarget.getEntityId());
disguise.setInvisible(true);
Manager.GetDisguise().disguise(disguise);
} }
} }
@ -637,6 +646,18 @@ public class SpeedBuilder extends SoloGame
recreation.pasteBuildData(_currentBuild); recreation.pasteBuildData(_currentBuild);
} }
Location specLocation = GetSpectatorLocation();
double avgDist = 0;
//Add up all the distances
for (Location loc : GetTeamList().get(0).GetSpawns())
{
avgDist += UtilMath.offset2d(specLocation, loc);
}
//Get the average by dividing
avgDist /= GetTeamList().get(0).GetSpawns().size();
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
@ -649,7 +670,15 @@ public class SpeedBuilder extends SoloGame
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
player.teleport(GetSpectatorLocation()); Location toTeleport = specLocation.clone();
//Spread players by getting a random x and z in that radius
toTeleport.setX(toTeleport.getX() + (Math.random() * avgDist * 2 - avgDist));
toTeleport.setZ(toTeleport.getZ() + (Math.random() * avgDist * 2 - avgDist));
toTeleport.setDirection(UtilAlg.getTrajectory(toTeleport, _buildMiddle.clone().add(0.5, 0, 0.5)));
player.teleport(toTeleport);
} }
} }
@ -690,7 +719,12 @@ public class SpeedBuilder extends SoloGame
WorldData.World.playEffect(eliminating.getMidpoint(), Effect.EXPLOSION_HUGE, 0); WorldData.World.playEffect(eliminating.getMidpoint(), Effect.EXPLOSION_HUGE, 0);
WorldData.World.playSound(eliminating.getMidpoint(), Sound.EXPLODE, 10F, 1F); WorldData.World.playSound(eliminating.getMidpoint(), Sound.EXPLODE, 10F, 1F);
Manager.GetExplosion().BlockExplosion(eliminating.getBlocks(), eliminating.getMidpoint(), false, false); HashSet<Block> blocks = UtilBlock.findConnectedBlocks(eliminating.OriginalBuildLocation.getBlock(), null, 1000);
//Sets should remove duplicates
blocks.addAll(eliminating.getBlocks());
Manager.GetExplosion().BlockExplosion(blocks, eliminating.getMidpoint(), false, true);
eliminating.clearBuildArea(true); eliminating.clearBuildArea(true);