2021-09-16 15:17:19 +02:00
|
|
|
using Content.Server.Holiday;
|
2022-03-17 20:13:31 +13:00
|
|
|
using Content.Shared.Hands.EntitySystems;
|
2021-09-16 15:17:19 +02:00
|
|
|
using Content.Shared.Roles;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Jobs
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class GiveItemOnHolidaySpecial : JobSpecial
|
2021-09-16 15:17:19 +02:00
|
|
|
{
|
|
|
|
|
[DataField("holiday", customTypeSerializer:typeof(PrototypeIdSerializer<HolidayPrototype>))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public string Holiday { get; private set; } = string.Empty;
|
2021-09-16 15:17:19 +02:00
|
|
|
|
|
|
|
|
[DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public string Prototype { get; private set; } = string.Empty;
|
2021-09-16 15:17:19 +02:00
|
|
|
|
2021-12-05 21:02:04 +01:00
|
|
|
public override void AfterEquip(EntityUid mob)
|
2021-09-16 15:17:19 +02:00
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Holiday) || string.IsNullOrEmpty(Prototype))
|
|
|
|
|
return;
|
|
|
|
|
|
2022-03-17 20:13:31 +13:00
|
|
|
var sysMan = IoCManager.Resolve<IEntitySystemManager>();
|
|
|
|
|
|
|
|
|
|
if (!sysMan.GetEntitySystem<HolidaySystem>().IsCurrentlyHoliday(Holiday))
|
2021-09-16 15:17:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2021-12-08 17:17:12 +01:00
|
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
2021-09-16 15:17:19 +02:00
|
|
|
|
2021-12-08 17:17:12 +01:00
|
|
|
var entity = entMan.SpawnEntity(Prototype, entMan.GetComponent<TransformComponent>(mob).Coordinates);
|
|
|
|
|
|
2022-03-17 20:13:31 +13:00
|
|
|
sysMan.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(mob, entity);
|
2021-09-16 15:17:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|