Skip to content

Commit

Permalink
Merge branch 'Rxup:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDarl authored Dec 4, 2023
2 parents 2089d68 + 06598a0 commit 6f3e7f0
Show file tree
Hide file tree
Showing 51 changed files with 408 additions and 131 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void UpdateUI()
OverrideDirection = Direction.South,
Scale = new Vector2(4f, 4f),
MaxSize = new Vector2(112, 112),
Stretch = SpriteView.StretchMode.None,
Stretch = SpriteView.StretchMode.Fill,
};
spriteView.SetEntity(_previewDummy.Value);
_viewBox.AddChild(spriteView);
Expand Down
7 changes: 7 additions & 0 deletions Content.Client/Overlays/ShowSecurityIconsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Mindshield.Components;
using Content.Shared.Overlays;
using Content.Shared.PDA;
using Content.Shared.StatusIcon;
Expand Down Expand Up @@ -66,6 +67,12 @@ private IReadOnlyList<StatusIconPrototype> DecideSecurityIcon(EntityUid uid)
else
Log.Error($"Invalid job icon prototype: {jobIcon}");

if (TryComp<MindShieldComponent>(uid, out var comp))
{
if (_prototypeMan.TryIndex<StatusIconPrototype>(comp.MindShieldStatusIcon.Id, out var icon))
result.Add(icon);
}

// Add arrest icons here, WYCI.

return result;
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Anomaly/AnomalySystem.Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ private void OnScannerAfterInteract(EntityUid uid, AnomalyScannerComponent compo
return;
if (!HasComp<AnomalyComponent>(target))
return;
if (!args.CanReach)
return;

_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid)
{
Expand Down
25 changes: 14 additions & 11 deletions Content.Server/Botany/Systems/MutationSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Content.Shared.Chemistry.Reagent;
using System.Linq;
using Content.Shared.Atmos;
Expand All @@ -11,11 +13,12 @@ public sealed class MutationSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private List<ReagentPrototype> _allChemicals = default!;
private WeightedRandomFillSolutionPrototype _randomChems = default!;


public override void Initialize()
{
_allChemicals = _prototypeManager.EnumeratePrototypes<ReagentPrototype>().ToList();
_randomChems = _prototypeManager.Index<WeightedRandomFillSolutionPrototype>("RandomPickBotanyReagent");
}

/// <summary>
Expand All @@ -37,7 +40,7 @@ public void MutateSeed(ref SeedData seed, float severity)
}

// Add up everything in the bits column and put the number here.
const int totalbits = 270;
const int totalbits = 275;

// Tolerances (55)
MutateFloat(ref seed.NutrientConsumption , 0.05f, 1.2f, 5, totalbits, severity);
Expand Down Expand Up @@ -81,10 +84,10 @@ public void MutateSeed(ref SeedData seed, float severity)
MutateGasses(ref seed.ConsumeGasses, 0.01f, 0.5f, 1, totalbits, severity);

// Chems (20)
MutateChemicals(ref seed.Chemicals, 5, 20, totalbits, severity);
MutateChemicals(ref seed.Chemicals, 20, totalbits, severity);

// Species (5)
MutateSpecies(ref seed, 5, totalbits, severity);
// Species (10)
MutateSpecies(ref seed, 10, totalbits, severity);
}

public SeedData Cross(SeedData a, SeedData b)
Expand Down Expand Up @@ -246,19 +249,19 @@ private void MutateGasses(ref Dictionary<Gas, float> gasses, float min, float ma
}
}

