This commit is contained in:
Virizion 2015-12-09 21:14:45 -05:00
parent be6f9ac6dc
commit 0ff87cf134
1 changed files with 49 additions and 15 deletions

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);
@ -250,13 +252,13 @@ 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
@ -265,21 +267,28 @@ public class SpeedBuilder extends SoloGame
judgeTargetLocation(null); judgeTargetLocation(null);
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());
DisguiseGuardian disguise = new DisguiseGuardian(_judgeLaserHelper);
_judgeDisguise.setTarget(_judgeLaserTarget.getEntityId()); disguise.setTarget(_judgeLaserTarget.getEntityId());
disguise.setInvisible(true);
Manager.GetDisguise().updateDisguise(_judgeDisguise); Manager.GetDisguise().disguise(disguise);
} }
} }
@ -636,6 +645,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())
{ {
@ -648,8 +669,16 @@ public class SpeedBuilder extends SoloGame
{ {
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
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(GetSpectatorLocation()); player.teleport(toTeleport);
} }
} }
@ -689,9 +718,14 @@ 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);
judgeTargetLocation(null); judgeTargetLocation(null);