Core/Vehicle: Change vehicle accessories' phase according to the player on the vehicle

Port From (https://github.com/TrinityCore/TrinityCore/commit/6d5086da1747816e1a4e8518e16ab1923de22e1a)
This commit is contained in:
hondacrx
2022-01-02 19:54:18 -05:00
parent 418289e41c
commit 9e61335fe8
2 changed files with 30 additions and 1 deletions
+13 -1
View File
@@ -37,7 +37,8 @@ namespace Game
for (var i = 0; i < unit.m_Controlled.Count; ++i)
{
Unit controlled = unit.m_Controlled[i];
if (controlled.GetTypeId() != TypeId.Player)
if (controlled.GetTypeId() != TypeId.Player
&& controlled.GetVehicle() == null) // Player inside nested vehicle should not phase the root vehicle and its accessories (only direct root vehicle control does)
func(controlled);
}
@@ -50,6 +51,17 @@ namespace Game
func(summon);
}
}
Vehicle vehicle = unit.GetVehicleKit();
if (vehicle != null)
{
foreach (var seat in vehicle.Seats)
{
Unit passenger = Global.ObjAccessor.GetUnit(unit, seat.Value.Passenger.Guid);
if (passenger != null)
func(passenger);
}
}
}
public static void AddPhase(WorldObject obj, uint phaseId, bool updateVisibility)