/// <summary> /// Called right after a player makes a destination movement. /// </summary> public void OnPlayerMovement(SRPlayer player) { if (inTrace) { Window w = Window.Get; if (TracePlayerName.Equals(player.Name, StringComparison.OrdinalIgnoreCase) || InfoManager.inParty && w.Training_cbxTraceMaster.Checked && InfoManager.Party.Master.Name == player.Name && InfoManager.isEntityNear(player.UniqueID)) { byte distance = 0; if (w.Training_cbxTraceDistance.Checked) { w.Training_tbxTraceDistance.InvokeIfRequired(() => { distance = byte.Parse(w.Training_tbxTraceDistance.Text); }); } // Follow blind movement SRCoord Q = player.MovementPosition; if (distance > 0) { SRCoord P = InfoManager.Character.GetRealtimePosition(); double PQMod = P.DistanceTo(Q); if (distance < PQMod) { SRCoord PQUnit = new SRCoord((Q.PosX - P.PosX) / PQMod, (Q.PosY - P.PosY) / PQMod); SRCoord NewPositon; if (P.inDungeon()) { NewPositon = new SRCoord((PQMod - distance) * PQUnit.PosX + P.PosX, (PQMod - distance) * PQUnit.PosY + P.PosY, P.Region, P.Z); } else { NewPositon = new SRCoord((PQMod - distance) * PQUnit.PosX + P.PosX, (PQMod - distance) * PQUnit.PosY + P.PosY); } MoveTo(NewPositon); w.LogProcess("Tracing to [" + player.Name + "] ..."); } } else { MoveTo(Q); w.LogProcess("Tracing to [" + player.Name + "] ..."); } } } }
/// <summary> /// Set the camera center, all map is updated after that. /// Invoke not required. /// </summary> public void SetView(SRCoord ViewPoint) { if (!m_ViewPoint.Equals(ViewPoint)) { // Update layer if (m_ViewPoint.Region != ViewPoint.Region && ViewPoint.inDungeon()) { SelectMapLayer(ViewPoint.Region); RemoveTiles(); m_ViewPoint = ViewPoint; } else { m_ViewPoint = ViewPoint; ClearTiles(); } UpdateTiles(); } UpdateMarkerLocations(); }
public override SRCoord GetRealtimePosition() { if (MovementPosition != null) { SRCoord P = Position; SRCoord Q = MovementPosition; // Check if it's updated.. if (!P.Equals(Q)) { // Scale 1920units:192px = 10:1 => To Ms double MilisecondsPerUnit = GetMovementSpeed(); // Checking update times! long milisecondsTranscurred = PositionUpdateTimer.ElapsedMilliseconds; long milisecondsMaximum = P.TimeTo(Q, MilisecondsPerUnit); if (milisecondsTranscurred >= milisecondsMaximum) { // The entity has reached the position long ago Position = Q; } else { // Create vector unit double PQMod = P.DistanceTo(Q); SRCoord PQUnit = new SRCoord((Q.PosX - P.PosX) / PQMod, (Q.PosY - P.PosY) / PQMod); double DistanceTillNow = milisecondsTranscurred * MilisecondsPerUnit; if (P.inDungeon()) { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY, P.Region, P.Z); } else { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY); } } PositionUpdateTimer.Restart(); } } return(Position); }