Cult item stuff & robe fix (#35)

* - tweak: New cult item behavior

* - fix: Fix cult robe modifier

* - fix: Fix runic wall cgraph
This commit is contained in:
Aviu00
2024-02-08 18:44:02 +09:00
committed by GitHub
parent 337034d734
commit 74941f06bb
10 changed files with 60 additions and 6 deletions

View File

@@ -2,6 +2,8 @@ using Content.Shared.Ghost;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared._White.Cult.Components;
using Content.Shared.Inventory.Events;
using Content.Shared.Weapons.Melee.Events;
namespace Content.Shared._White.Cult.Systems;
@@ -15,15 +17,40 @@ public sealed class CultItemSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<CultItemComponent, GettingPickedUpAttemptEvent>(OnHandPickUp);
SubscribeLocalEvent<CultItemComponent, BeingEquippedAttemptEvent>(OnEquipAttempt);
SubscribeLocalEvent<CultItemComponent, AttemptMeleeEvent>(OnMeleeAttempt);
}
private void OnEquipAttempt(EntityUid uid, CultItemComponent component, BeingEquippedAttemptEvent args)
{
if (CanUse(args.Equipee))
return;
args.Cancel();
_popupSystem.PopupClient(Loc.GetString("cult-item-component-equip-fail"), uid, args.Equipee);
}
private void OnMeleeAttempt(Entity<CultItemComponent> ent, ref AttemptMeleeEvent args)
{
if (CanUse(args.User))
return;
args.Cancelled = true;
args.Message = Loc.GetString("cult-item-component-attack-fail");
}
private void OnHandPickUp(EntityUid uid, CultItemComponent component, GettingPickedUpAttemptEvent args)
{
if (HasComp<Components.CultistComponent>(args.User) || HasComp<GhostComponent>(args.User))
if (component.CanPickUp || CanUse(args.User))
return;
args.Cancel();
_transform.AttachToGridOrMap(uid);
_popupSystem.PopupClient(Loc.GetString("cult-item-component-not-cultist", ("name", Name(uid))), uid, args.User);
_popupSystem.PopupClient(Loc.GetString("cult-item-component-pickup-fail", ("name", Name(uid))), uid, args.User);
}
private bool CanUse(EntityUid? uid)
{
return HasComp<CultistComponent>(uid) || HasComp<GhostComponent>(uid);
}
}