Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MindSlaveTweaks&Su... #2192

Merged
merged 12 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Client/SS220/Surgery/SurgerySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Server.SS220.Surgery.Systems;

namespace Content.Client.SS220.Surgery;

public sealed partial class SurgerySystem : SharedSurgerySystem
{
// exist only in to make prediction
}
40 changes: 38 additions & 2 deletions Content.Server/Implants/ImplanterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server.Construction.Conditions;
using Content.Server.Popups;
using Content.Server.SS220.MindSlave;
using Content.Shared.DoAfter;
Expand All @@ -8,6 +9,7 @@
using Content.Shared.Interaction;
using Content.Shared.Mindshield.Components;
using Content.Shared.Popups;
using Content.Shared.Tag; // SS220-mindslave
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;

Expand All @@ -19,10 +21,14 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly MindSlaveSystem _mindslave = default!;
[Dependency] private readonly TagSystem _tag = default!; // SS220-mindslave

//SS220-mindslave begin
[ValidatePrototypeId<EntityPrototype>]
private const string MindSlaveImplantProto = "MindSlaveImplant";
[ValidatePrototypeId<TagPrototype>]
private const string MindShieldImplantTag = "MindShield";
private const float MindShieldRemoveTime = 40;
//SS220-mindslave end

public override void Initialize()
Expand All @@ -46,6 +52,15 @@ private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent componen
return;

//SS220-mindslave begin
if (component.ImplanterSlot.ContainerSlot != null
&& component.ImplanterSlot.ContainerSlot.ContainedEntity != null
&& _tag.HasTag(component.ImplanterSlot.ContainerSlot.ContainedEntity.Value, MindShieldImplantTag)
&& _mindslave.IsEnslaved(target))
{
_popup.PopupEntity(Loc.GetString("mindshield-target-mindslaved"), target, args.User);
return;
}

