Skip to content

Commit

Permalink
Disease UPD (#537)
Browse files Browse the repository at this point in the history
* done

* fixes
  • Loading branch information
KayzelW authored Mar 27, 2024
1 parent 7ba384f commit 25ef11f
Show file tree
Hide file tree
Showing 15 changed files with 550 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Backmen.Disease;
using Content.Server.Polymorph.Systems;
using Content.Shared.Administration;
using Content.Shared.Backmen.Disease;
using Content.Shared.Polymorph;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.TypeParsers;

namespace Content.Server.Backmen.Administration.Commands.Toolshed;

[ToolshedCommand, AdminCommand(AdminFlags.Fun)]
public sealed class AddDiseaseCommand : ToolshedCommand
{
private DiseaseSystem? _diseaseSystem;

[CommandImplementation]
public EntityUid? AddDisease(
[PipedArgument] EntityUid input,
[CommandArgument] Prototype<DiseasePrototype> prototype
)
{
_diseaseSystem ??= GetSys<DiseaseSystem>();

_diseaseSystem.TryAddDisease(input, prototype.Id);
return input;
}

[CommandImplementation]
public IEnumerable<EntityUid> AddDisease(
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] Prototype<DiseasePrototype> prototype
)
=> input.Select(x => AddDisease(x, prototype)).Where(x => x is not null).Select(x => (EntityUid) x!);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System.Collections;
using System.Diagnostics;
using System.Linq;
using Content.Server.Administration;
using Content.Server.Humanoid;
using Content.Shared.Administration;
using Content.Shared.Humanoid;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Toolshed.Syntax;
using Robust.Shared.Utility;

namespace Content.Server.Backmen.Administration.Commands.Toolshed;

[ToolshedCommand, AdminCommand(AdminFlags.Fun)]
public sealed class ChangeSexCommand : ToolshedCommand
{
private HumanoidAppearanceSystem? _appearanceSystem;

#region base

private EntityUid? ChangeSex(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
Sex sex
)
{
if (!EntityManager.TryGetComponent<HumanoidAppearanceComponent>(input, out var humanoidAppearanceComponent))
{
ctx.ReportError(new NotHumanoidError());
return null;
}

_appearanceSystem ??= GetSys<HumanoidAppearanceSystem>();

humanoidAppearanceComponent.Gender = sex switch
{
Sex.Male => Gender.Male,
Sex.Female => Gender.Female,
Sex.Unsexed => Gender.Neuter,
_ => Gender.Epicene
};

if (EntityManager.TryGetComponent<GrammarComponent>(input, out var grammarComponent))
{
grammarComponent.Gender = humanoidAppearanceComponent.Gender;
EntityManager.Dirty(input, grammarComponent);
}

_appearanceSystem.SetSex(input, sex, humanoid: humanoidAppearanceComponent);
EntityManager.Dirty(input, humanoidAppearanceComponent);
return input;
}

private IEnumerable<EntityUid> ChangeSex(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
Sex sex
)
=> input.Select(x => ChangeSex(ctx, x, sex)).Where(x => x is not null).Select(x => (EntityUid) x!);

#endregion

[CommandImplementation("setMale")]
public EntityUid? SetMale(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input)
{
return ChangeSex(ctx, input, Sex.Male);
}

[CommandImplementation("setMale")]
public IEnumerable<EntityUid> SetMale(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input)
{
return ChangeSex(ctx, input, Sex.Male);
}

[CommandImplementation("setFemale")]
public EntityUid? SetFemale(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input)
{
return ChangeSex(ctx, input, Sex.Female);
}

[CommandImplementation("setFemale")]
public IEnumerable<EntityUid> SetFemale(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input)
{
return ChangeSex(ctx, input, Sex.Female);
}

[CommandImplementation("setUnsexed")]
public EntityUid? SetUnsexed(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input)
{
return ChangeSex(ctx, input, Sex.Unsexed);
}

[CommandImplementation("setUnsexed")]
public IEnumerable<EntityUid> SetUnsexed(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input)
{
return ChangeSex(ctx, input, Sex.Unsexed);
}
}

public record struct NotHumanoidError : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup(
"У сущности нет компонента HumanoidAppearanceComponent.");
}

public string? Expression { get; set; }
public Vector2i? IssueSpan { get; set; }
public StackTrace? Trace { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Backmen.Disease;
using Content.Server.Corvax.TTS;
using Content.Server.Humanoid;
using Content.Shared.Administration;
using Content.Shared.Backmen.Disease;
using Content.Shared.Corvax.TTS;
using Content.Shared.Humanoid;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.TypeParsers;

namespace Content.Server.Backmen.Administration.Commands.Toolshed;

[ToolshedCommand, AdminCommand(AdminFlags.Fun)]
public sealed class ChangeTTSCommand : ToolshedCommand
{
private HumanoidAppearanceSystem? _appearanceSystem;

[CommandImplementation]
public EntityUid? ChangeTTS(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] Prototype<TTSVoicePrototype> prototype
)
{
if (!EntityManager.TryGetComponent<HumanoidAppearanceComponent>(input, out var humanoidAppearanceComponent))
{
ctx.ReportError(new NotHumanoidError());
return null;
}

_appearanceSystem ??= GetSys<HumanoidAppearanceSystem>();

_appearanceSystem.SetTTSVoice(input, prototype.Id, humanoid: humanoidAppearanceComponent);
return input;
}

[CommandImplementation]
public IEnumerable<EntityUid> ChangeTTS(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] Prototype<TTSVoicePrototype> prototype
)
=> input.Select(x => ChangeTTS(ctx, x, prototype)).Where(x => x is not null).Select(x => (EntityUid) x!);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Forensics;
using Content.Shared.Administration;
using Content.Shared.Inventory;
using Robust.Shared.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Toolshed.Syntax;

