Core/GameObjects: Added stringid to gameobjects
Port From (https://github.com/TrinityCore/TrinityCore/commit/845f61e0a969891b14e1f182fadd29af347a1a3f)
This commit is contained in:
@@ -360,6 +360,9 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
LastUsedScriptID = GetGoInfo().ScriptId;
|
LastUsedScriptID = GetGoInfo().ScriptId;
|
||||||
|
|
||||||
|
m_stringIds[0] = goInfo.StringId;
|
||||||
|
|
||||||
AIM_Initialize();
|
AIM_Initialize();
|
||||||
|
|
||||||
if (spawnid != 0)
|
if (spawnid != 0)
|
||||||
@@ -1161,6 +1164,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
m_goData = data;
|
m_goData = data;
|
||||||
|
|
||||||
|
m_stringIds[1] = data.StringId;
|
||||||
|
|
||||||
if (addToMap && !GetMap().AddToMap(this))
|
if (addToMap && !GetMap().AddToMap(this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -2636,6 +2641,27 @@ namespace Game.Entities
|
|||||||
return GetGoInfo().ScriptId;
|
return GetGoInfo().ScriptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasStringId(string id)
|
||||||
|
{
|
||||||
|
return m_stringIds.Contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetScriptStringId(string id)
|
||||||
|
{
|
||||||
|
if (!id.IsEmpty())
|
||||||
|
{
|
||||||
|
m_scriptStringId = id;
|
||||||
|
m_stringIds[2] = m_scriptStringId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_scriptStringId = null;
|
||||||
|
m_stringIds[2] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] GetStringIds() { return m_stringIds; }
|
||||||
|
|
||||||
public override string GetName(Locale locale = Locale.enUS)
|
public override string GetName(Locale locale = Locale.enUS)
|
||||||
{
|
{
|
||||||
if (locale != Locale.enUS)
|
if (locale != Locale.enUS)
|
||||||
@@ -3769,6 +3795,8 @@ namespace Game.Entities
|
|||||||
public GameObjectFieldData m_gameObjectData;
|
public GameObjectFieldData m_gameObjectData;
|
||||||
GameObjectTypeBase m_goTypeImpl;
|
GameObjectTypeBase m_goTypeImpl;
|
||||||
protected GameObjectValue m_goValue; // TODO: replace with m_goTypeImpl
|
protected GameObjectValue m_goValue; // TODO: replace with m_goTypeImpl
|
||||||
|
string[] m_stringIds = new string[3];
|
||||||
|
string m_scriptStringId;
|
||||||
protected GameObjectTemplate m_goInfo;
|
protected GameObjectTemplate m_goInfo;
|
||||||
protected GameObjectTemplateAddon m_goTemplateAddon;
|
protected GameObjectTemplateAddon m_goTemplateAddon;
|
||||||
GameObjectData m_goData;
|
GameObjectData m_goData;
|
||||||
|
|||||||
@@ -48,180 +48,183 @@ namespace Game.Entities
|
|||||||
public uint ScriptId;
|
public uint ScriptId;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(68)]
|
||||||
|
public string StringId;
|
||||||
|
|
||||||
|
[FieldOffset(72)]
|
||||||
public door Door;
|
public door Door;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public button Button;
|
public button Button;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public questgiver QuestGiver;
|
public questgiver QuestGiver;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public chest Chest;
|
public chest Chest;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public binder Binder;
|
public binder Binder;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public generic Generic;
|
public generic Generic;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public trap Trap;
|
public trap Trap;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public chair Chair;
|
public chair Chair;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public spellFocus SpellFocus;
|
public spellFocus SpellFocus;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public text Text;
|
public text Text;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public goober Goober;
|
public goober Goober;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public transport Transport;
|
public transport Transport;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public areadamage AreaDamage;
|
public areadamage AreaDamage;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public camera Camera;
|
public camera Camera;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public moTransport MoTransport;
|
public moTransport MoTransport;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public duelflag DuelFlag;
|
public duelflag DuelFlag;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public fishingnode FishingNode;
|
public fishingnode FishingNode;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public ritual Ritual;
|
public ritual Ritual;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public mailbox MailBox;
|
public mailbox MailBox;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public guardpost GuardPost;
|
public guardpost GuardPost;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public spellcaster SpellCaster;
|
public spellcaster SpellCaster;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public meetingstone MeetingStone;
|
public meetingstone MeetingStone;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public flagstand FlagStand;
|
public flagstand FlagStand;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public fishinghole FishingHole;
|
public fishinghole FishingHole;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public flagdrop FlagDrop;
|
public flagdrop FlagDrop;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public controlzone ControlZone;
|
public controlzone ControlZone;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public auraGenerator AuraGenerator;
|
public auraGenerator AuraGenerator;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public dungeonDifficulty DungeonDifficulty;
|
public dungeonDifficulty DungeonDifficulty;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public barberChair BarberChair;
|
public barberChair BarberChair;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public destructiblebuilding DestructibleBuilding;
|
public destructiblebuilding DestructibleBuilding;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public guildbank GuildBank;
|
public guildbank GuildBank;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public trapDoor TrapDoor;
|
public trapDoor TrapDoor;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public newflag NewFlag;
|
public newflag NewFlag;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public newflagdrop NewFlagDrop;
|
public newflagdrop NewFlagDrop;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrisonbuilding GarrisonBuilding;
|
public garrisonbuilding GarrisonBuilding;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrisonplot GarrisonPlot;
|
public garrisonplot GarrisonPlot;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public clientcreature ClientCreature;
|
public clientcreature ClientCreature;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public clientitem ClientItem;
|
public clientitem ClientItem;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public capturepoint CapturePoint;
|
public capturepoint CapturePoint;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public phaseablemo PhaseableMO;
|
public phaseablemo PhaseableMO;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrisonmonument GarrisonMonument;
|
public garrisonmonument GarrisonMonument;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrisonshipment GarrisonShipment;
|
public garrisonshipment GarrisonShipment;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrisonmonumentplaque GarrisonMonumentPlaque;
|
public garrisonmonumentplaque GarrisonMonumentPlaque;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public itemforge ItemForge;
|
public itemforge ItemForge;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public uilink UILink;
|
public uilink UILink;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public keystonereceptacle KeystoneReceptacle;
|
public keystonereceptacle KeystoneReceptacle;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public gatheringnode GatheringNode;
|
public gatheringnode GatheringNode;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public challengemodereward ChallengeModeReward;
|
public challengemodereward ChallengeModeReward;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public multi Multi;
|
public multi Multi;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public siegeableMulti SiegeableMulti;
|
public siegeableMulti SiegeableMulti;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public siegeableMO SiegeableMO;
|
public siegeableMO SiegeableMO;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public pvpReward PvpReward;
|
public pvpReward PvpReward;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public playerchoicechest PlayerChoiceChest;
|
public playerchoicechest PlayerChoiceChest;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public legendaryforge LegendaryForge;
|
public legendaryforge LegendaryForge;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public garrtalenttree GarrTalentTree;
|
public garrtalenttree GarrTalentTree;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public weeklyrewardchest WeeklyRewardChest;
|
public weeklyrewardchest WeeklyRewardChest;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public clientmodel ClientModel;
|
public clientmodel ClientModel;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public craftingTable CraftingTable;
|
public craftingTable CraftingTable;
|
||||||
|
|
||||||
[FieldOffset(68)]
|
[FieldOffset(72)]
|
||||||
public raw Raw;
|
public raw Raw;
|
||||||
|
|
||||||
[FieldOffset(208)]
|
[FieldOffset(208)]
|
||||||
|
|||||||
@@ -1683,6 +1683,18 @@ namespace Game.Entities
|
|||||||
return searcher.GetTarget();
|
return searcher.GetTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject FindNearestGameObjectWithOptions(float range, FindGameObjectOptions options)
|
||||||
|
{
|
||||||
|
NearestCheckCustomizer checkCustomizer = new(this, range);
|
||||||
|
GameObjectWithOptionsInObjectRangeCheck<NearestCheckCustomizer> checker = new(this, checkCustomizer, options);
|
||||||
|
GameObjectLastSearcher searcher = new(this, checker);
|
||||||
|
if (options.IgnorePhases)
|
||||||
|
searcher.i_phaseShift = PhasingHandler.GetAlwaysVisiblePhaseShift();
|
||||||
|
|
||||||
|
Cell.VisitGridObjects(this, searcher, range);
|
||||||
|
return searcher.GetTarget();
|
||||||
|
}
|
||||||
|
|
||||||
public GameObject FindNearestUnspawnedGameObject(uint entry, float range)
|
public GameObject FindNearestUnspawnedGameObject(uint entry, float range)
|
||||||
{
|
{
|
||||||
NearestUnspawnedGameObjectEntryInObjectRangeCheck checker = new(this, entry, range);
|
NearestUnspawnedGameObjectEntryInObjectRangeCheck checker = new(this, entry, range);
|
||||||
@@ -2834,6 +2846,17 @@ namespace Game.Entities
|
|||||||
return gameobjectList;
|
return gameobjectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetGameObjectListWithOptionsInGrid(List<GameObject> gameObjectContainer, float maxSearchRange, FindGameObjectOptions options)
|
||||||
|
{
|
||||||
|
InRangeCheckCustomizer checkCustomizer = new(this, maxSearchRange);
|
||||||
|
GameObjectWithOptionsInObjectRangeCheck<InRangeCheckCustomizer> check = new(this, checkCustomizer, options);
|
||||||
|
GameObjectListSearcher searcher = new(this, gameObjectContainer, check);
|
||||||
|
if (options.IgnorePhases)
|
||||||
|
searcher.i_phaseShift = PhasingHandler.GetAlwaysVisiblePhaseShift();
|
||||||
|
|
||||||
|
Cell.VisitGridObjects(this, searcher, maxSearchRange);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Creature> GetCreatureListWithEntryInGrid(uint entry = 0, float maxSearchRange = 250.0f)
|
public List<Creature> GetCreatureListWithEntryInGrid(uint entry = 0, float maxSearchRange = 250.0f)
|
||||||
{
|
{
|
||||||
List<Creature> creatureList = new();
|
List<Creature> creatureList = new();
|
||||||
@@ -2847,8 +2870,8 @@ namespace Game.Entities
|
|||||||
public List<Creature> GetCreatureListWithOptionsInGrid(float maxSearchRange, FindCreatureOptions options)
|
public List<Creature> GetCreatureListWithOptionsInGrid(float maxSearchRange, FindCreatureOptions options)
|
||||||
{
|
{
|
||||||
List<Creature> creatureList = new();
|
List<Creature> creatureList = new();
|
||||||
NoopCheckCustomizer checkCustomizer = new();
|
InRangeCheckCustomizer checkCustomizer = new(this, maxSearchRange);
|
||||||
CreatureWithOptionsInObjectRangeCheck<NoopCheckCustomizer> check = new(this, checkCustomizer, options);
|
CreatureWithOptionsInObjectRangeCheck<InRangeCheckCustomizer> check = new(this, checkCustomizer, options);
|
||||||
CreatureListSearcher searcher = new(this, creatureList, check);
|
CreatureListSearcher searcher = new(this, creatureList, check);
|
||||||
if (options.IgnorePhases)
|
if (options.IgnorePhases)
|
||||||
searcher.i_phaseShift = PhasingHandler.GetAlwaysVisiblePhaseShift();
|
searcher.i_phaseShift = PhasingHandler.GetAlwaysVisiblePhaseShift();
|
||||||
@@ -4038,4 +4061,20 @@ namespace Game.Entities
|
|||||||
public ObjectGuid? DemonCreatorGuid;
|
public ObjectGuid? DemonCreatorGuid;
|
||||||
public ObjectGuid? PrivateObjectOwnerGuid;
|
public ObjectGuid? PrivateObjectOwnerGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FindGameObjectOptions
|
||||||
|
{
|
||||||
|
public uint? GameObjectId;
|
||||||
|
public string StringId;
|
||||||
|
|
||||||
|
public bool? IsSummon;
|
||||||
|
public bool? IsSpawned;
|
||||||
|
|
||||||
|
public bool IgnorePhases;
|
||||||
|
public bool IgnoreNotOwnedPrivateObjects = true;
|
||||||
|
public bool IgnorePrivateObjects;
|
||||||
|
|
||||||
|
public ObjectGuid? OwnerGuid;
|
||||||
|
public ObjectGuid? PrivateObjectOwnerGuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3971,8 +3971,8 @@ namespace Game
|
|||||||
"Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, " +
|
"Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, " +
|
||||||
//21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
//21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
||||||
"Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, Data24, Data25, Data26, Data27, Data28, " +
|
"Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, Data24, Data25, Data26, Data27, Data28, " +
|
||||||
//37 38 39 40 41 42 43 44 45
|
//37 38 39 40 41 42 43 44 45 46
|
||||||
"Data29, Data30, Data31, Data32, Data33, Data34, ContentTuningId, AIName, ScriptName FROM gameobject_template");
|
"Data29, Data30, Data31, Data32, Data33, Data34, ContentTuningId, AIName, ScriptName, StringId FROM gameobject_template");
|
||||||
|
|
||||||
if (result.IsEmpty())
|
if (result.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -4004,6 +4004,7 @@ namespace Game
|
|||||||
got.ContentTuningId = result.Read<uint>(43);
|
got.ContentTuningId = result.Read<uint>(43);
|
||||||
got.AIName = result.Read<string>(44);
|
got.AIName = result.Read<string>(44);
|
||||||
got.ScriptId = GetScriptId(result.Read<string>(45));
|
got.ScriptId = GetScriptId(result.Read<string>(45));
|
||||||
|
got.StringId = result.Read<string>(46);
|
||||||
|
|
||||||
switch (got.type)
|
switch (got.type)
|
||||||
{
|
{
|
||||||
@@ -4264,8 +4265,8 @@ namespace Game
|
|||||||
SQLResult result = DB.World.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, " +
|
SQLResult result = DB.World.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, " +
|
||||||
//7 8 9 10 11 12 13 14 15 16
|
//7 8 9 10 11 12 13 14 15 16
|
||||||
"rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnDifficulties, eventEntry, poolSpawnId, " +
|
"rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnDifficulties, eventEntry, poolSpawnId, " +
|
||||||
//17 18 19 20 21
|
//17 18 19 20 21 22
|
||||||
"phaseUseFlags, phaseid, phasegroup, terrainSwapMap, ScriptName " +
|
"phaseUseFlags, phaseid, phasegroup, terrainSwapMap, ScriptName, StringId " +
|
||||||
"FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " +
|
"FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " +
|
||||||
"LEFT OUTER JOIN pool_members ON pool_members.type = 1 AND gameobject.guid = pool_members.spawnId");
|
"LEFT OUTER JOIN pool_members ON pool_members.type = 1 AND gameobject.guid = pool_members.spawnId");
|
||||||
|
|
||||||
@@ -4428,6 +4429,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.ScriptId = GetScriptId(result.Read<string>(21));
|
data.ScriptId = GetScriptId(result.Read<string>(21));
|
||||||
|
data.StringId = result.Read<string>(22);
|
||||||
|
|
||||||
if (data.rotation.X < -1.0f || data.rotation.X > 1.0f)
|
if (data.rotation.X < -1.0f || data.rotation.X > 1.0f)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1490,7 +1490,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public class GameObjectLastSearcher : Notifier
|
public class GameObjectLastSearcher : Notifier
|
||||||
{
|
{
|
||||||
PhaseShift i_phaseShift;
|
public PhaseShift i_phaseShift;
|
||||||
GameObject i_object;
|
GameObject i_object;
|
||||||
ICheck<GameObject> i_check;
|
ICheck<GameObject> i_check;
|
||||||
|
|
||||||
@@ -1518,7 +1518,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public class GameObjectListSearcher : Notifier
|
public class GameObjectListSearcher : Notifier
|
||||||
{
|
{
|
||||||
PhaseShift i_phaseShift;
|
public PhaseShift i_phaseShift;
|
||||||
List<GameObject> i_objects;
|
List<GameObject> i_objects;
|
||||||
ICheck<GameObject> i_check;
|
ICheck<GameObject> i_check;
|
||||||
|
|
||||||
@@ -2422,7 +2422,7 @@ namespace Game.Maps
|
|||||||
float i_range;
|
float i_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreatureWithOptionsInObjectRangeCheck<T> : ICheck<Creature> where T : NoopCheckCustomizer
|
public class CreatureWithOptionsInObjectRangeCheck<T> : ICheck<Creature> where T : InRangeCheckCustomizer
|
||||||
{
|
{
|
||||||
WorldObject i_obj;
|
WorldObject i_obj;
|
||||||
FindCreatureOptions i_args;
|
FindCreatureOptions i_args;
|
||||||
@@ -2482,6 +2482,54 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GameObjectWithOptionsInObjectRangeCheck<T> : ICheck<GameObject> where T : InRangeCheckCustomizer
|
||||||
|
{
|
||||||
|
WorldObject _obj;
|
||||||
|
FindGameObjectOptions _args;
|
||||||
|
T _customizer;
|
||||||
|
|
||||||
|
public GameObjectWithOptionsInObjectRangeCheck(WorldObject obj, T customizer, FindGameObjectOptions args)
|
||||||
|
{
|
||||||
|
_obj = obj;
|
||||||
|
_args = args;
|
||||||
|
_customizer = customizer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Invoke(GameObject go)
|
||||||
|
{
|
||||||
|
if (_args.IsSpawned.HasValue && _args.IsSpawned != go.IsSpawned()) // Despawned
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (go.GetGUID() == _obj.GetGUID())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_customizer.Test(go))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_args.GameObjectId.HasValue && go.GetEntry() != _args.GameObjectId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_args.StringId.IsEmpty() && !go.HasStringId(_args.StringId))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_args.IsSummon.HasValue && (go.GetSpawnId() == 0) != _args.IsSummon)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((_args.OwnerGuid.HasValue && go.GetOwnerGUID() != _args.OwnerGuid)
|
||||||
|
|| (_args.PrivateObjectOwnerGuid.HasValue && go.GetPrivateObjectOwner() != _args.PrivateObjectOwnerGuid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_args.IgnorePrivateObjects && go.IsPrivateObject())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_args.IgnoreNotOwnedPrivateObjects && !go.CheckPrivateObjectOwnerVisibility(_obj))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_customizer.Update(go);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class AnyPlayerInObjectRangeCheck : ICheck<Player>
|
public class AnyPlayerInObjectRangeCheck : ICheck<Player>
|
||||||
{
|
{
|
||||||
public AnyPlayerInObjectRangeCheck(WorldObject obj, float range, bool reqAlive = true)
|
public AnyPlayerInObjectRangeCheck(WorldObject obj, float range, bool reqAlive = true)
|
||||||
@@ -2933,32 +2981,44 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK modifiers
|
// CHECK modifiers
|
||||||
public class NoopCheckCustomizer
|
public class InRangeCheckCustomizer
|
||||||
{
|
{
|
||||||
public virtual bool Test(WorldObject o) { return true; }
|
WorldObject _obj;
|
||||||
|
float _range;
|
||||||
|
|
||||||
|
public InRangeCheckCustomizer(WorldObject obj, float range)
|
||||||
|
{
|
||||||
|
_obj = obj;
|
||||||
|
_range = range;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Test(WorldObject obj)
|
||||||
|
{
|
||||||
|
return _obj.IsWithinDist(obj, _range);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Update(WorldObject o) { }
|
public virtual void Update(WorldObject o) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
class NearestCheckCustomizer : NoopCheckCustomizer
|
class NearestCheckCustomizer : InRangeCheckCustomizer
|
||||||
{
|
{
|
||||||
WorldObject i_obj;
|
WorldObject i_obj;
|
||||||
float i_range;
|
float i_range;
|
||||||
|
|
||||||
public NearestCheckCustomizer(WorldObject obj, float range)
|
public NearestCheckCustomizer(WorldObject obj, float range) : base(obj, range)
|
||||||
{
|
{
|
||||||
i_obj = obj;
|
i_obj = obj;
|
||||||
i_range = range;
|
i_range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Test(WorldObject o)
|
public override bool Test(WorldObject obj)
|
||||||
{
|
{
|
||||||
return i_obj.IsWithinDist(o, i_range);
|
return i_obj.IsWithinDist(obj, i_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(WorldObject o)
|
public override void Update(WorldObject obj)
|
||||||
{
|
{
|
||||||
i_range = i_obj.GetDistance(o);
|
i_range = i_obj.GetDistance(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user