private void MutateChemicals(ref Dictionary<string, SeedChemQuantity> chemicals, int max, int bits, int totalbits, float mult)
private void MutateChemicals(ref Dictionary<string, SeedChemQuantity> chemicals, int bits, int totalbits, float mult)
{
float probModify = mult * bits / totalbits;
probModify = Math.Clamp(probModify, 0, 1);
if (!Random(probModify))
return;

// Add a random amount of a random chemical to this set of chemicals
ReagentPrototype selectedChemical = _robustRandom.Pick(_allChemicals);
if (selectedChemical != null)
if (_randomChems != null)
{
string chemicalId = selectedChemical.ID;
int amount = _robustRandom.Next(1, max);
var pick = _randomChems.Pick(_robustRandom);
string chemicalId = pick.reagent;
int amount = _robustRandom.Next(1, ((int)pick.quantity));
SeedChemQuantity seedChemQuantity = new SeedChemQuantity();
if (chemicals.ContainsKey(chemicalId))
{
Expand Down
20 changes: 17 additions & 3 deletions Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
Expand All @@ -45,6 +46,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
Expand Down Expand Up @@ -304,14 +306,24 @@ private void OnAfterInteractUsing(EntityUid uid, SharedDisposalUnitComponent com
/// </summary>
private void OnThrowCollide(EntityUid uid, SharedDisposalUnitComponent component, ThrowHitByEvent args)
{
if (!CanInsert(uid, component, args.Thrown) ||
_robustRandom.NextDouble() > 0.75 ||
!component.Container.Insert(args.Thrown))
var canInsert = CanInsert(uid, component, args.Thrown);
var randDouble = _robustRandom.NextDouble();

if (!canInsert || randDouble > 0.75)
{
_audioSystem.PlayPvs(component.MissSound, uid);

_popupSystem.PopupEntity(Loc.GetString("disposal-unit-thrown-missed"), uid);
return;
}

var inserted = _containerSystem.Insert(args.Thrown, component.Container);

if (!inserted)
{
throw new InvalidOperationException("Container insertion failed but CanInsert returned true");
}

if (args.Component.Thrower != null)
_adminLogger.Add(LogType.Landed, LogImpact.Low, $"{ToPrettyString(args.Thrown)} thrown by {ToPrettyString(args.Component.Thrower.Value):player} landed in {ToPrettyString(uid)}");

Expand Down Expand Up @@ -786,6 +798,8 @@ public void QueueAutomaticEngage(EntityUid uid, SharedDisposalUnitComponent comp

public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null)
{
_audioSystem.PlayPvs(component.InsertSound, uid);

if (!component.Container.Insert(inserted))
return;

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Electrocution/ElectrocutionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public bool TryDoElectrifiedAct(EntityUid uid, EntityUid targetUid,
_appearance.SetData(uid, ElectrifiedVisuals.IsPowered, true);

siemens *= electrified.SiemensCoefficient;
if (siemens <= 0 || !DoCommonElectrocutionAttempt(targetUid, uid, ref siemens))
if (!DoCommonElectrocutionAttempt(targetUid, uid, ref siemens) || siemens <= 0)
return false; // If electrocution would fail, do nothing.

var targets = new List<(EntityUid entity, int depth)>();
Expand Down
22 changes: 22 additions & 0 deletions Content.Server/Explosion/Components/RandomTimerTriggerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Content.Server.Explosion.EntitySystems;

namespace Content.Server.Explosion.Components;

/// <summary>
/// This is used for randomizing a <see cref="RandomTimerTriggerComponent"/> on MapInit
/// </summary>
[RegisterComponent, Access(typeof(TriggerSystem))]
public sealed partial class RandomTimerTriggerComponent : Component
{
/// <summary>
/// The minimum random trigger time.
/// </summary>
[DataField]
public float Min;

/// <summary>
/// The maximum random trigger time.
/// </summary>
[DataField]
public float Max;
}
12 changes: 11 additions & 1 deletion Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Player;

namespace Content.Server.Explosion.EntitySystems;

Expand All @@ -18,6 +17,7 @@ private void InitializeOnUse()
SubscribeLocalEvent<OnUseTimerTriggerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<OnUseTimerTriggerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
SubscribeLocalEvent<OnUseTimerTriggerComponent, EntityStuckEvent>(OnStuck);
SubscribeLocalEvent<RandomTimerTriggerComponent, MapInitEvent>(OnRandomTimerTriggerMapInit);
}

private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
Expand Down Expand Up @@ -114,6 +114,16 @@ private void OnGetAltVerbs(EntityUid uid, OnUseTimerTriggerComponent component,
}
}

private void OnRandomTimerTriggerMapInit(Entity<RandomTimerTriggerComponent> ent, ref MapInitEvent args)
{
var (_, comp) = ent;

if (!TryComp<OnUseTimerTriggerComponent>(ent, out var timerTriggerComp))
return;

timerTriggerComp.Delay = _random.NextFloat(comp.Min, comp.Max);
}

private void CycleDelay(OnUseTimerTriggerComponent component, EntityUid user)
{
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;

namespace Content.Server.Explosion.EntitySystems
{
Expand Down Expand Up @@ -62,6 +63,7 @@ public sealed partial class TriggerSystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public override void Initialize()
Expand Down
30 changes: 8 additions & 22 deletions Content.Server/NPC/Systems/NPCRetaliationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
namespace Content.Server.NPC.Systems;

/// <summary>
/// Handles NPC which become aggressive after being attacked.
/// Handles NPC which become aggressive after being attacked.
/// </summary>
public sealed class NPCRetaliationSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly IGameTiming _timing = default!;

private readonly HashSet<EntityUid> _deAggroQueue = new();

/// <inheritdoc/>
/// <inheritdoc />
public override void Initialize()
{
SubscribeLocalEvent<NPCRetaliationComponent, DamageChangedEvent>(OnDamageChanged);
Expand Down Expand Up @@ -54,9 +52,7 @@ public bool TryRetaliate(EntityUid uid, EntityUid target, NPCRetaliationComponen

_npcFaction.AggroEntity(uid, target);
if (component.AttackMemoryLength is { } memoryLength)
{
component.AttackMemories[target] = _timing.CurTime + memoryLength;
}

return true;
}
Expand All @@ -65,25 +61,15 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<NPCRetaliationComponent, FactionExceptionComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var comp, out var factionException, out var metaData))
var query = EntityQueryEnumerator<NPCRetaliationComponent, FactionExceptionComponent>();
while (query.MoveNext(out var uid, out var retaliationComponent, out var factionException))
{
_deAggroQueue.Clear();

foreach (var ent in new ValueList<EntityUid>(comp.AttackMemories.Keys))
foreach (var entity in new ValueList<EntityUid>(retaliationComponent.AttackMemories.Keys))
{
if (_timing.CurTime < comp.AttackMemories[ent])
if (!TerminatingOrDeleted(entity) && _timing.CurTime < retaliationComponent.AttackMemories[entity])
continue;

if (TerminatingOrDeleted(ent, metaData))
_deAggroQueue.Add(ent);

_deAggroQueue.Add(ent);
}

foreach (var ent in _deAggroQueue)
{
_npcFaction.DeAggroEntity(uid, ent, factionException);
_npcFaction.DeAggroEntity(uid, entity, factionException);
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions Content.Shared/Disposal/Components/SharedDisposalUnitComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public abstract partial class SharedDisposalUnitComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField("soundFlush")]
public SoundSpecifier? FlushSound = new SoundPathSpecifier("/Audio/Machines/disposalflush.ogg");

/// <summary>
/// Sound played when an object is inserted into the disposal unit.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("soundInsert")]
public SoundSpecifier? InsertSound = new SoundPathSpecifier("/Audio/Effects/trashbag1.ogg");

/// <summary>
/// Sound played when an item is thrown and misses the disposal unit.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("soundMiss")]
public SoundSpecifier? MissSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");


/// <summary>
/// State for this disposals unit.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Mindshield/Components/MindShieldComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Revolutionary;
using Robust.Shared.GameStates;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;

namespace Content.Shared.Mindshield.Components;

Expand All @@ -9,4 +11,6 @@ namespace Content.Shared.Mindshield.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(SharedRevolutionarySystem))]
public sealed partial class MindShieldComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<StatusIconPrototype> MindShieldStatusIcon = "MindShieldIcon";
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,18 @@ public void ForceSetMovingTo(SharedPullableComponent pullable, EntityCoordinates
RaiseLocalEvent(pullable.Owner, new PullableMoveMessage(), true);
}
}

/// <summary>
/// Changes if the entity needs a hand in order to be able to pull objects.
/// </summary>
public void ChangeHandRequirement(EntityUid uid, bool needsHands, SharedPullerComponent? comp)
{
if (!Resolve(uid, ref comp, false))
return;

comp.NeedsHands = needsHands;

Dirty(uid, comp);
}
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Rounding/ContentHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static int RoundToLevels(double actual, double max, int levels)
}

var preround = toOne * (levels - 1);
if (toOne <= threshold || levels <= 2)
if (toOne < threshold || levels <= 2)
{
return (int) Math.Ceiling(preround);
}
Expand Down
Loading

0 comments on commit 6f3e7f0

Please sign in to comment.