Convert alot of methods to use TimeSpan.

This commit is contained in:
hondacrx
2022-03-01 23:47:53 -05:00
parent 6f1b2f5cd5
commit 042bfc12e5
31 changed files with 143 additions and 127 deletions
+5 -5
View File
@@ -322,7 +322,7 @@ namespace Game.AI
return true;
}
public CypherStrings VisualizeBoundary(int duration, Unit owner = null, bool fill = false)
public CypherStrings VisualizeBoundary(TimeSpan duration, Unit owner = null, bool fill = false)
{
if (!owner)
return 0;
@@ -380,7 +380,7 @@ namespace Game.AI
if (fill || hasOutOfBoundsNeighbor)
{
var pos = new Position(startPosition.GetPositionX() + front.Key * SharedConst.BoundaryVisualizeStepSize, startPosition.GetPositionY() + front.Value * SharedConst.BoundaryVisualizeStepSize, spawnZ);
TempSummon point = owner.SummonCreature(SharedConst.BoundaryVisualizeCreature, pos, TempSummonType.TimedDespawn, (uint)(duration * Time.InMilliseconds));
TempSummon point = owner.SummonCreature(SharedConst.BoundaryVisualizeCreature, pos, TempSummonType.TimedDespawn, duration);
if (point)
{
point.SetObjectScale(SharedConst.BoundaryVisualizeCreatureScale);
@@ -417,18 +417,18 @@ namespace Game.AI
}
}
public Creature DoSummon(uint entry, Position pos, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
public Creature DoSummon(uint entry, Position pos, TimeSpan despawnTime, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
{
return me.SummonCreature(entry, pos, summonType, despawnTime);
}
public Creature DoSummon(uint entry, WorldObject obj, float radius = 5.0f, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
public Creature DoSummon(uint entry, WorldObject obj, float radius = 5.0f, TimeSpan despawnTime = default, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
{
Position pos = obj.GetRandomNearPosition(radius);
return me.SummonCreature(entry, pos, summonType, despawnTime);
}
public Creature DoSummonFlyer(uint entry, WorldObject obj, float flightZ, float radius = 5.0f, uint despawnTime = 30000, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
public Creature DoSummonFlyer(uint entry, WorldObject obj, float flightZ, float radius = 5.0f, TimeSpan despawnTime = default, TempSummonType summonType = TempSummonType.CorpseTimedDespawn)
{
Position pos = obj.GetRandomNearPosition(radius);
pos.posZ += flightZ;
+2 -4
View File
@@ -259,7 +259,7 @@ namespace Game.AI
}
//Spawns a creature relative to me
public Creature DoSpawnCreature(uint entry, float offsetX, float offsetY, float offsetZ, float angle, TempSummonType type, uint despawntime)
public Creature DoSpawnCreature(uint entry, float offsetX, float offsetY, float offsetZ, float angle, TempSummonType type, TimeSpan despawntime)
{
return me.SummonCreature(entry, me.GetPositionX() + offsetX, me.GetPositionY() + offsetY, me.GetPositionZ() + offsetZ, angle, type, despawntime);
}
@@ -639,8 +639,6 @@ namespace Game.AI
DoMeleeAttackIfReady();
}
public void _DespawnAtEvade(uint delayToRespawn = 30, Creature who = null) { _DespawnAtEvade(TimeSpan.FromSeconds(delayToRespawn), who); }
public void _DespawnAtEvade(TimeSpan delayToRespawn, Creature who = null)
{
if (delayToRespawn < TimeSpan.FromSeconds(2))
@@ -660,7 +658,7 @@ namespace Game.AI
return;
}
who.DespawnOrUnsummon(0, delayToRespawn);
who.DespawnOrUnsummon(TimeSpan.Zero, delayToRespawn);
if (instance != null && who == me)
instance.SetBossState(_bossId, EncounterState.Fail);
+13 -13
View File
@@ -29,7 +29,7 @@ namespace Game.AI
{
public EscortAI(Creature creature) : base(creature)
{
_pauseTimer = 2500;
_pauseTimer = TimeSpan.FromSeconds(2.5);
_playerCheckTimer = 1000;
_maxPlayerDistance = 100;
_activeAttacker = true;
@@ -118,7 +118,7 @@ namespace Game.AI
SetCombatMovement(true);
//add a small delay before going to first waypoint, normal in near all cases
_pauseTimer = 2000;
_pauseTimer = TimeSpan.FromSeconds(2);
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
me.RestoreFaction();
@@ -182,11 +182,11 @@ namespace Game.AI
//Waypoint Updating
if (HasEscortState(EscortState.Escorting) && !me.IsEngaged() && !HasEscortState(EscortState.Returning))
{
if (_pauseTimer <= diff)
if (_pauseTimer.TotalMilliseconds <= diff)
{
if (!HasEscortState(EscortState.Paused))
{
_pauseTimer = 0;
_pauseTimer = TimeSpan.Zero;
if (_ended)
{
@@ -231,7 +231,7 @@ namespace Game.AI
}
}
else
_pauseTimer -= diff;
_pauseTimer -= TimeSpan.FromMilliseconds(diff);
}
@@ -252,7 +252,7 @@ namespace Game.AI
if (_instantRespawn)
{
if (!isEscort)
me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(1));
me.DespawnOrUnsummon(TimeSpan.Zero, TimeSpan.FromSeconds(1));
else
me.GetMap().Respawn(SpawnObjectType.Creature, me.GetSpawnId());
}
@@ -288,8 +288,8 @@ namespace Game.AI
//Combat start position reached, continue waypoint movement
if (moveType == MovementGeneratorType.Point)
{
if (_pauseTimer == 0)
_pauseTimer = 2000;
if (_pauseTimer == TimeSpan.Zero)
_pauseTimer = TimeSpan.FromSeconds(2);
if (Id == EscortPointIds.LastPoint)
{
@@ -317,12 +317,12 @@ namespace Game.AI
{
_started = false;
_ended = true;
_pauseTimer = 1000;
_pauseTimer = TimeSpan.FromSeconds(1);
}
}
}
public void AddWaypoint(uint id, float x, float y, float z, float orientation = 0, uint waitTime = 0)
public void AddWaypoint(uint id, float x, float y, float z, float orientation, TimeSpan waitTime)
{
GridDefines.NormalizeMapCoord(ref x);
GridDefines.NormalizeMapCoord(ref y);
@@ -334,7 +334,7 @@ namespace Game.AI
waypoint.z = z;
waypoint.orientation = orientation;
waypoint.moveType = _running ? WaypointMoveType.Run : WaypointMoveType.Walk;
waypoint.delay = waitTime;
waypoint.delay = (uint)waitTime.TotalMilliseconds;
waypoint.eventId = 0;
waypoint.eventChance = 100;
_path.nodes.Add(waypoint);
@@ -456,7 +456,7 @@ namespace Game.AI
}
}
void SetPauseTimer(uint Timer) { _pauseTimer = Timer; }
public void SetPauseTimer(TimeSpan timer) { _pauseTimer = timer; }
public bool HasEscortState(EscortState escortState) { return (_escortState & escortState) != 0; }
public override bool IsEscorted() { return !_playerGUID.IsEmpty(); }
@@ -476,7 +476,7 @@ namespace Game.AI
void RemoveEscortState(EscortState escortState) { _escortState &= ~escortState; }
ObjectGuid _playerGUID;
uint _pauseTimer;
TimeSpan _pauseTimer;
uint _playerCheckTimer;
EscortState _escortState;
float _maxPlayerDistance;
+5 -5
View File
@@ -1185,7 +1185,7 @@ namespace Game.AI
y += e.Target.y;
z += e.Target.z;
o += e.Target.o;
Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner);
Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner);
if (summon != null)
if (e.Action.summonCreature.attackInvoker != 0)
summon.GetAI().AttackStart(target.ToUnit());
@@ -1194,7 +1194,7 @@ namespace Game.AI
if (e.GetTargetType() != SmartTargets.Position)
break;
Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, privateObjectOwner);
Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner);
if (summon1 != null)
if (unit != null && e.Action.summonCreature.attackInvoker != 0)
summon1.GetAI().AttackStart(unit);
@@ -1210,14 +1210,14 @@ namespace Game.AI
{
Position pos = target.GetPositionWithOffset(new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o));
Quaternion rot = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(pos.GetOrientation(), 0f, 0f));
summoner.SummonGameObject(e.Action.summonGO.entry, pos, rot, e.Action.summonGO.despawnTime, (GameObjectSummonType)e.Action.summonGO.summonType);
summoner.SummonGameObject(e.Action.summonGO.entry, pos, rot, TimeSpan.FromSeconds(e.Action.summonGO.despawnTime), (GameObjectSummonType)e.Action.summonGO.summonType);
}
if (e.GetTargetType() != SmartTargets.Position)
break;
Quaternion _rot = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(e.Target.o, 0f, 0f));
summoner.SummonGameObject(e.Action.summonGO.entry, new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), _rot, e.Action.summonGO.despawnTime, (GameObjectSummonType)e.Action.summonGO.summonType);
summoner.SummonGameObject(e.Action.summonGO.entry, new Position(e.Target.x, e.Target.y, e.Target.z, e.Target.o), _rot, TimeSpan.FromSeconds(e.Action.summonGO.despawnTime), (GameObjectSummonType)e.Action.summonGO.summonType);
break;
}
case SmartActions.KillUnit:
@@ -2473,7 +2473,7 @@ namespace Game.AI
void doCreatePersonalClone(Position position, Unit owner)
{
ObjectGuid privateObjectOwner = owner.GetGUID();
Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, e.Action.becomePersonalClone.duration, 0, 0, privateObjectOwner);
Creature summon = GetBaseObject().SummonPersonalClone(position, (TempSummonType)e.Action.becomePersonalClone.type, TimeSpan.FromMilliseconds(e.Action.becomePersonalClone.duration), 0, 0, privateObjectOwner);
if (summon != null)
if (IsSmart(summon))
((SmartAI)summon.GetAI()).SetTimedActionList(e, (uint)e.EntryOrGuid, owner, e.EventId + 1);
@@ -407,10 +407,10 @@ namespace Game.BattleGrounds
// create remind invite events
BGQueueInviteEvent inviteEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, (ArenaTypes)m_queueId.TeamSize, ginfo.RemoveInviteTime);
m_events.AddEvent(inviteEvent, m_events.CalculateTime(BattlegroundConst.InvitationRemindTime));
m_events.AddEvent(inviteEvent, m_events.CalculateTime(TimeSpan.FromMilliseconds(BattlegroundConst.InvitationRemindTime)));
// create automatic remove events
BGQueueRemoveEvent removeEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo.RemoveInviteTime);
m_events.AddEvent(removeEvent, m_events.CalculateTime(BattlegroundConst.InviteAcceptWaitTime));
m_events.AddEvent(removeEvent, m_events.CalculateTime(TimeSpan.FromMilliseconds(BattlegroundConst.InviteAcceptWaitTime)));
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
+6 -4
View File
@@ -93,10 +93,12 @@ namespace Game.Chat
string fill_str = args.NextString();
string duration_str = args.NextString();
if (!int.TryParse(duration_str, out int duration))
duration = -1;
if (duration <= 0 || duration >= 30 * Time.Minute) // arbitary upper limit
duration = 3 * Time.Minute;
if (!int.TryParse(duration_str, out int tempDuration))
tempDuration = 0;
TimeSpan duration = TimeSpan.FromSeconds(tempDuration);
if (duration <= TimeSpan.Zero || duration >= TimeSpan.FromMinutes(30)) // arbitary upper limit
duration = TimeSpan.FromMinutes(3);
bool doFill = fill_str.ToLower().Equals("fill");
@@ -645,10 +645,10 @@ namespace Game.Chat
Player player = handler.GetPlayer();
uint spawntime = args.NextUInt32();
uint spawntm = 300;
TimeSpan spawntm = TimeSpan.FromSeconds(300);
if (spawntime != 0)
spawntm = spawntime;
spawntm = TimeSpan.FromSeconds(spawntime);
Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f));
if (Global.ObjectMgr.GetGameObjectTemplate(id) == null)
+2 -1
View File
@@ -20,6 +20,7 @@ using Framework.IO;
using Game.Entities;
using Game.Maps;
using Game.Movement;
using System;
using System.Collections.Generic;
namespace Game.Chat
@@ -84,7 +85,7 @@ namespace Game.Chat
handler.SendSysMessage("Enable GM mode to see the path points.");
for (uint i = 0; i < pointPath.Length; ++i)
player.SummonCreature(1, pointPath[i].X, pointPath[i].Y, pointPath[i].Z, 0, TempSummonType.TimedDespawn, 9000);
player.SummonCreature(1, pointPath[i].X, pointPath[i].Y, pointPath[i].Z, 0, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(9));
return true;
}
+1 -1
View File
@@ -858,7 +858,7 @@ namespace Game.Chat
return false;
Player chr = handler.GetSession().GetPlayer();
chr.SummonCreature(id, chr, loot ? TempSummonType.CorpseTimedDespawn : TempSummonType.CorpseDespawn, 30 * Time.InMilliseconds);
chr.SummonCreature(id, chr, loot ? TempSummonType.CorpseTimedDespawn : TempSummonType.CorpseDespawn, TimeSpan.FromSeconds(30));
return true;
}
+2 -2
View File
@@ -58,10 +58,10 @@ namespace Game.Combat
if (a.HasUnitState(UnitState.InFlight) || b.HasUnitState(UnitState.InFlight))
return false;
Creature aCreature = a.ToCreature();
if (aCreature?.IsCombatDisallowed())
if (aCreature != null && aCreature.IsCombatDisallowed())
return false;
Creature bCreature = b.ToCreature();
if (bCreature?.IsCombatDisallowed())
if (bCreature != null && bCreature.IsCombatDisallowed())
return false;
if (a.IsFriendlyTo(b) || b.IsFriendlyTo(a))
return false;
@@ -1035,7 +1035,7 @@ namespace Game.Entities
Player player = caster.ToPlayer();
if (player)
if (player.IsDebugAreaTriggers)
player.SummonCreature(1, this, TempSummonType.TimedDespawn, GetTimeToTarget());
player.SummonCreature(1, this, TempSummonType.TimedDespawn, TimeSpan.FromMilliseconds(GetTimeToTarget()));
}
}
+7 -9
View File
@@ -1959,7 +1959,7 @@ namespace Game.Entities
{
if (timeMSToDespawn != 0)
{
m_Events.AddEvent(new ForcedDespawnDelayEvent(this, forceRespawnTimer), m_Events.CalculateTime(timeMSToDespawn));
m_Events.AddEvent(new ForcedDespawnDelayEvent(this, forceRespawnTimer), m_Events.CalculateTime(TimeSpan.FromMilliseconds(timeMSToDespawn)));
return;
}
@@ -2008,15 +2008,13 @@ namespace Game.Entities
}
}
public void DespawnOrUnsummon(TimeSpan time, TimeSpan forceRespawnTimer = default) { DespawnOrUnsummon((uint)time.TotalMilliseconds, forceRespawnTimer); }
public void DespawnOrUnsummon(uint msTimeToDespawn = 0, TimeSpan forceRespawnTimer = default)
public void DespawnOrUnsummon(TimeSpan msTimeToDespawn = default, TimeSpan forceRespawnTimer = default)
{
TempSummon summon = ToTempSummon();
if (summon != null)
summon.UnSummon(msTimeToDespawn);
summon.UnSummon((uint)msTimeToDespawn.TotalMilliseconds);
else
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
ForcedDespawn((uint)msTimeToDespawn.TotalMilliseconds, forceRespawnTimer);
}
public void LoadTemplateImmunities()
@@ -2167,7 +2165,7 @@ namespace Game.Entities
e.AddAssistant(assistList.First().GetGUID());
assistList.Remove(assistList.First());
}
m_Events.AddEvent(e, m_Events.CalculateTime(WorldConfig.GetUIntValue(WorldCfg.CreatureFamilyAssistanceDelay)));
m_Events.AddEvent(e, m_Events.CalculateTime(TimeSpan.FromMilliseconds(WorldConfig.GetUIntValue(WorldCfg.CreatureFamilyAssistanceDelay))));
}
}
}
@@ -3098,7 +3096,7 @@ namespace Game.Entities
{
return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard);
}
bool IsCombatDisallowed()
public bool IsCombatDisallowed()
{
return GetCreatureTemplate().FlagsExtra.HasFlag(CreatureFlagsExtra.NoCombat);
}
@@ -3404,7 +3402,7 @@ namespace Game.Entities
}
public override bool Execute(ulong e_time, uint p_time)
{
m_owner.DespawnOrUnsummon(0, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime
m_owner.DespawnOrUnsummon(TimeSpan.Zero, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime
return true;
}
+12 -12
View File
@@ -1415,7 +1415,7 @@ namespace Game.Entities
return null;
}
public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, ObjectGuid privateObjectOwner = default)
public TempSummon SummonCreature(uint entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, ObjectGuid privateObjectOwner = default)
{
if (x == 0.0f && y == 0.0f && z == 0.0f)
GetClosePoint(out x, out y, out z, GetCombatReach());
@@ -1426,12 +1426,12 @@ namespace Game.Entities
return SummonCreature(entry, new Position(x, y, z, o), despawnType, despawnTime, 0, 0, privateObjectOwner);
}
public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
public TempSummon SummonCreature(uint entry, Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
{
Map map = GetMap();
if (map != null)
{
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, this, spellId, vehId, privateObjectOwner);
TempSummon summon = map.SummonCreature(entry, pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner);
if (summon != null)
{
summon.SetTempSummonType(despawnType);
@@ -1442,12 +1442,12 @@ namespace Game.Entities
return null;
}
public TempSummon SummonPersonalClone(Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, uint despawnTime = 0, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
public TempSummon SummonPersonalClone(Position pos, TempSummonType despawnType = TempSummonType.ManualDespawn, TimeSpan despawnTime = default, uint vehId = 0, uint spellId = 0, ObjectGuid privateObjectOwner = default)
{
Map map = GetMap();
if (map != null)
{
TempSummon summon = map.SummonCreature(GetEntry(), pos, null, despawnTime, this, spellId, vehId, privateObjectOwner);
TempSummon summon = map.SummonCreature(GetEntry(), pos, null, (uint)despawnTime.TotalMilliseconds, this, spellId, vehId, privateObjectOwner);
if (summon != null)
{
summon.SetTempSummonType(despawnType);
@@ -1458,7 +1458,7 @@ namespace Game.Entities
return null;
}
public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
public GameObject SummonGameObject(uint entry, float x, float y, float z, float ang, Quaternion rotation, TimeSpan respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
{
if (x == 0 && y == 0 && z == 0)
{
@@ -1470,7 +1470,7 @@ namespace Game.Entities
return SummonGameObject(entry, pos, rotation, respawnTime, summonType);
}
public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, uint respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
public GameObject SummonGameObject(uint entry, Position pos, Quaternion rotation, TimeSpan respawnTime, GameObjectSummonType summonType = GameObjectSummonType.TimedOrCorpseDespawn)
{
if (!IsInWorld)
return null;
@@ -1489,7 +1489,7 @@ namespace Game.Entities
PhasingHandler.InheritPhaseShift(go, this);
go.SetRespawnTime((int)respawnTime);
go.SetRespawnTime((int)respawnTime.TotalSeconds);
if (IsPlayer() || (IsCreature() && summonType == GameObjectSummonType.TimedOrCorpseDespawn)) //not sure how to handle this
ToUnit().AddGameObject(go);
else
@@ -1499,10 +1499,10 @@ namespace Game.Entities
return go;
}
public Creature SummonTrigger(float x, float y, float z, float ang, uint duration, CreatureAI AI = null)
public Creature SummonTrigger(float x, float y, float z, float ang, TimeSpan despawnTime, CreatureAI AI = null)
{
TempSummonType summonType = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
Creature summon = SummonCreature(SharedConst.WorldTrigger, x, y, z, ang, summonType, duration);
TempSummonType summonType = (despawnTime == TimeSpan.Zero) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
Creature summon = SummonCreature(SharedConst.WorldTrigger, x, y, z, ang, summonType, despawnTime);
if (summon == null)
return null;
@@ -1535,7 +1535,7 @@ namespace Game.Entities
foreach (var tempSummonData in data)
{
TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, tempSummonData.time);
TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, TimeSpan.FromMilliseconds(tempSummonData.time));
if (summon)
list.Add(summon);
}
@@ -81,7 +81,7 @@ namespace Game.Entities
return;
player.GetMap().LoadGridForActiveObject(pos.GetPositionX(), pos.GetPositionY(), player);
m_CinematicObject = player.SummonCreature(1, pos.posX, pos.posY, pos.posZ, 0.0f, TempSummonType.TimedDespawn, 5 * Time.Minute * Time.InMilliseconds);
m_CinematicObject = player.SummonCreature(1, pos.posX, pos.posY, pos.posZ, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5));
if (m_CinematicObject)
{
m_CinematicObject.SetActive(true);
+2 -1
View File
@@ -18,6 +18,7 @@
using Framework.Constants;
using Framework.Dynamic;
using Game.DataStorage;
using System;
using System.Collections.Generic;
namespace Game.Entities
@@ -254,7 +255,7 @@ namespace Game.Entities
{
ForcedUnsummonDelayEvent pEvent = new(this);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
m_Events.AddEvent(pEvent, m_Events.CalculateTime(TimeSpan.FromMilliseconds(msTime)));
return;
}
+2 -1
View File
@@ -20,6 +20,7 @@ using Game.DataStorage;
using Game.Groups;
using Game.Networking.Packets;
using Game.Spells;
using System;
namespace Game.Entities
{
@@ -99,7 +100,7 @@ namespace Game.Entities
{
if (msTime != 0)
{
m_Events.AddEvent(new ForcedUnsummonDelayEvent(this), m_Events.CalculateTime(msTime));
m_Events.AddEvent(new ForcedUnsummonDelayEvent(this), m_Events.CalculateTime(TimeSpan.FromMilliseconds(msTime)));
return;
}
+2 -2
View File
@@ -279,7 +279,7 @@ namespace Game.Entities
Log.outDebug(LogFilter.Vehicle, "Vehicle ({0}, Entry {1}): installing accessory (Entry: {2}) on seat: {3}", _me.GetGUID().ToString(), GetCreatureEntry(), entry, seatId);
TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, summonTime);
TempSummon accessory = _me.SummonCreature(entry, _me, (TempSummonType)type, TimeSpan.FromMilliseconds(summonTime));
Cypher.Assert(accessory);
if (minion)
@@ -310,7 +310,7 @@ namespace Game.Entities
// exits the vehicle will dismiss. That's why the actual adding the passenger to the vehicle is scheduled
// asynchronously, so it can be cancelled easily in case the vehicle is uninstalled meanwhile.
VehicleJoinEvent e = new(this, unit);
unit.m_Events.AddEvent(e, unit.m_Events.CalculateTime(0));
unit.m_Events.AddEvent(e, unit.m_Events.CalculateTime(TimeSpan.Zero));
KeyValuePair<sbyte, VehicleSeat> seat = new();
if (seatId < 0) // no specific seat requirement
+2 -2
View File
@@ -548,7 +548,7 @@ namespace Game.Maps
Log.outDebug(LogFilter.Scripts, "InstanceScript: DoCloseDoorOrButton failed");
}
public void DoRespawnGameObject(ObjectGuid guid, uint timeToDespawn)
public void DoRespawnGameObject(ObjectGuid guid, TimeSpan timeToDespawn)
{
GameObject go = instance.GetGameObject(guid);
if (go)
@@ -569,7 +569,7 @@ namespace Game.Maps
if (go.IsSpawned())
return;
go.SetRespawnTime((int)timeToDespawn);
go.SetRespawnTime((int)timeToDespawn.TotalSeconds);
}
else
Log.outDebug(LogFilter.Scripts, "InstanceScript: DoRespawnGameObject failed");
+2 -2
View File
@@ -4738,7 +4738,7 @@ namespace Game.Maps
float z = step.script.TempSummonCreature.PosZ;
float o = step.script.TempSummonCreature.Orientation;
if (pSummoner.SummonCreature(step.script.TempSummonCreature.CreatureEntry, x, y, z, o, TempSummonType.TimedOrDeadDespawn, step.script.TempSummonCreature.DespawnDelay) == null)
if (pSummoner.SummonCreature(step.script.TempSummonCreature.CreatureEntry, x, y, z, o, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromMilliseconds(step.script.TempSummonCreature.DespawnDelay)) == null)
Log.outError(LogFilter.Scripts, "{0} creature was not spawned (entry: {1}).", step.script.GetDebugInfo(), step.script.TempSummonCreature.CreatureEntry);
}
}
@@ -4884,7 +4884,7 @@ namespace Game.Maps
// First try with target or source creature, then with target or source gameobject
Creature cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true);
if (cSource != null)
cSource.DespawnOrUnsummon(step.script.DespawnSelf.DespawnDelay);
cSource.DespawnOrUnsummon(TimeSpan.FromMilliseconds(step.script.DespawnSelf.DespawnDelay));
else
{
GameObject goSource = _GetScriptGameObjectSourceOrTarget(source, target, step.script, true);
+1 -1
View File
@@ -896,7 +896,7 @@ namespace Game.Spells
return;
m_dropEvent = new ChargeDropEvent(this, removeMode);
owner.m_Events.AddEvent(m_dropEvent, owner.m_Events.CalculateTime(delay));
owner.m_Events.AddEvent(m_dropEvent, owner.m_Events.CalculateTime(TimeSpan.FromMilliseconds(delay)));
}
public void SetStackAmount(byte stackAmount)
+6 -6
View File
@@ -324,7 +324,7 @@ namespace Game.Spells
public void RecalculateDelayMomentForDst()
{
m_delayMoment = CalculateDelayMomentForDst(0.0f);
m_caster.m_Events.ModifyEventTime(_spellEvent, GetDelayStart() + m_delayMoment);
m_caster.m_Events.ModifyEventTime(_spellEvent, TimeSpan.FromMilliseconds(GetDelayStart() + m_delayMoment));
}
void SelectEffectImplicitTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, ref uint processedEffectMask)
@@ -1830,7 +1830,7 @@ namespace Game.Spells
targetInfo.ReflectResult = unitCaster.SpellHitResult(unitCaster, m_spellInfo, false); // can't reflect twice
// Proc spell reflect aura when missile hits the original target
target.m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target.m_Events.CalculateTime(targetInfo.TimeDelay));
target.m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target.m_Events.CalculateTime(TimeSpan.FromMilliseconds(targetInfo.TimeDelay)));
// Increase time interval for reflected spells by 1.5
targetInfo.TimeDelay += targetInfo.TimeDelay >> 1;
@@ -2374,7 +2374,7 @@ namespace Game.Spells
// create and add update event for this spell
_spellEvent = new SpellEvent(this);
m_caster.m_Events.AddEvent(_spellEvent, m_caster.m_Events.CalculateTime(1));
m_caster.m_Events.AddEvent(_spellEvent, m_caster.m_Events.CalculateTime(TimeSpan.FromMilliseconds(1)));
// check disables
if (Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_spellInfo.Id, m_caster))
@@ -8797,7 +8797,7 @@ namespace Game.Spells
if (n_offset != 0)
{
// re-add us to the queue
m_Spell.GetCaster().m_Events.AddEvent(this, m_Spell.GetDelayStart() + n_offset, false);
m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(m_Spell.GetDelayStart() + n_offset), false);
return false; // event not complete
}
// event complete
@@ -8815,7 +8815,7 @@ namespace Game.Spells
Cypher.Assert(n_offset == m_Spell.GetDelayMoment());
// re-plan the event for the delay moment
m_Spell.GetCaster().m_Events.AddEvent(this, e_time + m_Spell.GetDelayMoment(), false);
m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(e_time + m_Spell.GetDelayMoment()), false);
return false; // event not complete
}
break;
@@ -8829,7 +8829,7 @@ namespace Game.Spells
}
// spell processing not complete, plan event on the next update interval
m_Spell.GetCaster().m_Events.AddEvent(this, e_time + 1, false);
m_Spell.GetCaster().m_Events.AddEvent(this, TimeSpan.FromMilliseconds(e_time + 1), false);
return false; // event not complete
}
+1 -1
View File
@@ -1621,7 +1621,7 @@ namespace Game.Spells
// randomize position for multiple summons
pos = caster.GetRandomPoint(destTarget, radius);
summon = caster.SummonCreature(entry, pos, summonType, (uint)duration, 0, m_spellInfo.Id, privateObjectOwner);
summon = caster.SummonCreature(entry, pos, summonType, TimeSpan.FromMilliseconds(duration), 0, m_spellInfo.Id, privateObjectOwner);
if (summon == null)
continue;