/// <summary> /// </summary> /// <param name="self"> /// </param> /// <param name="caller"> /// </param> /// <param name="target"> /// </param> /// <param name="arguments"> /// </param> /// <returns> /// </returns> public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { if (arguments.Count() != 3) { return false; } uint arg1 = arguments[1].AsUInt32(); int toPlayfield = arguments[2].AsInt32(); byte destinationIndex = (byte)(arg1 >> 16); PlayfieldData pfd = PlayfieldLoader.PFData[toPlayfield]; PlayfieldDestination pfDestination = pfd.Destinations[destinationIndex]; float newX = (pfDestination.EndX - pfDestination.StartX) * 0.5f + pfDestination.StartX; float newZ = (pfDestination.EndZ - pfDestination.StartZ) * 0.5f + pfDestination.StartZ; float dist = WallCollision.Distance( pfDestination.StartX, pfDestination.StartZ, pfDestination.EndX, pfDestination.EndZ); float headDistX = (pfDestination.EndX - pfDestination.StartX) / dist; float headDistZ = (pfDestination.EndZ - pfDestination.StartZ) / dist; newX -= headDistZ * 4; newZ += headDistX * 4; Coordinate destCoordinate = new Coordinate(newX, pfDestination.EndY, newZ); ((ICharacter)self).Teleport( destCoordinate, ((ICharacter)self).Heading, new Identity() { Type = IdentityType.Playfield, Instance = toPlayfield }); return true; }