Table of Contents

Class CanUseItemCondition

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Condition that checks whether a character is carrying a specific item.

[Serializable]
public class CanUseItemCondition : BaseCondition, ICondition
Inheritance
CanUseItemCondition
Implements
Inherited Members

Remarks

Despite the name, this condition checks inventory presence and nothing else. It is an "owns one of these" test, not a "may use this right now" test. Read the name as HasItemInInventory; the class name is kept because conditions are persisted by type through [SerializeReference] and renaming it would silently null out the condition on every authored Trigger asset that already references it.

What it does NOT check, and where each of those actually lives:

  • Cooldown. Compose HasCooldownCondition (with Invert set) alongside this one, giving it the consumable template's ID — that is the key Invoke(IPlayerCharacter, Item, uint) registers the cooldown under. Doing it here instead would mean a second, parallel copy of that condition's tick-domain resolution: a replicate-domain tick has to be preferred over a raw authoritative one and an authoritative one mapped through ResolveAuthoritativeTick(uint), or the comparison is made in the wrong clock and answers wrongly during reconcile replay. One copy of that, in the condition named after it, is the whole point of ECA conditions being small composable predicates.
  • Charges / stack amount. CanConsume(IPlayerCharacter, Item, uint) owns it, and needs the Item instance and an IPlayerCharacter — neither of which this condition has, since IItemContainer.ContainsItem answers only yes or no and the subject here may be an NPC.
  • "Requirements". There is no such concept to check. BaseItemTemplate has no level, class, attribute or faction requirement fields of any kind — the FIXME that used to sit in Evaluate(ICharacter, EventData) promising a "requirements" check referred to a system that has never existed. If one is added later, this is the condition to extend.

This is not the authoritative use gate and must not be treated as one. Item use is validated server-side by CanConsume(IPlayerCharacter, Item, uint), called from both AbilityController.ActivateConsumable (client pre-filter) and the authoritative activation path. A Trigger that gates on this condition alone is gating on possession, so a character who owns a potion satisfies it while the potion is still on cooldown.

Fields

RequiredItem

The item template required for this condition to pass.

public BaseItemTemplate RequiredItem

Field Value

BaseItemTemplate

Methods

Evaluate(ICharacter, EventData)

Evaluates whether the character (or event target) is carrying the specified item.

public override bool Evaluate(ICharacter initiator, EventData eventData)

Parameters

initiator ICharacter

The character to check, or the fallback if no event target is present.

eventData EventData

Optional event data that may provide a different character to check.

Returns

bool

True if the character has the required item in their inventory; otherwise, false.

Remarks

Presence only. See the remarks on CanUseItemCondition for what is not checked here and which condition or template method checks it instead.