Fancy Verb Menu & Verb API Refactor (#928)
This commit is contained in:
committed by
GitHub
parent
4527fc9e84
commit
cad59d2cb4
@@ -58,28 +58,22 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
||||
[Verb]
|
||||
private sealed class InsertVerb : Verb<PowerCellChargerComponent>
|
||||
{
|
||||
protected override string GetText(IEntity user, PowerCellChargerComponent component)
|
||||
{
|
||||
if (!user.TryGetComponent(out HandsComponent handsComponent) || handsComponent.GetActiveHand == null)
|
||||
{
|
||||
return "Insert";
|
||||
}
|
||||
return $"Insert {handsComponent.GetActiveHand.Owner.Name}";
|
||||
}
|
||||
|
||||
protected override VerbVisibility GetVisibility(IEntity user, PowerCellChargerComponent component)
|
||||
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
||||
{
|
||||
if (!user.TryGetComponent(out HandsComponent handsComponent))
|
||||
{
|
||||
return VerbVisibility.Invisible;
|
||||
data.Visibility = VerbVisibility.Invisible;
|
||||
return;
|
||||
}
|
||||
|
||||
if (component._container.ContainedEntity != null || handsComponent.GetActiveHand == null)
|
||||
{
|
||||
return VerbVisibility.Disabled;
|
||||
data.Visibility = VerbVisibility.Disabled;
|
||||
data.Text = "Insert";
|
||||
return;
|
||||
}
|
||||
|
||||
return VerbVisibility.Visible;
|
||||
data.Text = $"Insert {handsComponent.GetActiveHand.Owner.Name}";
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, PowerCellChargerComponent component)
|
||||
@@ -102,22 +96,16 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
||||
[Verb]
|
||||
private sealed class EjectVerb : Verb<PowerCellChargerComponent>
|
||||
{
|
||||
protected override string GetText(IEntity user, PowerCellChargerComponent component)
|
||||
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
||||
{
|
||||
if (component._container.ContainedEntity == null)
|
||||
{
|
||||
return "Eject";
|
||||
data.Text = "Eject";
|
||||
data.Visibility = VerbVisibility.Disabled;
|
||||
return;
|
||||
}
|
||||
return $"Eject {component._container.ContainedEntity.Name}";
|
||||
}
|
||||
|
||||
protected override VerbVisibility GetVisibility(IEntity user, PowerCellChargerComponent component)
|
||||
{
|
||||
if (component._container.ContainedEntity == null)
|
||||
{
|
||||
return VerbVisibility.Disabled;
|
||||
}
|
||||
return VerbVisibility.Visible;
|
||||
data.Text = $"Eject {component._container.ContainedEntity.Name}";
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, PowerCellChargerComponent component)
|
||||
|
||||
Reference in New Issue
Block a user