if (component.Implant == MindSlaveImplantProto)
{
if (args.User == target)
Expand Down Expand Up @@ -155,15 +170,36 @@ public void TryImplant(ImplanterComponent component, EntityUid user, EntityUid t
//TODO: Remove when surgery is in
public void TryDraw(ImplanterComponent component, EntityUid user, EntityUid target, EntityUid implanter)
{
var args = new DoAfterArgs(EntityManager, user, component.DrawTime, new DrawEvent(), implanter, target: target, used: implanter)
//SS220-Mindshield-remove-time begin
var isMindShield = false;

if (_container.TryGetContainer(target, ImplanterComponent.ImplantSlotId, out var implantContainer))
{
foreach (var implant in implantContainer.ContainedEntities)
{
if (HasComp<SubdermalImplantComponent>(implant) && _container.CanRemove(implant, implantContainer))
{
if (_tag.HasTag(implant, MindShieldImplantTag))
isMindShield = true;
break;
}
}
}
var delay = isMindShield ? MindShieldRemoveTime : component.DrawTime;
var popupPath = isMindShield ? "injector-component-drawing-mind-shield" : "injector-component-drawing-user";
var args = new DoAfterArgs(EntityManager, user, delay, new DrawEvent(), implanter, target: target, used: implanter)
// var args = new DoAfterArgs(EntityManager, user, component.DrawTime, new DrawEvent(), implanter, target: target, used: implanter)
//SS220-Mindshield-remove-time end
{
BreakOnDamage = true,
BreakOnMove = true,
NeedHand = true,
};

if (_doAfter.TryStartDoAfter(args))
_popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user);
// _popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user); //SS220-Mindshield-remove-time
_popup.PopupEntity(Loc.GetString(popupPath), target, user);


}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.Damage;

namespace Content.Server.SS220.MindSlave.Components;

[RegisterComponent]
public sealed partial class MindSlaveDisfunctionComponent : Component
{

[ViewVariables]
public Dictionary<MindSlaveDisfunctionType, List<string>> Disfunction => DisfunctionParameters.Disfunction;

[ViewVariables]
public DamageSpecifier DeadlyStageDamage => DisfunctionParameters.DeadlyStageDamage;

[DataField(required: true)]
public DisfunctionParameters DisfunctionParameters = new();

[ViewVariables(VVAccess.ReadOnly)]
public List<IComponent> DisfunctionComponents = new();

[ViewVariables(VVAccess.ReadWrite)]
public MindSlaveDisfunctionType DisfunctionStage = MindSlaveDisfunctionType.None;

[ViewVariables(VVAccess.ReadWrite)]
public bool Active = true;

[ViewVariables(VVAccess.ReadWrite)]
public bool Deadly = false;

[ViewVariables(VVAccess.ReadWrite)]
public bool Weakened = false;

[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextProgressTime;

[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextDeadlyDamageTime;

[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan PausedTime;

[ViewVariables(VVAccess.ReadWrite)]
public float ConstMinutesBetweenStages = 35;

[ViewVariables(VVAccess.ReadWrite)]
public float MaxRandomMinutesBetweenStages = 7;

}

public enum MindSlaveDisfunctionType
{
None = 0,
Initial,
Progressive,
Terminal,
Deadly
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.Damage;

namespace Content.Server.SS220.MindSlave.Components;

[RegisterComponent]
public sealed partial class MindSlaveDisfunctionProviderComponent : Component
{
[DataField(required: true)]
public DisfunctionParameters Disfunction = new();
}

[DataDefinition]
public sealed partial class DisfunctionParameters
{
[DataField(required: true)]
public Dictionary<MindSlaveDisfunctionType, List<string>> Disfunction = new();

[DataField(required: true)]
public DamageSpecifier DeadlyStageDamage = new();

[DataField(required: true)]
public string ProgressionPopup;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Robust.Shared.Prototypes;

namespace Content.Server.SS220.MindSlave.Components;

[RegisterComponent]
public sealed partial class MindSlaveStopWordContainerComponent : Component
{
// to pass tests add values
[DataField]
public string Collection = "nanotrasen_central_command";
[DataField]
public string Group = "roundstart";
[DataField]
public string Form = "hos_mindslave_briefing";

/// <summary>
/// This stamp will be applied to list
/// </summary>
[DataField]
public List<EntProtoId> StampList = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

namespace Content.Server.SS220.MindSlave.DisfunctionComponents;

[RegisterComponent]
public sealed partial class MindSlaveDisfunctionAccentComponent : Component
{
[DataField]
public float Prob = 0.33f;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

namespace Content.Server.SS220.MindSlave.DisfunctionComponents;

[RegisterComponent]
public sealed partial class WieldUnabilityComponent : Component
{ }
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Server.Speech;
using Robust.Shared.Random;

namespace Content.Server.SS220.MindSlave.DisfunctionComponents;

public sealed class MindSlaveDisfunctionAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;

private readonly List<string> _vowels = ["а", "е", "у", "о", "и", "я"];
private readonly List<string> _consonants = ["в", "п", "р", "к", "м", "т", "с"];

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MindSlaveDisfunctionAccentComponent, AccentGetEvent>(OnAccent);
}

private void OnAccent(Entity<MindSlaveDisfunctionAccentComponent> entity, ref AccentGetEvent args)
{
var message = args.Message;
var vowel = _random.Pick(_vowels);
var consonant = _random.Pick(_consonants);
args.Message = TryChangeInString(TryChangeInString(message, vowel, consonant, entity.Comp.Prob),
consonant, vowel, entity.Comp.Prob);
}

private string TryChangeInString(string value, string key, string keyAddition, float prob)
{
var result = value;
var index = value.IndexOf(key);
if (index != -1)
{
if (_random.Prob(prob))
{
result = value.Replace(key, key + keyAddition + key);
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Server.Popups;
using Content.Server.SS220.MindSlave.DisfunctionComponents;
using Content.Shared.Wieldable;

namespace Content.Server.SS220.MindSlave.DisfunctionSystem;

public sealed class WieldUnabilitySystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<WieldUnabilityComponent, BeforeWieldEvent>(OnWieldAttempt);
}

private void OnWieldAttempt(Entity<WieldUnabilityComponent> entity, ref BeforeWieldEvent args)
{
if (args.Cancelled)
return;

_popup.PopupCursor(Loc.GetString("unable-to-wield", ("user", entity.Owner)), entity);
args.Cancel();
}
}
24 changes: 24 additions & 0 deletions Content.Server/SS220/MindSlave/MindSlaveEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

/// <summary>
/// Event raised right after Mindslave component added to Entity on slave entity
/// </summary>
public sealed class AfterEntityMindSlavedEvent(EntityUid master, EntityUid slave) : EventArgs
{
public EntityUid Master { get; } = master;
public EntityUid Slave { get; } = slave;
}

/// <summary>
/// Event raised right after Mindslave component added to Entity om master entity
/// </summary>
public sealed class AfterEntityMindSlavedMasterEvent(EntityUid master, EntityUid slave) : EventArgs
{
public EntityUid Master { get; } = master;
public EntityUid Slave { get; } = slave;
}

public sealed class StopWordGeneratedEvent(string stopWord) : EventArgs
{
public string StopWord { get; } = stopWord;
}
Loading
Loading