This commit is contained in:
Aviu00
2024-01-23 08:43:11 +03:00
parent 5a43180119
commit b8db546c33
13 changed files with 17 additions and 176 deletions

View File

@@ -159,10 +159,9 @@ public sealed partial class ChatSystem : SharedChatSystem
IConsoleShell? shell = null, IConsoleShell? shell = null,
ICommonSession? player = null, string? nameOverride = null, ICommonSession? player = null, string? nameOverride = null,
bool checkRadioPrefix = true, bool checkRadioPrefix = true,
bool ignoreActionBlocker = false, bool ignoreActionBlocker = false)
bool force = false)
{ {
TrySendInGameICMessage(source, message, desiredType, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal, hideLog, shell, player, nameOverride, checkRadioPrefix, ignoreActionBlocker, force); TrySendInGameICMessage(source, message, desiredType, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal, hideLog, shell, player, nameOverride, checkRadioPrefix, ignoreActionBlocker);
} }
/// <summary> /// <summary>
@@ -186,8 +185,7 @@ public sealed partial class ChatSystem : SharedChatSystem
ICommonSession? player = null, ICommonSession? player = null,
string? nameOverride = null, string? nameOverride = null,
bool checkRadioPrefix = true, bool checkRadioPrefix = true,
bool ignoreActionBlocker = false, bool ignoreActionBlocker = false
bool force = false
) )
{ {
if (HasComp<GhostComponent>(source)) if (HasComp<GhostComponent>(source))
@@ -209,7 +207,7 @@ public sealed partial class ChatSystem : SharedChatSystem
return; return;
} }
if (!force && !CanSendInGame(message, shell, player)) if (!CanSendInGame(message, shell, player))
return; return;
ignoreActionBlocker = CheckIgnoreSpeechBlocker(source, ignoreActionBlocker); ignoreActionBlocker = CheckIgnoreSpeechBlocker(source, ignoreActionBlocker);

View File

@@ -16,7 +16,7 @@ internal sealed class NoticeCommand : IConsoleCommand
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (shell.Player is not IPlayerSession player) if (shell.Player is not { } player)
{ {
shell.WriteError("This command cannot be run from the server."); shell.WriteError("This command cannot be run from the server.");
return; return;

View File

@@ -1,76 +0,0 @@
using Content.Server.Administration;
using Content.Server.Chat.Systems;
using Content.Shared.Actions;
using Content.Shared.Mobs.Systems;
using Content.Shared.White.Other;
using Robust.Server.Console;
using Robust.Server.GameObjects;
namespace Content.Server.White.Other;
/// <summary>
/// Handles performing crit-specific actions.
/// </summary>
public sealed class CritMobActionsSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IServerConsoleHost _host = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly QuickDialogSystem _quickDialog = default!;
private const int MaxLastWordsLength = 30;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MobStateActionsComponent, CritSuccumbEvent>(OnSuccumb);
SubscribeLocalEvent<MobStateActionsComponent, CritLastWordsEvent>(OnLastWords);
}
private void OnSuccumb(EntityUid uid, MobStateActionsComponent component, CritSuccumbEvent args)
{
if (!TryComp<ActorComponent>(uid, out var actor) || !_mobState.IsCritical(uid))
return;
_host.ExecuteCommand(actor.PlayerSession, "ghost");
args.Handled = true;
}
private void OnLastWords(EntityUid uid, MobStateActionsComponent component, CritLastWordsEvent args)
{
if (!TryComp<ActorComponent>(uid, out var actor))
return;
_quickDialog.OpenDialog(actor.PlayerSession, Loc.GetString("action-name-crit-last-words"), "",
(string lastWords) =>
{
if (actor.PlayerSession.AttachedEntity != uid
|| !_mobState.IsCritical(uid))
return;
if (lastWords.Length > MaxLastWordsLength)
{
lastWords = lastWords.Substring(0, MaxLastWordsLength);
}
lastWords += "...";
_chat.TrySendInGameICMessage(uid, lastWords, InGameICChatType.Whisper, ChatTransmitRange.Normal, force: true);
_host.ExecuteCommand(actor.PlayerSession, "ghost");
});
args.Handled = true;
}
}
/// <summary>
/// Only applies to mobs in crit capable of ghosting/succumbing
/// </summary>
public sealed class CritSuccumbEvent : InstantActionEvent
{
}
/// <summary>
/// Only applies to mobs capable of speaking, as a last resort in crit
/// </summary>
public sealed class CritLastWordsEvent : InstantActionEvent
{
}

View File

@@ -88,7 +88,8 @@ public sealed class OnDeath : EntitySystem
private void SendDeathGaspMessage(EntityUid uid, string message) private void SendDeathGaspMessage(EntityUid uid, string message)
{ {
_chat.TrySendInGameICMessage(uid, message, InGameICChatType.Emote, ChatTransmitRange.Normal, force: true); _chat.TrySendInGameICMessage(uid, message, InGameICChatType.Emote, ChatTransmitRange.Normal,
ignoreActionBlocker: true);
} }
private void PlayDeathSound(EntityUid uid) private void PlayDeathSound(EntityUid uid)

