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

Fix a bunch of warnings #9528

Merged
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
14 changes: 6 additions & 8 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

_jobPriorities = new List<JobPrioritySelector>();
_jobCategories = new Dictionary<string, BoxContainer>();
var spriteSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SpriteSystem>();

var firstCategory = true;

Expand Down Expand Up @@ -389,7 +390,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt
_jobList.AddChild(category);
}

var selector = new JobPrioritySelector(job);
var selector = new JobPrioritySelector(job, spriteSystem);
category.AddChild(selector);
_jobPriorities.Add(selector);

Expand Down Expand Up @@ -991,7 +992,7 @@ public JobPriority Priority

public event Action<JobPriority>? PriorityChanged;

public JobPrioritySelector(JobPrototype job)
public JobPrioritySelector(JobPrototype job, SpriteSystem sprites)
{
Job = job;

Expand Down Expand Up @@ -1020,12 +1021,9 @@ public JobPrioritySelector(JobPrototype job)
Stretch = TextureRect.StretchMode.KeepCentered
};

if (job.Icon != null)
{
var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"),
job.Icon);
icon.Texture = specifier.Frame0();
}
var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"),
job.Icon);
icon.Texture = sprites.Frame0(specifier);

AddChild(new BoxContainer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ protected override void Dispose(bool disposing)

private void OnStopAutodockPressed(EntityUid obj)
{
SendMessage(new StopAutodockRequestMessage() {Entity = obj});
SendMessage(new StopAutodockRequestMessage() {DockEntity = obj});
}

private void OnAutodockPressed(EntityUid obj)
{
SendMessage(new AutodockRequestMessage() {Entity = obj});
SendMessage(new AutodockRequestMessage() {DockEntity = obj});
}

private void OnUndockPressed(EntityUid obj)
{
SendMessage(new UndockRequestMessage() {Entity = obj});
SendMessage(new UndockRequestMessage() {DockEntity = obj});
}

private void OnShuttleModePressed(ShuttleMode obj)
Expand Down
38 changes: 20 additions & 18 deletions Content.Server/Bible/BibleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Shared.Actions;
using Content.Server.Cooldown;
using Content.Server.Bible.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Robust.Shared.Random;
using Robust.Shared.Audio;
Expand All @@ -25,6 +26,7 @@ public sealed class BibleSystem : EntitySystem
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;

public override void Initialize()
{
Expand All @@ -37,8 +39,8 @@ public override void Initialize()
SubscribeLocalEvent<FamiliarComponent, MobStateChangedEvent>(OnFamiliarDeath);
}

private Queue<EntityUid> AddQueue = new();
private Queue<EntityUid> RemQueue = new();
private readonly Queue<EntityUid> _addQueue = new();
private readonly Queue<EntityUid> _remQueue = new();

/// <summary>
/// This handles familiar respawning.
Expand All @@ -47,17 +49,17 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

foreach(var entity in AddQueue)
foreach(var entity in _addQueue)
{
EnsureComp<SummonableRespawningComponent>(entity);
}
AddQueue.Clear();
_addQueue.Clear();

foreach(var entity in RemQueue)
foreach(var entity in _remQueue)
{
RemComp<SummonableRespawningComponent>(entity);
}
RemQueue.Clear();
_remQueue.Clear();

foreach (var (respawning, summonableComp) in EntityQuery<SummonableRespawningComponent, SummonableComponent>())
{
Expand All @@ -66,7 +68,7 @@ public override void Update(float frameTime)
{
continue;
}
/// Clean up the old body
// Clean up the old body
if (summonableComp.Summon != null)
{
EntityManager.DeleteEntity(summonableComp.Summon.Value);
Expand All @@ -75,9 +77,9 @@ public override void Update(float frameTime)
summonableComp.AlreadySummoned = false;
_popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", summonableComp.Owner)), summonableComp.Owner, Filter.Pvs(summonableComp.Owner));
SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(summonableComp.Owner), summonableComp.Owner, AudioParams.Default.WithVolume(-4f));
/// Clean up the accumulator and respawn tracking component
// Clean up the accumulator and respawn tracking component
summonableComp.Accumulator = 0;
RemQueue.Enqueue(respawning.Owner);
_remQueue.Enqueue(respawning.Owner);
}
}

