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

@@ -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);
}
}
@@ -92,9 +94,8 @@ 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;
}
}