Set max length of battlecry to 12 chars. (#16958)
* Set max length of battlecry to 12 chars. Deleted a duplicate file. * Also cleanup some leftovers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Shared.Speech.Components;
|
using Content.Shared.Speech.Components;
|
||||||
using Content.Shared.Weapons.Melee;
|
using Content.Shared.Speech.EntitySystems;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
|
|
||||||
|
|
||||||
@@ -22,10 +22,15 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
|
|||||||
private void OnBattlecryChanged(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechBattlecryChangedMessage args)
|
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;
|
||||||
|
|
||||||
TryChangeBattlecry(uid, args.Battlecry, meleeSpeechUser);
|
string battlecry = args.Battlecry;
|
||||||
|
|
||||||
|
if (battlecry.Length > comp.MaxBattlecryLength)
|
||||||
|
battlecry = battlecry[..comp.MaxBattlecryLength];
|
||||||
|
|
||||||
|
TryChangeBattlecry(uid, battlecry, meleeSpeechUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -41,12 +46,14 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
|
|||||||
public bool TryChangeBattlecry(EntityUid uid, string? battlecry, MeleeSpeechComponent? meleeSpeechComp = null)
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -56,6 +63,9 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
|
|||||||
if (meleeSpeechComp.Battlecry == battlecry)
|
if (meleeSpeechComp.Battlecry == battlecry)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
meleeSpeechComp.Battlecry = battlecry;
|
meleeSpeechComp.Battlecry = battlecry;
|
||||||
Dirty(meleeSpeechComp);
|
Dirty(meleeSpeechComp);
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,17 @@ namespace Content.Shared.Speech.Components;
|
|||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[AutoGenerateComponentState]
|
[AutoGenerateComponentState]
|
||||||
[Access(typeof(SharedMeleeSpeechSystem), Other = AccessPermissions.ReadWrite)]
|
|
||||||
public sealed partial class MeleeSpeechComponent : Component
|
public sealed partial class MeleeSpeechComponent : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("Battlecry")]
|
[DataField("Battlecry")]
|
||||||
[AutoNetworkedField]
|
[AutoNetworkedField]
|
||||||
[Access(typeof(SharedMeleeSpeechSystem), Other = AccessPermissions.ReadWrite)]
|
|
||||||
public string? Battlecry;
|
public string? Battlecry;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("MaxBattlecryLength")]
|
||||||
|
public int MaxBattlecryLength = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Weapons.Melee;
|
namespace Content.Shared.Speech.EntitySystems;
|
||||||
|
|
||||||
public abstract class SharedMeleeSpeechSystem : EntitySystem
|
public abstract class SharedMeleeSpeechSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.Speech.EntitySystems;
|
|
||||||
|
|
||||||
public abstract class SharedMeleeSpeechSystem : EntitySystem
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user