/// <summary> /// </summary> /// <param name="c"> /// </param> private void CheckWallCollision(ICharacter c) { WallCollisionResult wcr = WallCollision.CheckCollision(c.Coordinates, c.Playfield.Identity.Instance); if (wcr != null) { int destPlayfield = wcr.SecondWall.DestinationPlayfield; if (destPlayfield > 0) { if (Program.DebugZoning) { LogUtil.Debug(wcr.ToString()); } PlayfieldDestination dest = PlayfieldLoader.PFData[destPlayfield].Destinations[wcr.SecondWall.DestinationIndex]; if (Program.DebugZoning) { LogUtil.Debug(dest.ToString()); } float newX = (dest.EndX - dest.StartX) * wcr.Factor + dest.StartX; float newZ = (dest.EndZ - dest.StartZ) * wcr.Factor + dest.StartZ; float dist = WallCollision.Distance(dest.StartX, dest.StartZ, dest.EndX, dest.EndZ); float headDistX = (dest.EndX - dest.StartX) / dist; float headDistZ = (dest.EndZ - dest.StartZ) / dist; newX -= headDistZ * 8; newZ += headDistX * 8; Coordinate destinationCoordinate = new Coordinate(newX, c.RawCoordinates.Y, newZ); this.Teleport( (Character)c, destinationCoordinate, c.RawHeading, new Identity() { Type = IdentityType.Playfield, Instance = destPlayfield }); return; } } }
/// <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); }