namespace Content.Server.Backmen.Administration.Commands.Toolshed;

[ToolshedCommand, AdminCommand(AdminFlags.Fun)]
public sealed class MakeFakeFingerprintCommand : ToolshedCommand
{
private InventorySystem? _inventory;

[CommandImplementation]
public EntityUid? MakeFakeFingerprint(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid target,
[CommandArgument] ValueRef<ICommonSession> playerRef
)
{
var player = playerRef.Evaluate(ctx);
if (player is null || player.AttachedEntity is null)
{
ctx.ReportError(new NotForServerConsoleError());
return target;
}

var playerUid = player.AttachedEntity.Value;


var f = EntityManager.EnsureComponent<ForensicsComponent>(target);
if (EntityManager.TryGetComponent<DnaComponent>(playerUid, out var dna))
{
f.DNAs.Add(dna.DNA);
}

_inventory ??= GetSys<InventorySystem>();
if (_inventory.TryGetSlotEntity(playerUid, "gloves", out var gloves))
{
if (EntityManager.TryGetComponent<FiberComponent>(gloves, out var fiber) &&
!string.IsNullOrEmpty(fiber.FiberMaterial))
{
f.Fibers.Add(string.IsNullOrEmpty(fiber.FiberColor)
? Loc.GetString("forensic-fibers", ("material", fiber.FiberMaterial))
: Loc.GetString("forensic-fibers-colored", ("color", fiber.FiberColor),
("material", fiber.FiberMaterial)));
}
}

if (EntityManager.TryGetComponent<FingerprintComponent>(playerUid, out var fingerprint))
{
f.Fingerprints.Add(fingerprint.Fingerprint ?? "");
}

return target;
}

[CommandImplementation]
public IEnumerable<EntityUid> MakeFakeFingerprint(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> target,
[CommandArgument] ValueRef<ICommonSession> playerRef
)
=> target.Select(x => MakeFakeFingerprint(ctx, x, playerRef)).Where(x => x is not null)
.Select(x => (EntityUid) x!);
}
77 changes: 77 additions & 0 deletions Content.Server/Backmen/Disease/Effects/DiseaseCyborgConversion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Content.Server.Humanoid;
using Content.Server.Repairable;
using Content.Shared.Backmen.Disease;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;

namespace Content.Server.Backmen.Disease.Effects;

public sealed partial class DiseaseCyborgConversion : DiseaseEffect
{
public override object GenerateEvent(Entity<DiseaseCarrierComponent> ent, ProtoId<DiseasePrototype> disease)
{
return new DiseaseEffectArgs<DiseaseCyborgConversion>(ent, disease, this);
}
}

public sealed partial class DiseaseEffectSystem
{
[Dependency] private readonly HumanoidAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly MetaDataSystem _metaDataSystem = default!;

private void DiseaseCyborgConversion(Entity<DiseaseCarrierComponent> ent,
ref DiseaseEffectArgs<DiseaseCyborgConversion> args)
{
if (args.Handled)
return;
args.Handled = true;

if (TryComp<MobThresholdsComponent>(ent, out var thresholdsComponent))
{
(thresholdsComponent as dynamic).AllowRevives = true;
}

var repairableComponent = EnsureComp<RepairableComponent>(ent);
repairableComponent.AllowSelfRepair = true;
repairableComponent.SelfRepairPenalty = 0.45f;
repairableComponent.FuelCost = 10;
repairableComponent.DoAfterDelay = 8;

_disease.CureDisease(ent, args.Disease);
if (TryComp<HumanoidAppearanceComponent>(ent, out var appearanceComponent))
{
_appearanceSystem.SetSex(ent, Sex.Female, true, appearanceComponent);
_appearanceSystem.SetSkinColor(ent, Color.Red, true, true, appearanceComponent);
_appearanceSystem.SetTTSVoice(ent, "Baya", appearanceComponent);
if (appearanceComponent.MarkingSet.Markings.TryGetValue(MarkingCategories.Tail, out var tails))
{
foreach (var marking in tails)
{
_appearanceSystem.RemoveMarking(ent, marking.MarkingId);
}
}

if (appearanceComponent.MarkingSet.Markings.TryGetValue(MarkingCategories.HeadTop, out var headtop))
{
foreach (var marking in headtop)
{
_appearanceSystem.RemoveMarking(ent, marking.MarkingId);
}
}

_appearanceSystem.AddMarking(ent, "MothAntennasFeathery", Color.Red, true, true, appearanceComponent);
_appearanceSystem.AddMarking(ent, "TailSuccubus", Color.Red, true, true, appearanceComponent);
appearanceComponent.Age = 1;
appearanceComponent.EyeColor = Color.Red;
appearanceComponent.Gender = Gender.Epicene;
_metaDataSystem.SetEntityDescription(ent,
"Рободьявол. Кажется, это можно починить сваркой даже если оно умерло");
Dirty(ent, appearanceComponent);
_popup.PopupPredicted("Кажется у вас в теле что-то поменялось....", ent, null, PopupType.LargeCaution);
}
}
}
Loading

0 comments on commit 25ef11f

Please sign in to comment.