Fix a bunch of warnings (#9528)

This commit is contained in:
metalgearsloth
2022-07-09 09:07:47 +10:00
committed by GitHub
parent 9f80b7b68a
commit 4a393d4665
16 changed files with 65 additions and 82 deletions

View File

@@ -341,6 +341,7 @@ namespace Content.Client.Preferences.UI
_jobPriorities = new List<JobPrioritySelector>();
_jobCategories = new Dictionary<string, BoxContainer>();
var spriteSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SpriteSystem>();
var firstCategory = true;
@@ -389,7 +390,7 @@ namespace Content.Client.Preferences.UI
_jobList.AddChild(category);
}
var selector = new JobPrioritySelector(job);
var selector = new JobPrioritySelector(job, spriteSystem);
category.AddChild(selector);
_jobPriorities.Add(selector);
@@ -991,7 +992,7 @@ namespace Content.Client.Preferences.UI
public event Action<JobPriority>? PriorityChanged;
public JobPrioritySelector(JobPrototype job)
public JobPrioritySelector(JobPrototype job, SpriteSystem sprites)
{
Job = job;
@@ -1020,12 +1021,9 @@ namespace Content.Client.Preferences.UI
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();
}
icon.Texture = sprites.Frame0(specifier);
AddChild(new BoxContainer
{

View File

@@ -43,17 +43,17 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
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)

View File

@@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker;
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;
@@ -25,6 +26,7 @@ namespace Content.Server.Bible
[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()
{
@@ -37,8 +39,8 @@ namespace Content.Server.Bible
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.
@@ -47,17 +49,17 @@ namespace Content.Server.Bible
{
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>())
{
@@ -66,7 +68,7 @@ namespace Content.Server.Bible
{
continue;
}
/// Clean up the old body
// Clean up the old body
if (summonableComp.Summon != null)
{
EntityManager.DeleteEntity(summonableComp.Summon.Value);
@@ -75,9 +77,9 @@ namespace Content.Server.Bible
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);
}
}
@@ -93,8 +95,7 @@ namespace Content.Server.Bible
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;
}
@@ -152,8 +153,9 @@ namespace Content.Server.Bible
{
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
@@ -179,13 +181,13 @@ namespace Content.Server.Bible
/// </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);
}
}
@@ -207,10 +209,10 @@ namespace Content.Server.Bible
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;
}

View File

@@ -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;
@@ -20,6 +21,7 @@ namespace Content.Server.Chat
[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)
{
@@ -30,7 +32,7 @@ namespace Content.Server.Chat
}
// 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;
}
@@ -41,7 +43,7 @@ namespace Content.Server.Chat
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);
}
@@ -54,7 +56,6 @@ namespace Content.Server.Chat
/// <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;
@@ -69,12 +70,11 @@ namespace Content.Server.Chat
/// <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);
@@ -82,11 +82,13 @@ namespace Content.Server.Chat
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);

View File

@@ -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;
@@ -50,7 +29,7 @@ public sealed class SalvageMobRestrictionsSystem : EntitySystem
{
rg = AddComp<SalvageMobRestrictionsGridComponent>(gridUid);
}
rg!.MobsToKill.Add(uid);
rg.MobsToKill.Add(uid);
component.LinkedGridEntity = gridUid;
}

View File

@@ -66,10 +66,10 @@ public sealed partial class DockingSystem
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);
@@ -77,28 +77,28 @@ public sealed partial class DockingSystem
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);
}
}

View File

@@ -259,12 +259,12 @@ namespace Content.Server.Weapon.Melee
}
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;
}
}

View File

@@ -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;

View File

@@ -5,7 +5,7 @@ using Robust.Shared.Serialization;
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;

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.MobState.EntitySystems;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Map;
@@ -15,6 +16,7 @@ namespace Content.Shared.Examine
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] protected readonly SharedMobStateSystem MobStateSystem = default!;
public const float MaxRaycastRange = 100;
@@ -43,8 +45,8 @@ namespace Content.Shared.Examine
public bool IsInDetailsRange(EntityUid examiner, EntityUid entity)
{
// check if the mob is in ciritcal or dead
if (EntityManager.TryGetComponent(examiner, out MobStateComponent? mobState) && mobState.IsIncapacitated())
// check if the mob is in critical or dead
if (MobStateSystem.IsIncapacitated(examiner))
return false;
if (!_interactionSystem.InRangeUnobstructed(examiner, entity, ExamineDetailsRange))
@@ -94,9 +96,9 @@ namespace Content.Shared.Examine
{
if (Resolve(examiner, ref mobState, logMissing: false))
{
if (mobState.IsDead())
if (MobStateSystem.IsDead(examiner, mobState))
return DeadExamineRange;
else if (mobState.IsCritical())
else if (MobStateSystem.IsCritical(examiner, mobState))
return CritExamineRange;
}
return ExamineRange;

View File

@@ -37,7 +37,7 @@ namespace Content.Shared.Hands.Components
_blockingEntity = pullState.BlockingEntity;
// update hands GUI with new entity.
if (Owner.TryGetContainer(out var containter))
if (Owner.TryGetContainer(out _))
EntitySystem.Get<SharedItemSystem>().VisualsChanged(Owner);
}

View File

@@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events;
[Serializable, NetSerializable]
public sealed class AutodockRequestMessage : BoundUserInterfaceMessage
{
public EntityUid Entity;
public EntityUid DockEntity;
}

View File

@@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events;
[Serializable, NetSerializable]
public sealed class StopAutodockRequestMessage : BoundUserInterfaceMessage
{
public EntityUid Entity;
public EntityUid DockEntity;
}

View File

@@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events;
[Serializable, NetSerializable]
public sealed class UndockRequestMessage : BoundUserInterfaceMessage
{
public EntityUid Entity;
public EntityUid DockEntity;
}

View File

@@ -5,7 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Shared.Stacks
{
[NetworkedComponent, Access(typeof(SharedStackSystem))]
public abstract class SharedStackComponent : Component, ISerializationHooks
public abstract class SharedStackComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("stackType", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]

View File

@@ -34,7 +34,7 @@ namespace Content.Shared.Wires
}
[Serializable, NetSerializable]
public class WiresActionMessage : BoundUserInterfaceMessage
public sealed class WiresActionMessage : BoundUserInterfaceMessage
{
public readonly int Id;
public readonly WiresAction Action;
@@ -116,7 +116,7 @@ namespace Content.Shared.Wires
}
[Serializable, NetSerializable]
public class WiresBoundUserInterfaceState : BoundUserInterfaceState
public sealed class WiresBoundUserInterfaceState : BoundUserInterfaceState
{
public string BoardName { get; }
public string? SerialNumber { get; }
@@ -167,7 +167,7 @@ namespace Content.Shared.Wires
/// what wires there are on an entity.
/// </summary>
[Serializable, NetSerializable]
public class ClientWire
public sealed class ClientWire
{
/// <summary>
/// ID of this wire, which corresponds to