Core/Creatures: add TimeSpan to TempSummon
Port From (https://github.com/TrinityCore/TrinityCore/commit/1dd4b38170339e2d1d959c45ecad1b3b8dceb216)
This commit is contained in:
@@ -1544,7 +1544,7 @@ namespace Game.Entities
|
||||
Map map = GetMap();
|
||||
if (map != null)
|
||||
{
|
||||
TempSummon summon = map.SummonCreature(entry, pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner);
|
||||
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, this, spellId, vehId, privateObjectOwner);
|
||||
if (summon != null)
|
||||
{
|
||||
summon.SetTempSummonType(despawnType);
|
||||
@@ -1560,7 +1560,7 @@ namespace Game.Entities
|
||||
Map map = GetMap();
|
||||
if (map != null)
|
||||
{
|
||||
TempSummon summon = map.SummonCreature(GetEntry(), pos, null, (uint)despawnTime.TotalMilliseconds, privateObjectOwner, spellId, vehId, privateObjectOwner.GetGUID(), new SmoothPhasingInfo(GetGUID(), true, true));
|
||||
TempSummon summon = map.SummonCreature(GetEntry(), pos, null, despawnTime, privateObjectOwner, spellId, vehId, privateObjectOwner.GetGUID(), new SmoothPhasingInfo(GetGUID(), true, true));
|
||||
if (summon != null)
|
||||
{
|
||||
summon.SetTempSummonType(despawnType);
|
||||
@@ -1648,7 +1648,7 @@ namespace Game.Entities
|
||||
|
||||
foreach (var tempSummonData in data)
|
||||
{
|
||||
TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, TimeSpan.FromMilliseconds(tempSummonData.time));
|
||||
TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, tempSummonData.time);
|
||||
if (summon)
|
||||
list.Add(summon);
|
||||
}
|
||||
|
||||
@@ -1239,7 +1239,7 @@ namespace Game.Entities
|
||||
petSpells.PetGUID = vehicle.GetGUID();
|
||||
petSpells.CreatureFamily = 0; // Pet Family (0 for all vehicles)
|
||||
petSpells.Specialization = 0;
|
||||
petSpells.TimeLimit = vehicle.IsSummon() ? vehicle.ToTempSummon().GetTimer() : 0;
|
||||
petSpells.TimeLimit = (uint)(vehicle.IsSummon() ? vehicle.ToTempSummon().GetTimer().TotalMilliseconds : 0);
|
||||
petSpells.ReactState = vehicle.GetReactState();
|
||||
petSpells.CommandState = CommandStates.Follow;
|
||||
petSpells.Flag = 0x8;
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace Game.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
TimeSpan msDiff = TimeSpan.FromMilliseconds(diff);
|
||||
switch (m_type)
|
||||
{
|
||||
case TempSummonType.ManualDespawn:
|
||||
@@ -67,26 +68,26 @@ namespace Game.Entities
|
||||
break;
|
||||
case TempSummonType.TimedDespawn:
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_timer <= msDiff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
m_timer -= msDiff;
|
||||
break;
|
||||
}
|
||||
case TempSummonType.TimedDespawnOutOfCombat:
|
||||
{
|
||||
if (!IsInCombat())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_timer <= msDiff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
m_timer -= msDiff;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
@@ -98,13 +99,13 @@ namespace Game.Entities
|
||||
{
|
||||
if (m_deathState == DeathState.Corpse)
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_timer <= msDiff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_timer -= diff;
|
||||
m_timer -= msDiff;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -129,13 +130,13 @@ namespace Game.Entities
|
||||
|
||||
if (!IsInCombat())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_timer <= msDiff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
m_timer -= msDiff;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
@@ -145,13 +146,13 @@ namespace Game.Entities
|
||||
{
|
||||
if (!IsInCombat() && IsAlive())
|
||||
{
|
||||
if (m_timer <= diff)
|
||||
if (m_timer <= msDiff)
|
||||
{
|
||||
UnSummon();
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_timer -= diff;
|
||||
m_timer -= msDiff;
|
||||
}
|
||||
else if (m_timer != m_lifetime)
|
||||
m_timer = m_lifetime;
|
||||
@@ -164,7 +165,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void InitStats(WorldObject summoner, uint duration)
|
||||
public virtual void InitStats(WorldObject summoner, TimeSpan duration)
|
||||
{
|
||||
Cypher.Assert(!IsPet());
|
||||
|
||||
@@ -172,7 +173,7 @@ namespace Game.Entities
|
||||
m_lifetime = duration;
|
||||
|
||||
if (m_type == TempSummonType.ManualDespawn)
|
||||
m_type = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
|
||||
m_type = (duration == TimeSpan.Zero) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
|
||||
|
||||
if (summoner != null && summoner.IsPlayer())
|
||||
{
|
||||
@@ -363,7 +364,7 @@ namespace Game.Entities
|
||||
|
||||
TempSummonType GetSummonType() { return m_type; }
|
||||
|
||||
public uint GetTimer() { return m_timer; }
|
||||
public TimeSpan GetTimer() { return m_timer; }
|
||||
|
||||
public uint? GetCreatureIdVisibleToSummoner() { return m_creatureIdVisibleToSummoner; }
|
||||
public uint? GetDisplayIdVisibleToSummoner() { return m_displayIdVisibleToSummoner; }
|
||||
@@ -373,8 +374,8 @@ namespace Game.Entities
|
||||
|
||||
public SummonPropertiesRecord m_Properties;
|
||||
TempSummonType m_type;
|
||||
uint m_timer;
|
||||
uint m_lifetime;
|
||||
TimeSpan m_timer;
|
||||
TimeSpan m_lifetime;
|
||||
ObjectGuid m_summonerGUID;
|
||||
uint? m_creatureIdVisibleToSummoner;
|
||||
uint? m_displayIdVisibleToSummoner;
|
||||
@@ -394,7 +395,7 @@ namespace Game.Entities
|
||||
InitCharmInfo();
|
||||
}
|
||||
|
||||
public override void InitStats(WorldObject summoner, uint duration)
|
||||
public override void InitStats(WorldObject summoner, TimeSpan duration)
|
||||
{
|
||||
base.InitStats(summoner, duration);
|
||||
|
||||
@@ -488,7 +489,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitStats(WorldObject summoner, uint duration)
|
||||
public override void InitStats(WorldObject summoner, TimeSpan duration)
|
||||
{
|
||||
base.InitStats(summoner, duration);
|
||||
|
||||
@@ -1085,7 +1086,7 @@ namespace Game.Entities
|
||||
UnitTypeMask |= UnitTypeMask.Puppet;
|
||||
}
|
||||
|
||||
public override void InitStats(WorldObject summoner, uint duration)
|
||||
public override void InitStats(WorldObject summoner, TimeSpan duration)
|
||||
{
|
||||
base.InitStats(summoner, duration);
|
||||
|
||||
@@ -1135,7 +1136,7 @@ namespace Game.Entities
|
||||
public uint entry; // Entry of summoned creature
|
||||
public Position pos; // Position, where should be creature spawned
|
||||
public TempSummonType type; // Summon type, see TempSummonType for available types
|
||||
public uint time; // Despawn time, usable only with certain temp summon types
|
||||
public TimeSpan time; // Despawn time, usable only with certain temp summon types
|
||||
}
|
||||
|
||||
enum PetEntry
|
||||
|
||||
@@ -26,18 +26,19 @@ namespace Game.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_duration <= diff)
|
||||
if (m_duration <= TimeSpan.FromMilliseconds(diff))
|
||||
{
|
||||
UnSummon(); // remove self
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_duration -= diff;
|
||||
|
||||
m_duration -= TimeSpan.FromMilliseconds(diff);
|
||||
|
||||
base.Update(diff);
|
||||
|
||||
}
|
||||
|
||||
public override void InitStats(WorldObject summoner, uint duration)
|
||||
public override void InitStats(WorldObject summoner, TimeSpan duration)
|
||||
{
|
||||
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
|
||||
Player owner = GetOwner().ToPlayer();
|
||||
@@ -156,9 +157,9 @@ namespace Game.Entities
|
||||
|
||||
public uint GetSpell(byte slot = 0) { return m_spells[slot]; }
|
||||
|
||||
public uint GetTotemDuration() { return m_duration; }
|
||||
public TimeSpan GetTotemDuration() { return m_duration; }
|
||||
|
||||
public void SetTotemDuration(uint duration) { m_duration = duration; }
|
||||
public void SetTotemDuration(TimeSpan duration) { m_duration = duration; }
|
||||
|
||||
public TotemType GetTotemType() { return m_type; }
|
||||
|
||||
@@ -174,7 +175,7 @@ namespace Game.Entities
|
||||
public override void UpdateDamagePhysical(WeaponAttackType attType) { }
|
||||
|
||||
TotemType m_type;
|
||||
uint m_duration;
|
||||
TimeSpan m_duration;
|
||||
}
|
||||
|
||||
public enum TotemType
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace Game.Entities
|
||||
return go;
|
||||
}
|
||||
|
||||
public TempSummon SummonPassenger(uint entry, Position pos, TempSummonType summonType, SummonPropertiesRecord properties = null, uint duration = 0, Unit summoner = null, uint spellId = 0, uint vehId = 0)
|
||||
public TempSummon SummonPassenger(uint entry, Position pos, TempSummonType summonType, SummonPropertiesRecord properties = null, TimeSpan duration = default, Unit summoner = null, uint spellId = 0, uint vehId = 0)
|
||||
{
|
||||
Map map = GetMap();
|
||||
if (map == null)
|
||||
|
||||
Reference in New Issue
Block a user