private void SpawnMob(int x, int y, NPCEntry entry, IWorldLocation dest) { Vector3 pos = new Vector3(dest.Position.X + (float)x, dest.Position.Y + (float)y); WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U); entry.SpawnAt((IWorldLocation)worldLocation, false).Brain.State = BrainState.GmMove; }
public float GetHeight(WorldLocation location, TileManager tiles, SceneryDrawer scenery) { location.Normalize(); // First, ensure we have the tile in question cached. var tile = Tiles.FirstOrDefault(t => t.TileX == location.TileX && t.TileZ == location.TileZ); if (tile == null) { Tiles.Add(tile = new Tile(location.TileX, location.TileZ, Divisions)); } // Remove excess entries. if (Tiles.Count > TileCount) { Tiles.RemoveAt(0); } // Now calculate division to query. var x = (int)((location.Location.X + 1024) / BlockSize); var z = (int)((location.Location.Z + 1024) / BlockSize); // If we don't have it cached, load it. if (tile.Height[x, z] == float.MinValue) { var position = new WorldLocation(location.TileX, location.TileZ, (x + 0.5f) * BlockSize - 1024, 0, (z + 0.5f) * BlockSize - 1024); tile.Height[x, z] = Math.Max(tiles.GetElevation(position), scenery.GetBoundingBoxTop(position, BlockSize)); tile.Used++; } return(tile.Height[x, z]); }
public Nullable <Block> GetBlock(WorldLocation loc) { ChunkLocation cl = new ChunkLocation((int)Math.Floor((Double)loc.X / 16), loc.Y, (int)Math.Floor((Double)loc.Z / 16)); Chunk c = GetChunk(cl); return(c.GetBlock(loc)); }
/// <summary> /// Basic method to draw an arc, intended to be used for drawing a curver track section /// Parameters are in world coordinates and sizes /// </summary> /// <param name="width">Width of the arc-line to draw in meters</param> /// <param name="color">Color of the arc-line</param> /// <param name="point">WorldLocation of the starting point of the arc</param> /// <param name="radius">Radius of the curvature of the arc</param> /// <param name="angle">Angle (in degrees east of North) of the first part of the arc</param> /// <param name="arcDegrees">Number of degrees in the arc (360 would be full circle)</param> /// <param name="arcDegreesOffset">Offset of the number of degrees (meaning, do not draw the first arcDegreesOffset degrees</param> public void DrawArc(float width, Color color, WorldLocation point, float radius, float angle, float arcDegrees, float arcDegreesOffset) { WorldLocation beginPoint; // (possibly approximate) location of begin-point if (arcDegreesOffset == 0) { beginPoint = point; } else { beginPoint = new WorldLocation(point); float arcRadOffset = arcDegreesOffset * MathHelper.Pi / 180; float lengthOffset = radius * arcRadOffset; beginPoint.Location.X += lengthOffset * (float)Math.Sin(angle + arcRadOffset / 2); beginPoint.Location.Z += lengthOffset * (float)Math.Cos(angle + arcRadOffset / 2); } WorldLocation endPoint = new WorldLocation(beginPoint); //approximate location of end-point float arcRad = arcDegrees * MathHelper.Pi / 180; float length = radius * arcRad; endPoint.Location.X += length * (float)Math.Sin(angle + arcRad / 2); endPoint.Location.Z += length * (float)Math.Cos(angle + arcRad / 2); if (OutOfArea(beginPoint) && OutOfArea(endPoint)) { return; } // for the 90 degree offset, see DrawLine BasicShapes.DrawArc(GetWindowSize(width), color, GetWindowVector(point), GetWindowSize(radius), angle - MathHelper.Pi / 2, arcDegrees, arcDegreesOffset); }
void HandleSuspendTokenResponse(SuspendTokenResponse suspendTokenResponse) { if (!_player.IsBeingTeleportedFar()) { return; } WorldLocation loc = GetPlayer().GetTeleportDest(); if (CliDB.MapStorage.LookupByKey(loc.GetMapId()).IsDungeon()) { UpdateLastInstance updateLastInstance = new(); updateLastInstance.MapID = loc.GetMapId(); SendPacket(updateLastInstance); } NewWorld packet = new(); packet.MapID = loc.GetMapId(); packet.Loc.Pos = loc; packet.Reason = (uint)(!_player.IsBeingTeleportedSeamlessly() ? NewWorldReason.Normal : NewWorldReason.Seamless); SendPacket(packet); if (_player.IsBeingTeleportedSeamlessly()) { HandleMoveWorldportAck(); } }
public DispatcherLineSegment(WorldLocation start, WorldLocation end, Color color, float width) { Start = start; End = end; Color = color; Width = width; }
void SendSpiritResurrect() { GetPlayer().ResurrectPlayer(0.5f, true); GetPlayer().DurabilityLossAll(0.25f, true); // get corpse nearest graveyard WorldSafeLocsEntry corpseGrave = null; WorldLocation corpseLocation = GetPlayer().GetCorpseLocation(); if (GetPlayer().HasCorpse()) { corpseGrave = Global.ObjectMgr.GetClosestGraveYard(corpseLocation, GetPlayer().GetTeam(), GetPlayer()); } // now can spawn bones GetPlayer().SpawnCorpseBones(); // teleport to nearest from corpse graveyard, if different from nearest to player ghost if (corpseGrave != null) { WorldSafeLocsEntry ghostGrave = Global.ObjectMgr.GetClosestGraveYard(GetPlayer(), GetPlayer().GetTeam(), GetPlayer()); if (corpseGrave != ghostGrave) { GetPlayer().TeleportTo(corpseGrave.Loc); } } }
/// <summary> /// Check wether this vector node is closest to the mouse location /// </summary> /// <param name="location">Location to check</param> /// <param name="mouseLocation">Current mouse location</param> /// <param name="trackNode">The trackNode that will be stored when indeed it is the closest to the mouse location</param> /// <param name="vectorSection">the vectorSection that will be stored when indeed it is closest to the mouse location</param> /// <param name="tvsi">Current index of the trackvectorsection</param> /// <param name="pixelsPerMeter"></param> public void CheckMouseDistance(WorldLocation location, WorldLocation mouseLocation, TrackNode trackNode, TrVectorSection vectorSection, int tvsi, double pixelsPerMeter) { storedMouseLocation = mouseLocation; float distanceSquared = WorldLocation.GetDistanceSquared2D(location, mouseLocation); // to make unique distances becasue they also act as Key double distanceSquaredIndexed = ((double)distanceSquared) * (1 + 1e-16 * trackNode.Index); if (distanceSquaredIndexed < sortedTrackCandidates.First().Key) { if (!sortedTrackCandidates.ContainsKey(distanceSquaredIndexed)) { sortedTrackCandidates.Add(distanceSquaredIndexed, new TrackCandidate(trackNode, vectorSection, tvsi, 0)); // The next one is a bit tricky. The problem is that the first culling is done based on the trackvector section location // Which is only at one side of the section. So the other end might be quiet far away. // Unfortunately, this means that we need to keep track of many candidates to make sure we can calculate the closest one // Which is costing performance. // The biggest issue is for a long track close to a region with lots junctions and hence small track segments // By making this number zoom dependent, we get good results for big zooms, and not a large // performance penalty for wide views int maxNumberOfCandidates = 50 + (int)(100 * pixelsPerMeter); while (sortedTrackCandidates.Count > maxNumberOfCandidates) { sortedTrackCandidates.RemoveAt(0); // First one has largest distance } } } }
public virtual void DoTeleport(Mobile m) { WorldLocation loc = TeleLocs.Keys.FirstOrDefault(l => l.Location.X == m.X && l.Location.Y == m.Y && l.Location.Z >= m.Z - 5 && l.Location.Z <= m.Z + 5 && l.Map == m.Map); if (loc != null) { var destinationPoint = TeleLocs[loc].Location; var destinationMap = TeleLocs[loc].Map; if (destinationPoint != Point3D.Zero && destinationMap != null && destinationMap != Map.Internal) { m.BeginAction(typeof(Teleporter)); m.Frozen = true; Timer.DelayCall(TimeSpan.FromMilliseconds(400), () => { BaseCreature.TeleportPets(m, destinationPoint, destinationMap); m.MoveToWorld(destinationPoint, destinationMap); m.Frozen = false; Timer.DelayCall(TimeSpan.FromMilliseconds(250), () => m.EndAction(typeof(Teleporter))); }); } } }
public override void Update(STFReader stf) { stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("eventtypelocation", () => { stf.MustMatchBlockStart(); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("id", () => { ID = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("ortstriggeringtrain", () => { ParseTrain(stf); }), new STFReader.TokenProcessor("activation_level", () => { ActivationLevel = stf.ReadIntBlock(null); }), new STFReader.TokenProcessor("outcomes", () => { if (Outcomes == null) { Outcomes = new Outcomes(stf); } else { Outcomes.Update(stf); } }), new STFReader.TokenProcessor("name", () => { Name = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("texttodisplayoncompletioniftriggered", () => { TextToDisplayOnCompletionIfTriggered = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("texttodisplayoncompletionifnottriggered", () => { TextToDisplayOnCompletionIfNotTriggered = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("triggeronstop", () => { TriggerOnStop = stf.ReadBoolBlock(true); }), new STFReader.TokenProcessor("location", () => { stf.MustMatchBlockStart(); location = new WorldLocation(stf.ReadInt(null), stf.ReadInt(null), stf.ReadFloat(STFReader.Units.None, null), 0f, stf.ReadFloat(STFReader.Units.None, null)); RadiusM = stf.ReadFloat(STFReader.Units.Distance, null); stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortscontinue", () => { OrtsContinue = stf.ReadIntBlock(0); }), new STFReader.TokenProcessor("ortsactsoundfile", () => OrtsActivitySoundProcessor(stf)), new STFReader.TokenProcessor("ortsweatherchange", () => { WeatherChange = new OrtsWeatherChange(stf); }), }); }
/// <summary> /// Constructor that immediately sets the closest item (and distance) /// </summary> /// <param name="item">track item to store as closest item</param> public CloseToMouseItem(DrawableTrackItem item) { ClosestDistanceSquared = 0; DrawableTrackItem = item; Description = DrawableTrackItem.Description; worldLocation = DrawableTrackItem.WorldLocation; }
public GameSession(Player player) { CurrentWorld = WorldFactory.Immensea(); CurrentPlayer = player; CurrentPlayer.Weapon = ItemFactory.CreateWeapon(TypeID.PointyStick); CurrentLocation = CurrentWorld.LocationAt(0, 0); }
public void Update(WorldLocation playerLocation, int approachDist, int scaredDist) { if (state == State.Idle1) { if (Simulator.Random.Next(10) == 0) { state = State.Idle2; } } else if (state == State.Idle2) { if (Simulator.Random.Next(5) == 0) { state = State.Idle1; } } if (!WorldLocation.Within(Location, playerLocation, scaredDist) && state < State.LookLeft) { if (WorldLocation.Within(Location, playerLocation, approachDist) && state < State.LookLeft) { state = State.LookRight; } } if (WorldLocation.Within(Location, playerLocation, scaredDist) && state == State.LookRight || state == State.LookLeft) { state = State.Scared; } }
public void SetChunkData(byte[] cData, Boolean isCompressed = true) { MemoryStream byteStream = new MemoryStream(); ZlibStream zStream = new ZlibStream(byteStream, CompressionMode.Decompress, CompressionLevel.BestCompression, true); zStream.Write(cData, 0, cData.Length); zStream.Flush(); zStream.Dispose(); zStream = null; byte[] bytes = byteStream.ToArray(); byteStream.Dispose(); byteStream = null; Block b; WorldLocation blockLoc; int x, y, z; // Block Types for (int i = 0; i < 32768; i++) { x = (Location.X * 16) + (i >> 11); y = i & 0x7F; z = (Location.Z * 16) + ((i & 0x780) >> 7); blockLoc = new WorldLocation(x, y, z); b = new Block((BlockType)bytes[i], blockLoc); Blocks.Add(b); } // TODO: Read and handle block/sky light and metadata bytes = null; }
public void WorldPositionTranslationTest() { WorldLocation location = new WorldLocation(3, 4, 5, 6, 7); WorldPosition position = new WorldPosition(location); Assert.AreEqual(position.SetTranslation(Microsoft.Xna.Framework.Vector3.One), position.SetTranslation(1, 1, 1)); }
internal ActivitySound(STFReader stf) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("ortsactsoundfile", () => { stf.MustMatchBlockStart(); string soundFile = stf.ReadString(); SoundFile = Path.Combine(FolderStructure.RouteFromActivity(stf.FileName).SoundFile(soundFile)); if (!EnumExtension.GetValue(stf.ReadString(), out OrtsActivitySoundFileType soundFileType)) { stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown activity sound file type " + stf.ReadString()); SoundFileType = OrtsActivitySoundFileType.None; } else { SoundFileType = soundFileType; } stf.MustMatchBlockEnd(); }), new STFReader.TokenProcessor("ortssoundlocation", () => { stf.MustMatchBlockStart(); location = new WorldLocation(stf.ReadInt(null), stf.ReadInt(null), stf.ReadFloat(STFReader.Units.None, null), stf.ReadFloat(STFReader.Units.None, null), stf.ReadFloat(STFReader.Units.None, null)); stf.MustMatchBlockEnd(); }), });
/// <summary> /// Draw all the available labels onto the screen (drawArea). /// </summary> /// <param name="drawArea">The area we are drawing on</param> public void Draw(DrawArea drawArea) { this.drawArea = drawArea; if (!Properties.Settings.Default.showLabels) { return; } float closestDistanceSquared = float.MaxValue; foreach (StorableLabel label in labels.Labels) { if (!dragging || !label.Equals(draggingLabelToReplace)) { DrawLabel(label); } float distanceSquared = WorldLocation.GetDistanceSquared2D(label.WorldLocation, drawArea.MouseLocation); if (distanceSquared < closestDistanceSquared) { closestDistanceSquared = distanceSquared; closestToMouseLabel = label; } } if (dragging) { DrawLabel(draggingLabel); } }
public void WorldLocationElevationTest() { WorldLocation location = new WorldLocation(0, 0, 0, 0, 0).SetElevation(123.4f); Assert.AreEqual(123.4f, location.Location.Y); location = location.ChangeElevation(-10.2f); Assert.AreEqual(113.2f, location.Location.Y, EqualityPrecisionDelta.FloatPrecisionDelta); }
void Enter() { WorldLocation loc = new WorldLocation(_siteLevel.MapID); loc.Relocate(_owner); _owner.TeleportTo(loc, TeleportToOptions.Seamless); }
private void SpawnMob(int x, int y, uint npcId, IWorldLocation dest) { Vector3 pos = new Vector3(dest.Position.X + (float)x, dest.Position.Y + (float)y); WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U); NPCMgr.GetEntry(npcId).SpawnAt((IWorldLocation)worldLocation, false).Brain.State = BrainState.Roam; }
/// <summary> /// Basic method to draw a line starting at a point between two points. /// Parameters are in world coordinates and sizes. /// </summary> /// <param name="width"> Width of the line to draw in meters </param> /// <param name="color"> Color of the line</param> /// <param name="point"> WorldLocation of the first point of the line (for zero offset)</param> /// <param name="length"> length of the line to draw in meters (also when shifted by offset)</param> /// <param name="angle"> Angle (in rad east of North)</param> /// <param name="lengthOffset">Instead of starting to draw at the given point, only start to draw a distance offset further along the line</param> public void DrawLine(float width, Color color, WorldLocation point, float length, float angle, float lengthOffset) { WorldLocation beginPoint; float sinAngle = (float)Math.Sin(angle); float cosAngle = (float)Math.Cos(angle); if (lengthOffset == 0) { beginPoint = point; } else { beginPoint = new WorldLocation(point); beginPoint.Location.X += lengthOffset * sinAngle; beginPoint.Location.Z += lengthOffset * cosAngle; } WorldLocation endPoint = new WorldLocation(beginPoint); //location of end-point endPoint.Location.X += length * sinAngle; endPoint.Location.Z += length * cosAngle; if (OutOfArea(beginPoint) && OutOfArea(endPoint)) { return; } // definition of rotation in ORTS is angle right of North // rotation in the window/draw area is angle right/south of right-horizontal // hence a 90 degree correction // To prevent double calculations, offset is already taken into account here BasicShapes.DrawLine(GetWindowSize(width), color, GetWindowVector(beginPoint), GetWindowSize(length), angle - MathHelper.Pi / 2); }
void InitializeVisualStalker() { Aura aura = GetHitAura(); if (aura != null) { WorldLocation dest = GetExplTargetDest(); if (dest != null) { int duration = GetSpellInfo().CalcDuration(GetOriginalCaster()); TempSummon summon = GetCaster().GetMap().SummonCreature(CreatureIds.HealingRainInvisibleStalker, dest, null, (uint)duration, GetOriginalCaster()); if (summon == null) { return; } summon.CastSpell(summon, SpellIds.HealingRainVisual, true); var script = aura.GetScript <spell_sha_healing_rain_AuraScript>(); if (script != null) { script.SetVisualDummy(summon); } } } }
/// <summary> /// Draw/print a string message on the draw area /// </summary> /// <param name="location">The world location acting as the starting point of the drawing</param> /// <param name="message">The message to print</param> public void DrawExpandingString(WorldLocation location, string message) { // We offset the top-left corner to make sure the text is not on the marker. int offsetXY = 2 + (int)GetWindowSize(2f); DrawExpandingString(location, message, offsetXY, offsetXY); }
/// <summary> /// Place the (3D) camera such that the 3D terrain is drawn in exactly the same location as the other 2D elements /// </summary> /// <param name="drawArea">The area to draw upon (with physical location to pixel transformations)</param> void UpdateCamera(DrawArea drawArea) { // We create a view and projection matrix to allow viewing the world/terrain from the top. // All Vertices will be in real-world locations relative to a certain reference location //Using Pi/2 for projection, the distance from camera to plane is the same as the half the distance from top to bottom in the screen. // // So if the vertex positions are real world-locations, the camera-target should be at (worldCenterX, 0, worldCenterZ). // The Cameraposition itself is (world-center-X, cam-height, world-centerZ) // where camheight is (worldHeight/2 = worldWidth/aspectRatio/2). // The distance of camera can be very large, so the backplane has to be set accordingly: cam-height/2 and cam-height*2. WorldLocation upperLeft = drawArea.LocationUpperLeft; WorldLocation lowerRight = drawArea.LocationLowerRight; Vector3 groundUpperLeft = locationTranslator.VertexPosition(upperLeft); Vector3 groundLowerRight = locationTranslator.VertexPosition(lowerRight); Vector3 cameraTarget = (groundUpperLeft + groundLowerRight) / 2; float width = groundLowerRight.X - groundUpperLeft.X; float camHeight = width / device.Viewport.AspectRatio / 2; Vector3 cameraPosition = cameraTarget; cameraPosition.Y = -camHeight; basicEffect.View = Matrix.CreateLookAt(cameraPosition, cameraTarget, new Vector3(0, 0, 1)); basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, device.Viewport.AspectRatio, camHeight / 2, camHeight * 2); }
public void drawRoad(Point p1, Point p2, WorldScene _World, int[,] _Grid, System.Drawing.Bitmap _Bitmap) { int dx = p1.X - p2.X; int dy = p1.Y - p2.Y; if (dx == 0) { dx = 1; } for (int x = p1.X; x <= p2.X; x++) { int y = (p1.Y + dy * (x - p1.X) / dx) + (int)(_World.Noise.Noise(x * 0.1, 64, 64) / 0.1); Point pt = new Point(x, y); WorldLocation wl = pt.ToWorldLocation(); try { _World.Chunks[wl.chunk.X, wl.chunk.Y].Tiles[wl.tile.X, wl.tile.Y].ID = 2; _Bitmap.SetPixel(x, y, System.Drawing.Color.Aqua); } catch (Exception) { } } }
/// <summary> /// Translate a World-Location to a Vertex position, without taking height into account. /// This means that we take the (cornerIndexX,0,cornerIndexZ) vector between the location and some (center of) a reference tile. /// </summary> /// <param name="location">Source World location</param> public Vector3 VertexPosition(WorldLocation location) { WorldLocation normalizedLocation = new WorldLocation(location); normalizedLocation.NormalizeTo(referenceTileX, referenceTileZ); return(new Vector3(normalizedLocation.Location.X, 0, normalizedLocation.Location.Z)); }
/// <summary> /// Draw (part of) a tracksection (either curved or straight) /// </summary> /// <param name="drawArea">Area to draw upon</param> /// <param name="tvs">The vectorSection itself that needs to be drawn</param> /// <param name="colors">Colorscheme to use</param> /// <param name="startOffset">Do not draw the first startOffset meters in the section</param> /// <param name="stopOffset">Do not draw past stopOffset meters (draw all if stopOffset less than 0)</param> /// <remarks>Note that his is very similar to DrawTrackSection in class DrawTrackDB, but this one allows to draw partial sections</remarks> private void DrawTrackSection(DrawArea drawArea, TrVectorSection tvs, ColorScheme colors, float startOffset, float stopOffset) { TrackSection trackSection = tsectionDat.TrackSections.Get(tvs.SectionIndex); if (trackSection == null) return; WorldLocation thisLocation = new WorldLocation(tvs.TileX, tvs.TileZ, tvs.X, 0, tvs.Z); if (trackSection.SectionCurve != null) { //curved section float radius = trackSection.SectionCurve.Radius; int sign = (trackSection.SectionCurve.Angle < 0) ? -1 : 1; float angleLength = (stopOffset < 0) ? trackSection.SectionCurve.Angle : sign*MathHelper.ToDegrees(stopOffset/radius); float angleStart = sign*MathHelper.ToDegrees(startOffset / radius); angleLength -= angleStart; drawArea.DrawArc(trackSection.SectionSize.Width, colors.TrackCurved, thisLocation, radius, tvs.AY, angleLength, angleStart); } else { // straight section float length = (stopOffset < 0) ? trackSection.SectionSize.Length : stopOffset; length -= startOffset; drawArea.DrawLine(trackSection.SectionSize.Width, colors.TrackStraight, thisLocation, length, tvs.AY, startOffset); } }
public Bitmap CropWorldLocation(Bitmap image, WorldLocation location) { Point point; Size size; switch (location) { case WorldLocation.Grift: size = TransformFrom1440p(CommonImageSize.LocationGriftText); point = TransformFrom1440p(CommonImageCoordinate.LocationGrift); break; case WorldLocation.Rift: size = TransformFrom1440p(CommonImageSize.LocationRiftLevel); point = TransformFrom1440p(CommonImageCoordinate.LocationRiftLevel); break; case WorldLocation.Menu: size = TransformFrom1440p(CommonImageSize.LocationMenu); point = TransformFrom1440p(CommonImageCoordinate.LocationMenuSymbol); break; case WorldLocation.LoadingScreen: size = TransformFrom1440p(CommonImageSize.LocationLoadingScreen); point = TransformFrom1440p(CommonImageCoordinate.LocationLoadingScreen); break; default: return(null); } return(ImageHelper.CropImage(image, new Rectangle(point, size))); }
/// <summary> /// Basic method to draw a dashed line between two points. Coordinates are in area coordinates. /// </summary> /// <param name="width"> Width of the line to draw in meters </param> /// <param name="color"> Color of the line</param> /// <param name="point1"> WorldLocation of the first point of the line</param> /// <param name="point2"> WorldLocation of to the last point of the line</param> public void DrawDashedLine(float width, Color color, WorldLocation point1, WorldLocation point2) { if (OutOfArea(point1) && OutOfArea(point2)) { return; } BasicShapes.DrawDashedLine(GetWindowSize(width), color, GetWindowVector(point1), GetWindowVector(point2)); }
/// <summary> /// Translate a WorldLocation to parent window coordinates /// </summary> /// <param name="location">location in World coordinates (including tiles)</param> /// <returns>location on the parent window in a 2d vector (in pixels)</returns> private Vector2 GetWindowVector(WorldLocation location) { Vector2 windowVector = GetAreaVector(location); windowVector.X += AreaOffsetX; windowVector.Y += AreaOffsetY; return(windowVector); }
internal static void ClearStack() { lock (World.SyncRoot) { stepStack.Clear(); desiredPos = new WorldLocation(World.RealPlayer.X, World.RealPlayer.Y, World.RealPlayer.Z); desiredDir = World.RealPlayer.Direction; sequence = 0; Debug.WriteLine("Step stack cleared.", "World"); } }
public Block(BlockType type, WorldLocation loc) { Type = type; Location = loc; }
private void HandlePlayerBlockPlacement(Client client, PlayerBlockPlacementPacket packet) { // TODO: Check if player is close enough to place the block; check if player is placing on top of another block, etc. if (packet.Amount >= 0 && packet.BlockID > 0 && packet.BlockID <= 121) { int placeX = packet.X; int placeY = packet.Y; int placeZ = packet.Z; switch (packet.Direction) { case 0: placeY--; break; case 1: placeY++; break; case 2: placeZ--; break; case 3: placeZ++; break; case 4: placeX--; break; case 5: placeX++; break; } WorldLocation bLoc = new WorldLocation(placeX, placeY, placeZ); Nullable<Block> nb = Server.GetWorldManager().GetWorld(0).GetBlock(bLoc); if (nb != null) { Block b = (Block)nb; b.SetBlockType((BlockType)packet.BlockID); Server.OnBlockChange(b); } } }