Мелочи (#872)

This commit is contained in:
BIGZi0348
2025-01-05 23:40:31 +03:00
committed by GitHub
19 changed files with 291 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ public sealed class RandomArtifactsSystem : EntitySystem
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.4%
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.5%
private bool _artifactsEnabled;
public override void Initialize()
@@ -76,7 +76,7 @@ public sealed class RandomArtifactsSystem : EntitySystem
continue;
// var artifactComponent = EnsureComp<ArtifactComponent>(entity);
var comp = (ArtifactComponent) _componentFactory.GetComponent("Artifact");
var comp = (ArtifactComponent)_componentFactory.GetComponent("Artifact");
comp.Owner = entity;
_artifactsSystem.SafeRandomizeArtifact(entity, ref comp);
AddComp(entity, comp);
@@ -88,7 +88,7 @@ public sealed class RandomArtifactsSystem : EntitySystem
private HashSet<ItemComponent> GetPercentageOfHashSet(List<ItemComponent> sourceList, float percentage)
{
var countToAdd = (int) Math.Round((double) sourceList.Count * percentage / 100);
var countToAdd = (int)Math.Round((double)sourceList.Count * percentage / 100);
return sourceList.Where(x => !Transform(x.Owner).Anchored).Take(countToAdd).ToHashSet();
}

View File

@@ -0,0 +1,22 @@
using Content.Shared.Standing.Systems;
namespace Content.Server._White._Engi.DirectBallsHit;
[RegisterComponent]
public sealed partial class DirectBallsHitComponent : Component
{
[DataField]
public TimeSpan KnockdownTime = TimeSpan.FromSeconds(2.0f);
[DataField]
public TimeSpan JitterTime = TimeSpan.FromSeconds(2.0f);
[DataField]
public TimeSpan StutterTime = TimeSpan.FromSeconds(2.0f);
[DataField]
public SharedStandingStateSystem.DropHeldItemsBehavior KnockDownBehavior = SharedStandingStateSystem.DropHeldItemsBehavior.AlwaysDrop;
[DataField]
public bool RequireWield = true;
}

View File

@@ -0,0 +1,68 @@
using Content.Shared.Stunnable;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Wieldable.Components;
using Content.Shared.Jittering;
using Content.Shared.Speech.EntitySystems;
using Content.Shared.StatusEffect;
using Content.Shared.Standing;
using Content.Shared.Electrocution;
using Content.Shared.Popups;
using Content.Shared._White.Implants.NeuroControl;
using Robust.Shared.Timing;
using Content.Server.Chat.Systems;
namespace Content.Server._White._Engi.DirectBallsHit;
public sealed class DirectBallsHitSystem : EntitySystem
{
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly SharedJitteringSystem _jitter = default!;
[Dependency] private readonly SharedStutteringSystem _stutter = default!;
[Dependency] private readonly SharedElectrocutionSystem _electrocution = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly ChatSystem _chat = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DirectBallsHitComponent, MeleeHitEvent>(OnHit);
}
private void OnHit(Entity<DirectBallsHitComponent> ent, ref MeleeHitEvent args)
{
if (ent.Comp.RequireWield)
{
if (!TryComp<WieldableComponent>(args.Weapon, out var weapon))
return;
if (!weapon.Wielded)
return;
}
foreach (var uid in args.HitEntities)
{
_popupSystem.PopupEntity(
Loc.GetString("direct-balls-hit", ("uid", uid)),
uid,
PopupType.SmallCaution);
Timer.Spawn(TimeSpan.FromSeconds(0.5f), () => _chat.TryEmoteWithChat(uid, "Scream"));
if (HasComp<NeuroStabilizationComponent>(uid))
{
_electrocution.TryDoElectrocution(uid, null, 30, TimeSpan.FromSeconds(1), false, 0.5f, null, true);
continue;
}
if (TryComp(uid, out StandingStateComponent? standingState) && standingState.CanLieDown)
_stun.TryKnockdown(uid, ent.Comp.KnockdownTime, true, behavior: ent.Comp.KnockDownBehavior);
if (TryComp(uid, out StatusEffectsComponent? statusEffects))
{
_jitter.DoJitter(uid, ent.Comp.JitterTime, true, status: statusEffects);
_stutter.DoStutter(uid, ent.Comp.StutterTime, true, statusEffects);
}
}
}
}