Files
SPT-Server-Build/Core/Routers/ItemEvents/HealthItemEventRouter.cs
T
CWX a85eb5b5c0 new itemRouters, missing enums, fix method sigs (#41)
* callbacks

* controllers

* Router override

* make requests use interface

* create Routers

* extra parts

* fix method sig on callbacks

* add two missing enums as static classes

* add missing serializers (not complete)

* complete ItemEventRouters
2025-01-12 16:42:09 +00:00

48 lines
1.5 KiB
C#

using Core.Annotations;
using Core.Callbacks;
using Core.DI;
using Core.Models.Eft.Common;
using Core.Models.Eft.Health;
using Core.Models.Eft.ItemEvent;
namespace Core.Routers.ItemEvents;
[Injectable(InjectableTypeOverride = typeof(ItemEventRouterDefinition))]
public class HealthItemEventRouter : ItemEventRouterDefinition
{
protected HealthCallbacks _healthCallbacks;
public HealthItemEventRouter
(
HealthCallbacks healthCallbacks
)
{
_healthCallbacks = healthCallbacks;
}
protected override List<HandledRoute> GetHandledRoutes()
{
return new()
{
new HandledRoute("Eat", false),
new HandledRoute("Heal", false),
new HandledRoute("RestoreHealth", false)
};
}
public override object HandleItemEvent(string url, PmcData pmcData, object body, string sessionID, ItemEventRouterResponse output)
{
switch (url)
{
case "Eat":
return _healthCallbacks.OffraidEat(pmcData, body as OffraidEatRequestData, sessionID);
case "Heal":
return _healthCallbacks.OffraidHeal(pmcData, body as OffraidHealRequestData, sessionID);
case "RestoreHealth":
return _healthCallbacks.HealthTreatment(pmcData, body as HealthTreatmentRequestData, sessionID);
default:
throw new Exception($"HealthItemEventRouter being used when it cant handle route {url}");
}
}
}