2024-12-23 17:38:08 -05:00
|
|
|
using Arrowgene.Ddon.GameServer.Scripting.Interfaces;
|
|
|
|
|
using Arrowgene.Ddon.Shared.Model;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Arrowgene.Ddon.GameServer.Scripting
|
|
|
|
|
{
|
2025-02-03 00:56:57 -05:00
|
|
|
public class GameItemModule : GameServerScriptModule
|
2024-12-23 17:38:08 -05:00
|
|
|
{
|
|
|
|
|
public override string ModuleRoot => "game_items";
|
|
|
|
|
public override string Filter => "*.csx";
|
|
|
|
|
public override bool ScanSubdirectories => true;
|
|
|
|
|
public override bool EnableHotLoad => true;
|
|
|
|
|
|
|
|
|
|
private Dictionary<ItemId, IGameItem> Items { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool HasItem(ItemId itemId)
|
|
|
|
|
{
|
|
|
|
|
return Items.ContainsKey(itemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasItem(uint itemId)
|
|
|
|
|
{
|
|
|
|
|
return HasItem((ItemId)itemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IGameItem? GetItemInterface(ItemId itemId)
|
|
|
|
|
{
|
|
|
|
|
if (!Items.ContainsKey(itemId))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return Items[itemId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IGameItem? GetItemInterface(uint itemId)
|
|
|
|
|
{
|
|
|
|
|
return GetItemInterface((ItemId)itemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GameItemModule()
|
|
|
|
|
{
|
|
|
|
|
Items = new Dictionary<ItemId, IGameItem>();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-29 02:07:13 -07:00
|
|
|
public override bool EvaluateResult(string path, object result, IDictionary<string, object> variables)
|
2024-12-23 17:38:08 -05:00
|
|
|
{
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-29 02:07:13 -07:00
|
|
|
IGameItem item = (IGameItem)result;
|
2024-12-23 17:38:08 -05:00
|
|
|
Items[item.ItemId] = item;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|