Verbs can now set themselves as invisible.
This commit is contained in:
@@ -164,9 +164,9 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return component.Cell == null ? "Eject cell (cell missing)" : "Eject cell";
|
||||
}
|
||||
|
||||
protected override bool IsDisabled(IEntity user, HandheldLightComponent component)
|
||||
protected override VerbVisibility GetVisibility(IEntity user, HandheldLightComponent component)
|
||||
{
|
||||
return component.Cell == null;
|
||||
return component.Cell == null ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, HandheldLightComponent component)
|
||||
|
||||
@@ -68,13 +68,14 @@ namespace Content.Server.GameObjects
|
||||
return "Pick Up";
|
||||
}
|
||||
|
||||
protected override bool IsDisabled(IEntity user, ItemComponent component)
|
||||
protected override VerbVisibility GetVisibility(IEntity user, ItemComponent component)
|
||||
{
|
||||
if (user.TryGetComponent(out HandsComponent hands) && hands.IsHolding(component.Owner))
|
||||
{
|
||||
return true;
|
||||
return VerbVisibility.Disabled;
|
||||
}
|
||||
return false;
|
||||
|
||||
return VerbVisibility.Visible;
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, ItemComponent component)
|
||||
|
||||
@@ -257,9 +257,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
|
||||
return component.Magazine == null ? "Eject magazine (magazine missing)" : "Eject magazine";
|
||||
}
|
||||
|
||||
protected override bool IsDisabled(IEntity user, BallisticMagazineWeaponComponent component)
|
||||
protected override VerbVisibility GetVisibility(IEntity user, BallisticMagazineWeaponComponent component)
|
||||
{
|
||||
return component.Magazine == null;
|
||||
return component.Magazine == null ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, BallisticMagazineWeaponComponent component)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.EntitySystemMessages;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
@@ -61,11 +61,15 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var vis = verb.GetVisibility(userEntity, component);
|
||||
if(vis == VerbVisibility.Invisible)
|
||||
continue;
|
||||
|
||||
// TODO: These keys being giant strings is inefficient as hell.
|
||||
data.Add(new VerbsResponseMessage.VerbData(verb.GetText(userEntity, component),
|
||||
$"{component.GetType()}:{verb.GetType()}",
|
||||
!verb.IsDisabled(userEntity, component)));
|
||||
vis == VerbVisibility.Visible));
|
||||
}
|
||||
|
||||
var response = new VerbsResponseMessage(data, req.EntityUid);
|
||||
|
||||
Reference in New Issue
Block a user