mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Some misc streamlining/cleanup:
- std::chrono overloads for SummonCreature - Removed misleading const qualifier from SummonCreature (it wasn't being honored) - Rename parameters of SummonCreature to follow convention - EventProcessor has a new method (AddEventAtOffset) that adds an event...at an offset. Genius. PS: Hi there Keader.
This commit is contained in:
@@ -111,29 +111,24 @@ void EventProcessor::KillAllEvents(bool force)
|
||||
m_events.clear();
|
||||
}
|
||||
|
||||
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
|
||||
void EventProcessor::AddEvent(BasicEvent* event, uint64 e_time, bool set_addtime)
|
||||
{
|
||||
if (set_addtime)
|
||||
Event->m_addTime = m_time;
|
||||
Event->m_execTime = e_time;
|
||||
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
|
||||
event->m_addTime = m_time;
|
||||
event->m_execTime = e_time;
|
||||
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, event));
|
||||
}
|
||||
|
||||
void EventProcessor::ModifyEventTime(BasicEvent* Event, uint64 newTime)
|
||||
void EventProcessor::ModifyEventTime(BasicEvent* event, uint64 newTime)
|
||||
{
|
||||
for (auto itr = m_events.begin(); itr != m_events.end(); ++itr)
|
||||
{
|
||||
if (itr->second != Event)
|
||||
if (itr->second != event)
|
||||
continue;
|
||||
|
||||
Event->m_execTime = newTime;
|
||||
event->m_execTime = newTime;
|
||||
m_events.erase(itr);
|
||||
m_events.insert(std::pair<uint64, BasicEvent*>(newTime, Event));
|
||||
m_events.insert(std::pair<uint64, BasicEvent*>(newTime, event));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint64 EventProcessor::CalculateTime(uint64 t_offset) const
|
||||
{
|
||||
return(m_time + t_offset);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define __EVENTPROCESSOR_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
#include <map>
|
||||
|
||||
class EventProcessor;
|
||||
@@ -76,9 +77,10 @@ class TC_COMMON_API EventProcessor
|
||||
|
||||
void Update(uint32 p_time);
|
||||
void KillAllEvents(bool force);
|
||||
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
|
||||
void ModifyEventTime(BasicEvent* Event, uint64 newTime);
|
||||
uint64 CalculateTime(uint64 t_offset) const;
|
||||
void AddEvent(BasicEvent* event, uint64 e_time, bool set_addtime = true);
|
||||
void AddEventAtOffset(BasicEvent* event, Milliseconds const& offset) { AddEvent(event, CalculateTime(offset.count())); }
|
||||
void ModifyEventTime(BasicEvent* event, uint64 newTime);
|
||||
uint64 CalculateTime(uint64 t_offset) const { return m_time + t_offset; }
|
||||
|
||||
protected:
|
||||
uint64 m_time;
|
||||
|
||||
@@ -2513,7 +2513,7 @@ public:
|
||||
virtual G3D::Vector3 GetPosition() const override { return G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()); }
|
||||
virtual float GetOrientation() const override { return _owner->GetOrientation(); }
|
||||
virtual float GetScale() const override { return _owner->GetObjectScale(); }
|
||||
virtual void DebugVisualizeCorner(G3D::Vector3 const& corner) const override { _owner->SummonCreature(1, corner.x, corner.y, corner.z, 0, TEMPSUMMON_MANUAL_DESPAWN); }
|
||||
virtual void DebugVisualizeCorner(G3D::Vector3 const& corner) const override { const_cast<GameObject*>(_owner)->SummonCreature(1, corner.x, corner.y, corner.z, 0, TEMPSUMMON_MANUAL_DESPAWN); }
|
||||
|
||||
private:
|
||||
GameObject const* _owner;
|
||||
|
||||
@@ -1969,13 +1969,13 @@ void WorldObject::ClearZoneScript()
|
||||
m_zoneScript = nullptr;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 duration /*= 0*/, uint32 /*vehId = 0*/) const
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, uint32 /*vehId = 0*/)
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : nullptr))
|
||||
if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, ToUnit()))
|
||||
{
|
||||
summon->SetTempSummonType(spwtype);
|
||||
summon->SetTempSummonType(despawnType);
|
||||
return summon;
|
||||
}
|
||||
}
|
||||
@@ -1983,17 +1983,13 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang /*= 0*/, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despwtime /*= 0*/) const
|
||||
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/)
|
||||
{
|
||||
if (!x && !y && !z)
|
||||
{
|
||||
GetClosePoint(x, y, z, GetCombatReach());
|
||||
ang = GetOrientation();
|
||||
}
|
||||
|
||||
Position pos;
|
||||
pos.Relocate(x, y, z, ang);
|
||||
return SummonCreature(id, pos, spwtype, despwtime, 0);
|
||||
if (!o)
|
||||
o = GetOrientation();
|
||||
return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime);
|
||||
}
|
||||
|
||||
GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define _OBJECT_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "Duration.h"
|
||||
#include "GridReference.h"
|
||||
#include "GridRefManager.h"
|
||||
#include "ModelIgnoreFlags.h"
|
||||
@@ -372,8 +373,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
void ClearZoneScript();
|
||||
ZoneScript* GetZoneScript() const { return m_zoneScript; }
|
||||
|
||||
TempSummon* SummonCreature(uint32 id, Position const& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
|
||||
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0) const;
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds const& despawnTime, uint32 vehId = 0) { SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId); }
|
||||
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0);
|
||||
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime /* s */);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, uint32 respawnTime /* s */);
|
||||
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user