View File

@@ -8,6 +8,7 @@ using Content.Shared.White;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Player;
namespace Content.Server.White.Other.ExamineSystem namespace Content.Server.White.Other.ExamineSystem
{ {

View File

@@ -23,6 +23,9 @@
<Private>false</Private> <Private>false</Private>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="White\Other" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" /> <Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<Import Project="..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" /> <Import Project="..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" />
</Project> </Project>

View File

@@ -1,27 +0,0 @@
using Content.Shared.Mobs;
namespace Content.Shared.White.Other;
/// <summary>
/// Used for specifying actions that should be automatically added/removed on mob state transitions
/// </summary>
/// <remarks>
/// Mostly for crit-specific actions.
/// </remarks>
/// <see cref="MobStateActionsSystem"/>
[RegisterComponent]
public sealed class MobStateActionsComponent : Component
{
/// <summary>
/// Specifies a list of actions that should be available if a mob is in a given state.
/// </summary>
/// <example>
/// actions:
/// Critical:
/// - CritSuccumb
/// Alive:
/// - AnimalLayEgg
/// </example>
[DataField("actions")]
public Dictionary<MobState, List<string>> Actions = new();
}

View File

@@ -1,54 +0,0 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Mobs;
using Robust.Shared.Prototypes;
namespace Content.Shared.White.Other;
/// <summary>
/// Adds and removes defined actions when a mob's <see cref="MobState"/> changes.
/// </summary>
public sealed class MobStateActionsSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<MobStateActionsComponent, MobStateChangedEvent>(OnMobStateChanged);
}
private void OnMobStateChanged(EntityUid uid, MobStateActionsComponent component, MobStateChangedEvent args)
{
if (!TryComp<ActionsComponent>(uid, out var action))
return;
foreach (var (state, acts) in component.Actions)
{
if (state != args.NewMobState && state != args.OldMobState)
continue;
foreach (var item in acts)
{
if (!_proto.TryIndex<InstantActionPrototype>(item, out var proto))
continue;
var instance = new InstantAction(proto);
if (state == args.OldMobState)
{
// Don't remove actions that would be getting readded anyway
if (component.Actions.TryGetValue(args.NewMobState, out var value)
&& value.Contains(item))
continue;
_actions.RemoveAction(uid, instance, action);
}
else if (state == args.NewMobState)
{
_actions.AddAction(uid, instance, null, action);
}
}
}
}
}

View File

@@ -298,7 +298,7 @@ public sealed class WhiteCVars
/// <summary> /// <summary>
/// Should load a ERT map? /// Should load a ERT map?
/// </summary> /// </summary>
public static readonly CVarDef<bool> LoadERTMap = CVarDef.Create("white.ert_load", false, CVar.SERVERONLY); public static readonly CVarDef<bool> LoadErtMap = CVarDef.Create("white.ert_load", false, CVar.SERVERONLY);
public static readonly CVarDef<bool> LogChatActions = public static readonly CVarDef<bool> LogChatActions =
CVarDef.Create("white.log_to_chat", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED); CVarDef.Create("white.log_to_chat", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED);

View File

@@ -1388,7 +1388,7 @@
actions: actions:
Critical: Critical:
- ActionCritSuccumb - ActionCritSuccumb
- ActionCritFakeDeath #- ActionCritFakeDeath
- ActionCritLastWords - ActionCritLastWords
- type: MobThresholds - type: MobThresholds
thresholds: thresholds:
@@ -2793,7 +2793,7 @@
actions: actions:
Critical: Critical:
- ActionCritSuccumb - ActionCritSuccumb
- ActionCritFakeDeath #- ActionCritFakeDeath
- ActionCritLastWords - ActionCritLastWords
- type: MobThresholds - type: MobThresholds
thresholds: thresholds:

View File

@@ -234,11 +234,6 @@
- type: ExaminableClothes - type: ExaminableClothes
- type: CharacterInformation - type: CharacterInformation
- type: Penetrated - type: Penetrated
- type: MobStateActions
actions:
Critical:
- CritSuccumb
- CritLastWords
- type: entity - type: entity
save: false save: false

View File

@@ -1,4 +1,4 @@
# The progenitor. This should only container the most basic components possible. # The progenitor. This should only container the most basic components possible.
# Only put things on here if every mob *must* have it. This includes ghosts. # Only put things on here if every mob *must* have it. This includes ghosts.
- type: entity - type: entity
save: false save: false
@@ -72,7 +72,7 @@
actions: actions:
Critical: Critical:
- ActionCritSuccumb - ActionCritSuccumb
- ActionCritFakeDeath #- ActionCritFakeDeath
- ActionCritLastWords - ActionCritLastWords
- type: Deathgasp - type: Deathgasp
- type: HealthExaminable - type: HealthExaminable

View File

@@ -589,7 +589,7 @@
suffix: Agent suffix: Agent
components: components:
- type: IdCard - type: IdCard
jobTitle: Passenger jobTitle: ассистент
- type: Access - type: Access
tags: tags:
- Maintenance - Maintenance