Санитизация
This commit is contained in:
@@ -4,8 +4,8 @@ using Content.Shared._White._Engi.BucketHelmet;
|
||||
namespace Content.Server._White._Engi.BucketHelmet;
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// This handles placemet of PreventStrippingFromEarsComponent when bucket helmet is in use.
|
||||
/// WD Engi Exclusive.
|
||||
/// </summary>
|
||||
public sealed class BucketHelmetSystem : EntitySystem
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@ using Robust.Shared.Audio;
|
||||
namespace Content.Server._White._Engi.PacifiedOnChaplainAction
|
||||
{
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// Adds verb for chaplain to pacify entity.
|
||||
/// WD Engi Exclusive.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class PacifiedOnChaplainActionComponent : Component
|
||||
|
||||
@@ -12,7 +12,7 @@ using Content.Shared.Database;
|
||||
namespace Content.Server._White._Engi.PacifiedOnChaplainAction
|
||||
{
|
||||
/// <summary>
|
||||
/// WD Engi Exclusive.
|
||||
/// WD
|
||||
/// </summary>
|
||||
public sealed class PacifiedOnChaplainAction : EntitySystem
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Prototypes;
|
||||
namespace Content.Server._White._Engi.StationGoal
|
||||
{
|
||||
/// <summary>
|
||||
/// WD ENGI EXCLUSIVE.
|
||||
/// WD.
|
||||
/// If attached to a station prototype, will send the station a random goal from the list.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Content.Server._White._Engi.StationGoal
|
||||
{
|
||||
/// <summary>
|
||||
/// WD ENGI EXCLUSIVE.
|
||||
/// WD.
|
||||
/// Paper with a written station goal in it.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
|
||||
@@ -12,7 +12,7 @@ using Content.Server.RandomMetadata;
|
||||
namespace Content.Server._White._Engi.StationGoal
|
||||
{
|
||||
/// <summary>
|
||||
/// WD ENGI EXCLUSIVE.
|
||||
/// WD.
|
||||
/// System to spawn paper with station goal.
|
||||
/// </summary>
|
||||
public sealed class StationGoalPaperSystem : EntitySystem
|
||||
@@ -71,7 +71,6 @@ namespace Content.Server._White._Engi.StationGoal
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WD ENGI EXCLUSIVE.
|
||||
/// Send a station goal on selected station to all faxes which are authorized to receive it.
|
||||
/// </summary>
|
||||
/// <returns>True if at least one fax received paper</returns>
|
||||
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Prototypes;
|
||||
namespace Content.Server._White._Engi.StationGoal
|
||||
{
|
||||
/// <summary>
|
||||
/// WD ENGI EXCLUSIVE.
|
||||
/// WD
|
||||
/// </summary>
|
||||
[Serializable, Prototype("stationGoal")]
|
||||
public sealed class StationGoalPrototype : IPrototype
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Content.Shared.Chat.Prototypes;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server._White._Engi.Suhariki;
|
||||
|
||||
/// <summary>
|
||||
/// Makes you loose your tooth and have funny accent.
|
||||
/// WD Engi Exclusive.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(SuharikiSystem))]
|
||||
public sealed partial class SuharikiComponent : Component
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount and type of damage that will be dealt on event.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier Damage = new();
|
||||
|
||||
/// <summary>
|
||||
/// Chance of event activation.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Chance = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of rolls for event.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int StonesInFood = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype that will be spawned on event.
|
||||
/// </summary>
|
||||
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string HoldingPrototype = "SuharikiTooth";
|
||||
|
||||
/// <summary>
|
||||
/// Emote triggered on event.
|
||||
/// </summary>
|
||||
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
|
||||
public string EmoteId = "Scream";
|
||||
|
||||
/// <summary>
|
||||
/// Sound triggered on event.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/White/_Engi/Object/Misc/Suhariki/tooth_break.ogg");
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Nutrition.EntitySystems;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Server.Effects;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Speech.Components;
|
||||
|
||||
namespace Content.Server._White._Engi.Suhariki;
|
||||
|
||||
/// <summary>
|
||||
/// WD Engi Exclusive.
|
||||
/// </summary>
|
||||
public sealed class SuharikiSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly ColorFlashEffectSystem _color = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
[Dependency] private readonly FoodSystem _food = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly BodySystem _body = default!;
|
||||
private EntityQuery<MetaDataComponent> _metaQuery;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_metaQuery = GetEntityQuery<MetaDataComponent>();
|
||||
SubscribeLocalEvent<SuharikiComponent, UseInHandEvent>(OnUseInHand, after: new[] { typeof(OpenableSystem), typeof(ServerInventorySystem) });
|
||||
SubscribeLocalEvent<SuharikiComponent, GetVerbsEvent<AlternativeVerb>>(AddEatVerb);
|
||||
}
|
||||
|
||||
private void OnUseInHand(Entity<SuharikiComponent> entity, ref UseInHandEvent ev)
|
||||
{
|
||||
if (ev.Handled)
|
||||
return;
|
||||
|
||||
var result = TryUse(ev.User, ev.User, entity, entity.Comp);
|
||||
ev.Handled = result.Handled;
|
||||
}
|
||||
|
||||
private (bool Success, bool Handled) TryUse(EntityUid user, EntityUid target, EntityUid food, SuharikiComponent scomponent)
|
||||
{
|
||||
var foodComponents = _metaQuery.GetComponent(food).EntityPrototype;
|
||||
|
||||
if (foodComponents == null)
|
||||
return (false, false);
|
||||
|
||||
foodComponents.Components.TryGetComponent("Food", out var component);
|
||||
|
||||
if (component == null)
|
||||
return (false, false);
|
||||
|
||||
// idk what I'm doing but otherwise the owner is "0" and it throws fatal error
|
||||
component.Owner = food;
|
||||
|
||||
var result = _food.TryFeed(user, target, food, (FoodComponent) component);
|
||||
|
||||
if (result.Success)
|
||||
Timer.Spawn(300, () => RollEvent(scomponent, user));
|
||||
|
||||
return (true, true);
|
||||
}
|
||||
|
||||
private void RollEvent(SuharikiComponent scomponent, EntityUid user)
|
||||
{
|
||||
if (scomponent.StonesInFood < 1)
|
||||
return;
|
||||
|
||||
scomponent.StonesInFood -= 1;
|
||||
|
||||
// Pseudorandom shit
|
||||
if (!_random.Prob(scomponent.Chance))
|
||||
return;
|
||||
|
||||
// Normally slimes don't care about hard food
|
||||
var whomst = _metaQuery.GetComponent(user).EntityPrototype;
|
||||
var isUserSlime = whomst!.ID.Contains("slime", StringComparison.OrdinalIgnoreCase);
|
||||
if (isUserSlime)
|
||||
return;
|
||||
|
||||
var modifiedDamage = _damageableSystem.TryChangeDamage(user, scomponent.Damage, true);
|
||||
var deleted = Deleted(user);
|
||||
if (modifiedDamage is null || !EntityManager.EntityExists(user))
|
||||
return;
|
||||
if (!modifiedDamage.Any() || deleted)
|
||||
return;
|
||||
// Damaging the user with appropriate effects
|
||||
var stringTopopup = Loc.GetString("suhariki-lost", ("user", user));
|
||||
_popup.PopupEntity(Name(user) + " " + stringTopopup, user, Shared.Popups.PopupType.LargeCaution);
|
||||
_color.RaiseEffect(Color.Red, new List<EntityUid> { user }, Filter.Pvs(user, entityManager: EntityManager));
|
||||
_audio.PlayPvs(scomponent.UseSound, user, AudioParams.Default.WithVolume(-1f));
|
||||
_adminLogger.Add(LogType.Damaged,
|
||||
LogImpact.Medium,
|
||||
$"This idiot {ToPrettyString(user):user} tried to eat Suhariki and lost tooth, received {modifiedDamage.GetTotal():damage} damage and recieved FrontalLisp accent");
|
||||
|
||||
// Spawns prototype
|
||||
var coords = Transform(user).Coordinates;
|
||||
Spawn(scomponent.HoldingPrototype, coords.Offset(_random.NextVector2(0.2f)));
|
||||
|
||||
// Scream
|
||||
Timer.Spawn(300, () => _chat.TryEmoteWithChat(user, scomponent.EmoteId));
|
||||
|
||||
// Adding FrontalLisp accent
|
||||
EnsureComp<FrontalLispComponent>(user);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
private void AddEatVerb(Entity<SuharikiComponent> entity, ref GetVerbsEvent<AlternativeVerb> ev)
|
||||
{
|
||||
if (entity.Owner == ev.User ||
|
||||
!ev.CanInteract ||
|
||||
!ev.CanAccess ||
|
||||
!TryComp<BodyComponent>(ev.User, out var body) ||
|
||||
!_body.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs))
|
||||
return;
|
||||
|
||||
var user = ev.User;
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
TryUse(user, user, entity, entity.Comp);
|
||||
},
|
||||
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/cutlery.svg.192dpi.png")),
|
||||
Text = Loc.GetString("food-system-verb-eat"),
|
||||
Priority = -1
|
||||
};
|
||||
|
||||
ev.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user