Core/Movement: waypoint movement
Port From (https://github.com/TrinityCore/TrinityCore/commit/97585597f0b1aff93873fe4d757556731bc0c1b2)
This commit is contained in:
@@ -105,6 +105,21 @@ namespace Game.Entities
|
||||
ForcedDespawn(0);
|
||||
}
|
||||
|
||||
public override void PauseMovement(uint timer = 0, MovementSlot slot = 0)
|
||||
{
|
||||
base.PauseMovement(timer, slot);
|
||||
|
||||
SetHomePosition(GetPosition());
|
||||
}
|
||||
|
||||
public bool IsReturningHome()
|
||||
{
|
||||
if (GetMotionMaster().GetMotionSlotType(MovementSlot.Active) == MovementGeneratorType.Home)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SearchFormation()
|
||||
{
|
||||
if (IsSummon())
|
||||
@@ -119,6 +134,33 @@ namespace Game.Entities
|
||||
FormationMgr.AddCreatureToGroup(frmdata.leaderGUID, this);
|
||||
}
|
||||
|
||||
public bool IsFormationLeader()
|
||||
{
|
||||
if (m_formation == null)
|
||||
return false;
|
||||
|
||||
return m_formation.IsLeader(this);
|
||||
}
|
||||
|
||||
public void SignalFormationMovement(Position destination, uint id = 0, WaypointMoveType moveType = 0, bool orientation = false)
|
||||
{
|
||||
if (m_formation == null)
|
||||
return;
|
||||
|
||||
if (!m_formation.IsLeader(this))
|
||||
return;
|
||||
|
||||
m_formation.LeaderMoveTo(destination, id, moveType, orientation);
|
||||
}
|
||||
|
||||
public bool IsFormationLeaderMoveAllowed()
|
||||
{
|
||||
if (m_formation == null)
|
||||
return false;
|
||||
|
||||
return m_formation.CanLeaderStartMoving();
|
||||
}
|
||||
|
||||
public void RemoveCorpse(bool setSpawnTime = true, bool destroyForNearbyPlayers = true)
|
||||
{
|
||||
if (GetDeathState() != DeathState.Corpse)
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Game.Entities
|
||||
m_Formed = !dismiss;
|
||||
}
|
||||
|
||||
public void LeaderMoveTo(Position destination, uint id = 0, uint moveType = 0, bool orientation = false)
|
||||
public void LeaderMoveTo(Position destination, uint id = 0, WaypointMoveType moveType = 0, bool orientation = false)
|
||||
{
|
||||
//! To do: This should probably get its own movement generator or use WaypointMovementGenerator.
|
||||
//! If the leader's path is known, member's path can be plotted as well using formation offsets.
|
||||
@@ -258,11 +258,26 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanLeaderStartMoving()
|
||||
{
|
||||
foreach (var itr in m_members)
|
||||
{
|
||||
if (itr.Key != m_leader && itr.Key.IsAlive())
|
||||
{
|
||||
if (itr.Key.IsEngaged() || itr.Key.IsReturningHome())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Creature GetLeader() { return m_leader; }
|
||||
public uint GetId() { return m_groupID; }
|
||||
public bool IsEmpty() { return m_members.Empty(); }
|
||||
public bool IsFormed() { return m_Formed; }
|
||||
|
||||
public bool IsLeader(Creature creature) { return m_leader == creature; }
|
||||
|
||||
Creature m_leader;
|
||||
Dictionary<Creature, FormationInfo> m_members = new Dictionary<Creature, FormationInfo>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user