Fixed evolution rotation
This commit is contained in:
parent
53a3a29cd2
commit
62072077c1
@ -33,6 +33,8 @@ public abstract class EvoKit extends Kit
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1.0F, 0.1F);
|
||||
|
||||
UtilPlayer.message(player, C.Line);
|
||||
UtilPlayer.message(player, C.Line);
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
UtilPlayer.message(player, C.Bold + "You evolved into " + ("aeiou".indexOf(GetName().toLowerCase().substring(0, 1)) == -1 ? "a " : "an ") + F.elem(C.cGreen + C.Bold + GetName()) + "!");
|
||||
|
||||
|
@ -172,6 +172,18 @@ public class Evolution extends SoloGame
|
||||
_evolve.tick();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void moveEvolve(PlayerMoveEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!_evolve.isEvolving(event.getPlayer()))
|
||||
return;
|
||||
|
||||
_evolve.getEvolve(event.getPlayer()).teleport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasKit(Player player, Kit kit)
|
||||
{
|
||||
@ -210,16 +222,6 @@ public class Evolution extends SoloGame
|
||||
event.SetCancelled("Player is evolving!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEvolveMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_evolve.isEvolving(event.getPlayer()))
|
||||
event.getPlayer().teleport(event.getFrom());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEvolveAbility(EvolutionAbilityUseEvent event)
|
||||
{
|
||||
@ -268,17 +270,6 @@ public class Evolution extends SoloGame
|
||||
public void endEvolve(final EvolutionPostEvolveEvent event)
|
||||
{
|
||||
event.getPlayer().teleport(GetTeam(event.getPlayer()).GetSpawn());
|
||||
|
||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
SetKit(event.getPlayer(), GetKit(event.getPlayer()), false);
|
||||
}
|
||||
}, 4);
|
||||
|
||||
Manager.GetCondition().GetActiveCondition(event.getPlayer(), ConditionType.CLOAK).Expire();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
@ -12,6 +14,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.minecraft.game.core.condition.Condition;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.arcade.game.games.evolution.EvoKit;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
|
||||
@ -38,8 +41,8 @@ import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -62,15 +65,21 @@ public class EvolveData
|
||||
|
||||
private String _evolveTop;
|
||||
|
||||
private Bat _bat;
|
||||
|
||||
private ArrayList<Location> _rotateLocs = new ArrayList<Location>();
|
||||
private Iterator<Location> _rotateIterator;
|
||||
private double _radius = 3.4;
|
||||
|
||||
private double _radius = 4.0;
|
||||
private double _speed = 6.0;
|
||||
private double _height = 2.5;
|
||||
|
||||
public EvolveData(EvolveManager manager, Player player, EvoKit from, EvoKit to)
|
||||
{
|
||||
_manager = manager;
|
||||
|
||||
_player = player;
|
||||
_manager.Host.Manager.GetCondition().Factory().Cloak(null, _player, null, Double.MAX_VALUE, false, false);
|
||||
|
||||
_to = to;
|
||||
_evolveTop = C.cWhite + "You evolved into " + ("aeiou".indexOf(_to.GetName().toLowerCase().substring(0, 1)) == -1 ? "a " : "an ") + C.cGreen + C.Bold + _to.GetName();
|
||||
@ -78,13 +87,16 @@ public class EvolveData
|
||||
_eFrom = spawn(from.getEntity());
|
||||
|
||||
setupLocs();
|
||||
setupBat();
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
||||
|
||||
teleport();
|
||||
}
|
||||
|
||||
private void setupLocs()
|
||||
{
|
||||
for (double i = 0 ; i < 50.0 ; i+= .02)
|
||||
for (double i = 0 ; i < 50.0 ; i+= .03)
|
||||
{
|
||||
Location loc = _manager.getLocation().clone().add(Math.cos(i) * _radius, 3.0, Math.sin(i) * _radius);
|
||||
|
||||
@ -99,6 +111,23 @@ public class EvolveData
|
||||
_rotateIterator = _rotateLocs.iterator();
|
||||
}
|
||||
|
||||
private void setupBat()
|
||||
{
|
||||
_manager.Host.CreatureAllowOverride = true;
|
||||
Bat bat = _manager.getLocation().getWorld().spawn(_rotateIterator.next(), Bat.class);
|
||||
_manager.Host.CreatureAllowOverride = false;
|
||||
|
||||
bat.setAwake(true);
|
||||
bat.setRemoveWhenFarAway(false);
|
||||
|
||||
UtilEnt.Vegetate(bat, true);
|
||||
UtilEnt.ghost(bat, false, true);
|
||||
|
||||
bat.setPassenger(_player);
|
||||
|
||||
_bat = bat;
|
||||
}
|
||||
|
||||
//Boolean completed
|
||||
public boolean tick()
|
||||
{
|
||||
@ -120,6 +149,19 @@ public class EvolveData
|
||||
|
||||
UtilTextMiddle.display(null, _evolveTop, _player);
|
||||
|
||||
for (ConditionType type : ConditionType.values())
|
||||
{
|
||||
if (type == ConditionType.CLOAK)
|
||||
continue;
|
||||
|
||||
if (!_manager.Host.Manager.GetCondition().HasCondition(_player, type, null))
|
||||
continue;
|
||||
|
||||
_manager.Host.Manager.GetCondition().GetActiveCondition(_player, type).Expire();
|
||||
}
|
||||
|
||||
_manager.Host.SetKit(_player, _manager.Host.GetKit(_player), false);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionEndEvent(_player));
|
||||
}
|
||||
else
|
||||
@ -139,39 +181,40 @@ public class EvolveData
|
||||
|
||||
despawn(_eTo);
|
||||
|
||||
for (ConditionType type : ConditionType.values())
|
||||
{
|
||||
if (type == ConditionType.CLOAK)
|
||||
continue;
|
||||
_player.leaveVehicle();
|
||||
_bat.remove();
|
||||
|
||||
_manager.Host.Manager.GetCondition().EndCondition(_player, type, "Removing kit effects");
|
||||
}
|
||||
|
||||
_player.setFlying(false);
|
||||
_player.setAllowFlight(false);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player));
|
||||
|
||||
Condition cloak = _manager.Host.Manager.GetCondition().GetActiveCondition(_player, ConditionType.CLOAK);
|
||||
|
||||
if (cloak != null)
|
||||
cloak.Expire();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void teleport()
|
||||
public void teleport()
|
||||
{
|
||||
_player.teleport(_player.getLocation().setDirection(UtilAlg.getTrajectory(_player.getEyeLocation(), _manager.getLocation())));
|
||||
|
||||
if (_bat.isEmpty() || _bat.getPassenger() != _player)
|
||||
_bat.setPassenger(_player);
|
||||
|
||||
if (_player.getFireTicks() > 0)
|
||||
_player.setFireTicks(0);
|
||||
|
||||
((CraftEntity) _player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
|
||||
|
||||
_player.setFallDistance(0);
|
||||
_player.setHealth(20.0);
|
||||
_player.setAllowFlight(true);
|
||||
_player.setFlying(true);
|
||||
|
||||
((CraftPlayer) _player).getHandle().p(0);
|
||||
|
||||
if (!_rotateIterator.hasNext())
|
||||
_rotateIterator = _rotateLocs.iterator();
|
||||
//Orbit
|
||||
double oX = -Math.sin(_bat.getTicksLived() / _speed) * 2 * _radius;
|
||||
double oZ = Math.cos(_bat.getTicksLived() / _speed) * 2 * _radius;
|
||||
|
||||
_player.teleport(_rotateIterator.next());
|
||||
UtilAction.velocity(_bat, UtilAlg.getTrajectory(_bat.getLocation(), _manager.getLocation().clone().add(oX, _height, oZ)), 0.4, false, 0, 0.1, 1, true);
|
||||
}
|
||||
|
||||
private EntityInsentient spawn(EntityType type)
|
||||
|
@ -43,6 +43,11 @@ public class EvolveManager
|
||||
_data.put(player.getName(), new EvolveData(this, player, from, to));
|
||||
}
|
||||
|
||||
public EvolveData getEvolve(Player player)
|
||||
{
|
||||
return _data.get(player.getName());
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
Iterator<Entry<String, EvolveData>> iterator = _data.entrySet().iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user