Core/Cache: Implement QueryCache system

Ideas/Port From (https://github.com/TrinityCore/TrinityCore/commit/b4d30bb92cbfc8411d8d91b0f4f2981f2cecc148)
This commit is contained in:
hondacrx
2019-08-31 10:06:35 -04:00
parent 8797760d8a
commit 966c1fff33
13 changed files with 430 additions and 358 deletions
@@ -20,6 +20,8 @@ using Framework.Constants;
using Framework.GameMath;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Game.Network;
using Game.Network.Packets;
namespace Game.Entities
{
@@ -209,6 +211,9 @@ namespace Game.Entities
[FieldOffset(68)]
public raw Raw;
[FieldOffset(208)]
public QueryGameObjectResponse QueryData;
// helpers
public bool IsDespawnAtAction()
{
@@ -513,6 +518,41 @@ namespace Game.Entities
}
}
public void InitializeQueryData()
{
QueryData = new QueryGameObjectResponse();
QueryData.GameObjectID = entry;
QueryData.Allow = true;
GameObjectStats stats = new GameObjectStats();
stats.Type = (uint)type;
stats.DisplayID = displayId;
stats.Name[0] = name;
stats.IconName = IconName;
stats.CastBarCaption = castBarCaption;
stats.UnkString = unk1;
stats.Size = size;
var items = Global.ObjectMgr.GetGameObjectQuestItemList(entry);
foreach (uint item in items)
stats.QuestItems.Add(item);
unsafe
{
fixed (int* ptr = Raw.data)
{
for (int i = 0; i < SharedConst.MaxGOData; i++)
stats.Data[i] = ptr[i];
}
}
stats.RequiredLevel = (uint)RequiredLevel;
QueryData.Stats = stats;
}
#region TypeStructs
public unsafe struct raw
{