Skip to content

Commit

Permalink
use tags per item instead of var per component
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Aug 25, 2023
1 parent 58aca28 commit 4ff20a4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 26 deletions.
3 changes: 0 additions & 3 deletions Content.Server/Nyanotrasen/Borgs/InnateItemComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ public sealed class InnateItemComponent : Component
{
public bool AlreadyInitialized = false;

[DataField("afterInteract")]
public bool AfterInteract = true;

[DataField("startingPriority")]
public int? StartingPriority = null;
}
Expand Down
25 changes: 4 additions & 21 deletions Content.Server/Nyanotrasen/Borgs/InnateItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public override void Initialize()

private void OnMindAdded(EntityUid uid, InnateItemComponent component, MindAddedMessage args)
{
Logger.ErrorS("innate", $"OnMindAdded: {uid}");
if (!component.AlreadyInitialized)
RefreshItems(uid, component);

Expand All @@ -42,41 +41,25 @@ private void RefreshItems(EntityUid uid, InnateItemComponent component)
_tagSystem.HasTag(sourceItem, "NoAction"))
continue;

_actionsSystem.AddAction(uid, component.AfterInteract
? CreateAfterInteractAction(sourceItem, priority)
: CreateBeforeInteractAction(sourceItem, priority),
uid
);
_actionsSystem.AddAction(uid, CreateInteractAction(sourceItem, priority), null);

priority--;
}
}

private EntityTargetAction CreateAfterInteractAction(EntityUid uid, int priority)
{
EntityTargetAction action = new()
{
DisplayName = MetaData(uid).EntityName,
Description = MetaData(uid).EntityDescription,
EntityIcon = uid,
Event = new InnateAfterInteractActionEvent(uid),
Priority = priority,
};

return action;
}

private EntityTargetAction CreateBeforeInteractAction(EntityUid uid, int priority)
private EntityTargetAction CreateInteractAction(EntityUid uid, int priority)
{
EntityTargetAction action = new()
{
DisplayName = MetaData(uid).EntityName,
Description = MetaData(uid).EntityDescription,
EntityIcon = uid,
Event = new InnateBeforeInteractActionEvent(uid),
Event = _tagSystem.HasTag(uid, "InnateItemBeforeInteract") ? new InnateBeforeInteractActionEvent(uid) : new InnateAfterInteractActionEvent(uid),
Priority = priority,
CheckCanAccess = false,
Range = 25f,
Repeat = _tagSystem.HasTag(uid, "InnateItemRepeat"),
};

return action;
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
- type: Inventory
templateId: aghost
- type: InnateItem
afterInteract: false
startingPriority: 15
- type: ItemSlots
slots:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
showAuthor: false
# Innate door remotes (bolting, emergency access, etc)
- type: InnateItem
afterInteract: false
startingPriority: 25
- type: ItemSlots
slots:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
- AllAccess
- type: DoorRemote
defaultMode: enum.OperatingMode.OpenClose
- type: Tag
tags:
- InnateItemBeforeInteract
- InnateItemRepeat

# Innate items, not meant to be spawned as there isn't any functional difference between them and the parent
- type: entity
Expand Down
6 changes: 6 additions & 0 deletions Resources/Prototypes/SimpleStation14/tags.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
- type: Tag
id: GlassesNearsight

- type: Tag
id: InnateItemBeforeInteract

- type: Tag
id: InnateItemRepeat

- type: Tag
id: Plushie

Expand Down

0 comments on commit 4ff20a4

Please sign in to comment.