Convert alot of methods to use TimeSpan.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user