Meleespeech Action, Holoparasite Meleespeech (#19504)
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<DefaultWindow xmlns="https://spacestation14.io"
|
<DefaultWindow xmlns="https://spacestation14.io"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="{Loc north-star-menu-title}">
|
Title="{Loc melee-speech-menu-title}">
|
||||||
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150" >
|
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150" >
|
||||||
<Label Name="CurrentBattlecry" Text="{Loc 'north-star-current-battlecry'}" />
|
<Label Name="CurrentBattlecry" Text="{Loc 'melee-speech-current-battlecry'}" />
|
||||||
<LineEdit Name="BattlecryLineEdit" />
|
<LineEdit Name="BattlecryLineEdit" />
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</DefaultWindow>
|
</DefaultWindow>
|
||||||
|
|||||||
@@ -1,76 +1,83 @@
|
|||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Shared.Actions;
|
||||||
using Content.Shared.Speech.Components;
|
using Content.Shared.Speech.Components;
|
||||||
using Content.Shared.Speech.EntitySystems;
|
using Content.Shared.Speech.EntitySystems;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
|
||||||
namespace Content.Server.Speech.EntitySystems;
|
namespace Content.Server.Speech.EntitySystems;
|
||||||
|
|
||||||
public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
|
public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly SharedActionsSystem _actionSystem = default!;
|
||||||
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||||
|
public override void Initialize()
|
||||||
public override void Initialize()
|
{
|
||||||
{
|
base.Initialize();
|
||||||
base.Initialize();
|
SubscribeLocalEvent<MeleeSpeechComponent, MeleeSpeechBattlecryChangedMessage>(OnBattlecryChanged);
|
||||||
SubscribeLocalEvent<MeleeSpeechComponent, MeleeSpeechBattlecryChangedMessage>(OnBattlecryChanged);
|
SubscribeLocalEvent<MeleeSpeechComponent, MeleeSpeechConfigureActionEvent>(OnConfigureAction);
|
||||||
}
|
SubscribeLocalEvent<MeleeSpeechComponent, GetItemActionsEvent>(OnGetActions);
|
||||||
|
SubscribeLocalEvent<MeleeSpeechComponent, ComponentInit>(OnComponentInit);
|
||||||
|
}
|
||||||
private void OnBattlecryChanged(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechBattlecryChangedMessage args)
|
private void OnComponentInit(EntityUid uid, MeleeSpeechComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
|
if (component.ConfigureAction != null)
|
||||||
|
_actionSystem.AddAction(uid, component.ConfigureAction, uid);
|
||||||
|
}
|
||||||
|
private void OnGetActions(EntityUid uid, MeleeSpeechComponent component, GetItemActionsEvent args)
|
||||||
|
{
|
||||||
|
if (component.ConfigureAction != null)
|
||||||
|
args.Actions.Add(component.ConfigureAction);
|
||||||
|
}
|
||||||
|
private void OnBattlecryChanged(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechBattlecryChangedMessage args)
|
||||||
|
{
|
||||||
if (!TryComp<MeleeSpeechComponent>(uid, out var meleeSpeechUser))
|
if (!TryComp<MeleeSpeechComponent>(uid, out var meleeSpeechUser))
|
||||||
return;
|
return;
|
||||||
|
var battlecry = args.Battlecry;
|
||||||
string battlecry = args.Battlecry;
|
|
||||||
|
|
||||||
if (battlecry.Length > comp.MaxBattlecryLength)
|
if (battlecry.Length > comp.MaxBattlecryLength)
|
||||||
battlecry = battlecry[..comp.MaxBattlecryLength];
|
battlecry = battlecry[..comp.MaxBattlecryLength];
|
||||||
|
|
||||||
TryChangeBattlecry(uid, battlecry, meleeSpeechUser);
|
TryChangeBattlecry(uid, battlecry, meleeSpeechUser);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to open the Battlecry UI.
|
||||||
|
/// </summary>
|
||||||
|
private void OnConfigureAction(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechConfigureActionEvent args)
|
||||||
/// <summary>
|
{
|
||||||
/// Attempts to change the battlecry of an entity.
|
TryOpenUi(args.Performer, uid, comp);
|
||||||
/// Returns true/false.
|
}
|
||||||
/// </summary>
|
public void TryOpenUi(EntityUid user, EntityUid source, MeleeSpeechComponent? component = null)
|
||||||
/// <remarks>
|
{
|
||||||
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
|
if (!Resolve(source, ref component))
|
||||||
/// </remarks>
|
return;
|
||||||
public bool TryChangeBattlecry(EntityUid uid, string? battlecry, MeleeSpeechComponent? meleeSpeechComp = null)
|
if (!TryComp<ActorComponent>(user, out var actor))
|
||||||
{
|
return;
|
||||||
|
_uiSystem.TryToggleUi(source, MeleeSpeechUiKey.Key, actor.PlayerSession);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to change the battlecry of an entity.
|
||||||
|
/// Returns true/false.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Logs changes to an entity's battlecry
|
||||||
|
/// </remarks>
|
||||||
|
public bool TryChangeBattlecry(EntityUid uid, string? battlecry, MeleeSpeechComponent? meleeSpeechComp = null)
|
||||||
|
{
|
||||||
if (!Resolve(uid, ref meleeSpeechComp))
|
if (!Resolve(uid, ref meleeSpeechComp))
|
||||||
return false;
|
return false;
|
||||||
|
if (!string.IsNullOrWhiteSpace(battlecry))
|
||||||
if (!string.IsNullOrWhiteSpace(battlecry))
|
{
|
||||||
{
|
battlecry = battlecry.Trim();
|
||||||
battlecry = battlecry.Trim();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
}
|
battlecry = null;
|
||||||
else
|
}
|
||||||
{
|
if (meleeSpeechComp.Battlecry == battlecry)
|
||||||
battlecry = null;
|
return true;
|
||||||
}
|
meleeSpeechComp.Battlecry = battlecry;
|
||||||
|
Dirty(uid, meleeSpeechComp);
|
||||||
if (meleeSpeechComp.Battlecry == battlecry)
|
_adminLogger.Add(LogType.ItemConfigure, LogImpact.Medium, $" {ToPrettyString(uid):entity}'s battlecry has been changed to {battlecry}");
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
meleeSpeechComp.Battlecry = battlecry;
|
|
||||||
Dirty(meleeSpeechComp);
|
|
||||||
|
|
||||||
_adminLogger.Add(LogType.ItemConfigure, LogImpact.Medium, $" {ToPrettyString(uid):entity}'s battlecry has been changed to {battlecry}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,43 @@
|
|||||||
using Content.Shared.Speech.EntitySystems;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Actions.ActionTypes;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Speech.Components;
|
namespace Content.Shared.Speech.Components;
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
[AutoGenerateComponentState]
|
[AutoGenerateComponentState]
|
||||||
|
|
||||||
public sealed partial class MeleeSpeechComponent : Component
|
public sealed partial class MeleeSpeechComponent : Component
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The battlecry to be said when an entity attacks with this component
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("Battlecry")]
|
||||||
|
[AutoNetworkedField]
|
||||||
|
public string? Battlecry;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
/// <summary>
|
||||||
[DataField("Battlecry")]
|
/// The maximum amount of characters allowed in a battlecry
|
||||||
[AutoNetworkedField]
|
/// </summary>
|
||||||
public string? Battlecry;
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("MaxBattlecryLength")]
|
[DataField("MaxBattlecryLength")]
|
||||||
|
[AutoNetworkedField]
|
||||||
public int MaxBattlecryLength = 12;
|
public int MaxBattlecryLength = 12;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The action to open the battlecry UI
|
||||||
|
/// </summary>
|
||||||
|
[DataField("configureAction")]
|
||||||
|
public InstantAction ConfigureAction = new()
|
||||||
|
{
|
||||||
|
UseDelay = TimeSpan.FromSeconds(1),
|
||||||
|
ItemIconStyle = ItemActionIconStyle.BigItem,
|
||||||
|
DisplayName = "melee-speech-config",
|
||||||
|
Description = "melee-speech-config-desc",
|
||||||
|
Priority = -20,
|
||||||
|
Event = new MeleeSpeechConfigureActionEvent(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -35,7 +57,6 @@ public enum MeleeSpeechUiKey : byte
|
|||||||
public sealed class MeleeSpeechBoundUserInterfaceState : BoundUserInterfaceState
|
public sealed class MeleeSpeechBoundUserInterfaceState : BoundUserInterfaceState
|
||||||
{
|
{
|
||||||
public string CurrentBattlecry { get; }
|
public string CurrentBattlecry { get; }
|
||||||
|
|
||||||
public MeleeSpeechBoundUserInterfaceState(string currentBattlecry)
|
public MeleeSpeechBoundUserInterfaceState(string currentBattlecry)
|
||||||
{
|
{
|
||||||
CurrentBattlecry = currentBattlecry;
|
CurrentBattlecry = currentBattlecry;
|
||||||
@@ -51,3 +72,5 @@ public sealed class MeleeSpeechBattlecryChangedMessage : BoundUserInterfaceMessa
|
|||||||
Battlecry = battlecry;
|
Battlecry = battlecry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed partial class MeleeSpeechConfigureActionEvent : InstantActionEvent { }
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
north-star-current-battlecry = Battlecry:
|
|
||||||
north-star-menu-title = Set Battlecry
|
|
||||||
4
Resources/Locale/en-US/speech/melee-speech.ftl
Normal file
4
Resources/Locale/en-US/speech/melee-speech.ftl
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
melee-speech-config = Set Battlecry
|
||||||
|
melee-speech-config-desc = Set a custom battlecry for when you attack!
|
||||||
|
melee-speech-current-battlecry = Battlecry:
|
||||||
|
melee-speech-menu-title = Set Battlecry
|
||||||
@@ -322,6 +322,7 @@
|
|||||||
components:
|
components:
|
||||||
- type: Unremoveable
|
- type: Unremoveable
|
||||||
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingHandsBase
|
parent: ClothingHandsBase
|
||||||
id: ClothingHandsGlovesNorthStar
|
id: ClothingHandsGlovesNorthStar
|
||||||
@@ -349,6 +350,7 @@
|
|||||||
key: enum.MeleeSpeechUiKey.Key
|
key: enum.MeleeSpeechUiKey.Key
|
||||||
closeOnHandDeselect: false
|
closeOnHandDeselect: false
|
||||||
rightClickOnly: true
|
rightClickOnly: true
|
||||||
|
- type: Actions
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.MeleeSpeechUiKey.Key
|
- key: enum.MeleeSpeechUiKey.Key
|
||||||
|
|||||||
@@ -89,6 +89,11 @@
|
|||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 20
|
Blunt: 20
|
||||||
|
- type: MeleeSpeech
|
||||||
|
- type: UserInterface
|
||||||
|
interfaces:
|
||||||
|
- key: enum.MeleeSpeechUiKey.Key
|
||||||
|
type: MeleeSpeechBoundUserInterface
|
||||||
- type: Actions
|
- type: Actions
|
||||||
- type: Guardian
|
- type: Guardian
|
||||||
- type: InteractionPopup
|
- type: InteractionPopup
|
||||||
|
|||||||
Reference in New Issue
Block a user