Expand All @@ -92,9 +94,8 @@ private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInter
{
return;
}

if (args.Target == null || args.Target == args.User || !TryComp<MobStateComponent>(args.Target, out var mobState)
|| mobState.IsDead())

if (args.Target == null || args.Target == args.User || _mobStateSystem.IsDead(args.Target.Value))
{
return;
}
Expand Down Expand Up @@ -152,8 +153,9 @@ private void AddSummonVerb(EntityUid uid, SummonableComponent component, GetVerb
{
Act = () =>
{
TransformComponent? position = Comp<TransformComponent>(args.User);
AttemptSummon(component, args.User, position);
if (!TryComp<TransformComponent>(args.User, out var userXform)) return;

AttemptSummon(component, args.User, userXform);
},
Text = Loc.GetString("bible-summon-verb"),
Priority = 2
Expand All @@ -179,13 +181,13 @@ private void OnSummon(EntityUid uid, SummonableComponent component, SummonAction
/// </summary>
private void OnFamiliarDeath(EntityUid uid, FamiliarComponent component, MobStateChangedEvent args)
{
if (!args.Component.IsDead() || component.Source == null)
if (args.CurrentMobState != DamageState.Dead || component.Source == null)
return;

var source = component.Source;
if (source != null && TryComp<SummonableComponent>(source, out var summonable))
{
AddQueue.Enqueue(summonable.Owner);
_addQueue.Enqueue(summonable.Owner);
}
}

Expand All @@ -207,10 +209,10 @@ private void AttemptSummon(SummonableComponent component, EntityUid user, Transf
var familiar = EntityManager.SpawnEntity(component.SpecialItemPrototype, position.Coordinates);
component.Summon = familiar;

/// We only want to add the familiar component to mobs
// We only want to add the familiar component to mobs
if (HasComp<MobStateComponent>(familiar))
{
/// Make this Summon the familiar's source
// Make this Summon the familiar's source
var familiarComp = EnsureComp<FamiliarComponent>(familiar);
familiarComp.Source = component.Owner;
}
Expand Down
14 changes: 8 additions & 6 deletions Content.Server/Chat/SuicideSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Server.Hands.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
Expand All @@ -20,6 +21,7 @@ public sealed class SuicideSystem : EntitySystem
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;

public bool Suicide(EntityUid victim)
{
Expand All @@ -30,7 +32,7 @@ public bool Suicide(EntityUid victim)
}

// Checks to see if the player is dead.
if (!EntityManager.TryGetComponent<MobStateComponent>(victim, out var mobState) || mobState.IsDead())
if (!TryComp<MobStateComponent>(victim, out var mobState) || _mobState.IsDead(victim, mobState))
{
return false;
}
Expand All @@ -41,7 +43,7 @@ public bool Suicide(EntityUid victim)
var suicideEvent = new SuicideEvent(victim);

// If you are critical, you wouldn't be able to use your surroundings to suicide, so you do the default suicide
if (!mobState.IsCritical())
if (!_mobState.IsCritical(victim, mobState))
{
EnvironmentSuicideHandler(victim, suicideEvent);
}
Expand All @@ -54,7 +56,6 @@ public bool Suicide(EntityUid victim)
/// <summary>
/// If not handled, does the default suicide, which is biting your own tongue
/// </summary>
/// <param name="victim">The person attempting to die</param>
private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
{
if (suicideEvent.Handled) return;
Expand All @@ -69,24 +70,25 @@ private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicide
/// <summary>
/// Raise event to attempt to use held item, or surrounding entities to commit suicide
/// </summary>
/// <param name="victim">The person attempting to die</param>
private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
{
// Suicide by held item
if (EntityManager.TryGetComponent(victim, out HandsComponent? handsComponent)
&& handsComponent.ActiveHandEntity is EntityUid item)
&& handsComponent.ActiveHandEntity is { } item)
{
RaiseLocalEvent(item, suicideEvent, false);

if (suicideEvent.Handled)
return;
}

var itemQuery = GetEntityQuery<SharedItemComponent>();

// Suicide by nearby entity (ex: Microwave)
foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Anchored))
{
// Skip any nearby items that can be picked up, we already checked the active held item above
if (EntityManager.HasComponent<SharedItemComponent>(entity))
if (itemQuery.HasComponent(entity))
continue;

RaiseLocalEvent(entity, suicideEvent, false);
Expand Down
23 changes: 1 addition & 22 deletions Content.Server/Salvage/SalvageMobRestrictionsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Damage;
using Content.Shared.Damage;
using Content.Server.Body.Components;
using Robust.Server.Maps;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;

namespace Content.Server.Salvage;

Expand Down Expand Up @@ -50,7 +29,7 @@ private void OnInit(EntityUid uid, SalvageMobRestrictionsComponent component, Co
{
rg = AddComp<SalvageMobRestrictionsGridComponent>(gridUid);
}
rg!.MobsToKill.Add(uid);
rg.MobsToKill.Add(uid);
component.LinkedGridEntity = gridUid;
}

Expand Down
16 changes: 8 additions & 8 deletions Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,39 @@ private void UpdateAutodock()

private void OnRequestUndock(EntityUid uid, ShuttleConsoleComponent component, UndockRequestMessage args)
{
_sawmill.Debug($"Received undock request for {ToPrettyString(args.Entity)}");
_sawmill.Debug($"Received undock request for {ToPrettyString(args.DockEntity)}");

// TODO: Validation
if (!TryComp<DockingComponent>(args.Entity, out var dock) ||
if (!TryComp<DockingComponent>(args.DockEntity, out var dock) ||
!dock.Docked) return;

Undock(dock);
}

private void OnRequestAutodock(EntityUid uid, ShuttleConsoleComponent component, AutodockRequestMessage args)
{
_sawmill.Debug($"Received autodock request for {ToPrettyString(args.Entity)}");
_sawmill.Debug($"Received autodock request for {ToPrettyString(args.DockEntity)}");
var player = args.Session.AttachedEntity;

if (player == null || !HasComp<DockingComponent>(args.Entity)) return;
if (player == null || !HasComp<DockingComponent>(args.DockEntity)) return;

// TODO: Validation
var comp = EnsureComp<AutoDockComponent>(args.Entity);
var comp = EnsureComp<AutoDockComponent>(args.DockEntity);
comp.Requesters.Add(player.Value);
}

private void OnRequestStopAutodock(EntityUid uid, ShuttleConsoleComponent component, StopAutodockRequestMessage args)
{
_sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.Entity)}");
_sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.DockEntity)}");

var player = args.Session.AttachedEntity;

// TODO: Validation
if (player == null || !TryComp<AutoDockComponent>(args.Entity, out var comp)) return;
if (player == null || !TryComp<AutoDockComponent>(args.DockEntity, out var comp)) return;

comp.Requesters.Remove(player.Value);

if (comp.Requesters.Count == 0)
RemComp<AutoDockComponent>(args.Entity);
RemComp<AutoDockComponent>(args.DockEntity);
}
}
4 changes: 2 additions & 2 deletions Content.Server/Weapon/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ private void PlayHitSound(EntityUid target, string? type, SoundSpecifier? hitSou
}
else if (type != null && damageSoundComp.SoundTypes?.TryGetValue(type, out var damageSoundType) == true)
{
SoundSystem.Play(damageSoundType!.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation));
SoundSystem.Play(damageSoundType.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation));
playedSound = true;
}
else if (type != null && damageSoundComp.SoundGroups?.TryGetValue(type, out var damageSoundGroup) == true)
{
SoundSystem.Play(damageSoundGroup!.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation));
SoundSystem.Play(damageSoundGroup.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation));
playedSound = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Alert/AlertKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Content.Shared.Alert;
/// falls back to the id.
/// </summary>
[Serializable, NetSerializable]
public struct AlertKey : ISerializationHooks, IPopulateDefaultValues
public struct AlertKey :IPopulateDefaultValues
{
public AlertType? AlertType { get; private set; }
public readonly AlertCategory? AlertCategory;
Expand Down Expand Up @@ -58,4 +58,4 @@ public static AlertKey ForCategory(AlertCategory category)
{
return new(null, category);
}
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Body/Components/MechanismComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Content.Shared.Body.Components
{
[RegisterComponent]
public sealed class MechanismComponent : Component, ISerializationHooks
public sealed class MechanismComponent : Component
{
[Dependency] private readonly IEntityManager _entMan = default!;
private SharedBodyPartComponent? _part;
Expand Down
Loading