Enable nullability in Content.Server (#3685)

This commit is contained in:
DrSmugleaf
2021-03-16 15:50:20 +01:00
committed by GitHub
parent 90fec0ed24
commit a5ade526b7
306 changed files with 1616 additions and 1441 deletions

View File

@@ -12,7 +12,7 @@ namespace Content.Server.GameObjects.Components.Mobs
public int GetHeatResistance()
{
if (Owner.GetComponent<InventoryComponent>().TryGetSlotItem(EquipmentSlotDefines.Slots.GLOVES, itemComponent: out ClothingComponent gloves))
if (Owner.GetComponent<InventoryComponent>().TryGetSlotItem(EquipmentSlotDefines.Slots.GLOVES, out ClothingComponent? gloves))
{
return gloves?.HeatResistance ?? int.MinValue;
}

View File

@@ -16,11 +16,11 @@ namespace Content.Server.GameObjects.Components.Mobs
{
base.Appearance = value;
if (Owner.TryGetComponent(out IBody body))
if (Owner.TryGetComponent(out IBody? body))
{
foreach (var part in body.Parts.Values)
{
if (!part.Owner.TryGetComponent(out SpriteComponent sprite))
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
{
continue;
}
@@ -35,11 +35,11 @@ namespace Content.Server.GameObjects.Components.Mobs
{
base.Startup();
if (Appearance != null && Owner.TryGetComponent(out IBody body))
if (Appearance != null! && Owner.TryGetComponent(out IBody? body))
{
foreach (var part in body.Parts.Values)
{
if (!part.Owner.TryGetComponent(out SpriteComponent sprite))
if (!part.Owner.TryGetComponent(out SpriteComponent? sprite))
{
continue;
}

View File

@@ -9,8 +9,8 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -115,7 +115,7 @@ namespace Content.Server.GameObjects.Components.Mobs
if (Mind != null)
{
ghost.Name = Mind.CharacterName;
ghost.Name = Mind.CharacterName ?? string.Empty;
Mind.TransferTo(ghost);
}
});

View File

@@ -36,13 +36,13 @@ namespace Content.Server.GameObjects.Components.Mobs
}
else
{
Logger.WarningS("alert", "weightlesssystem not found");
Logger.WarningS("alert", $"{nameof(WeightlessSystem)} not found");
}
base.OnRemove();
}
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null)
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
{
base.HandleNetworkMessage(message, netChannel, session);

View File

@@ -12,22 +12,17 @@ namespace Content.Server.GameObjects.Components.Mobs.State
{
base.EnterState(entity);
if (entity.TryGetComponent(out AppearanceComponent appearance))
if (entity.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Critical);
}
if (entity.TryGetComponent(out StunnableComponent stun))
if (entity.TryGetComponent(out StunnableComponent? stun))
{
stun.CancelAll();
}
EntitySystem.Get<StandingStateSystem>().Down(entity);
}
public override void ExitState(IEntity entity)
{
base.ExitState(entity);
}
}
}

View File

@@ -14,24 +14,24 @@ namespace Content.Server.GameObjects.Components.Mobs.State
{
base.EnterState(entity);
if (entity.TryGetComponent(out AppearanceComponent appearance))
if (entity.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
}
if (entity.TryGetComponent(out ServerAlertsComponent status))
if (entity.TryGetComponent(out ServerAlertsComponent? status))
{
status.ShowAlert(AlertType.HumanDead);
}
if (entity.TryGetComponent(out StunnableComponent stun))
if (entity.TryGetComponent(out StunnableComponent? stun))
{
stun.CancelAll();
}
EntitySystem.Get<StandingStateSystem>().Down(entity);
if (entity.TryGetComponent(out IPhysBody physics))
if (entity.TryGetComponent(out IPhysBody? physics))
{
physics.CanCollide = false;
}
@@ -41,7 +41,7 @@ namespace Content.Server.GameObjects.Components.Mobs.State
{
base.ExitState(entity);
if (entity.TryGetComponent(out IPhysBody physics))
if (entity.TryGetComponent(out IPhysBody? physics))
{
physics.CanCollide = true;
}

View File

@@ -2,19 +2,14 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.Alert;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs.State;
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -73,12 +68,19 @@ namespace Content.Server.GameObjects.Components.Mobs
Paralyze(4f);
var source = eventArgs.Source;
var target = eventArgs.Target;
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/thudswoosh.ogg", source,
AudioHelpers.WithVariation(0.025f));
if (source != null)
{
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/thudswoosh.ogg", source,
AudioHelpers.WithVariation(0.025f));
source.PopupMessageOtherClients(Loc.GetString("{0} pushes {1}!", source.Name, eventArgs.Target.Name));
source.PopupMessageCursor(Loc.GetString("You push {0}!", eventArgs.Target.Name));
if (target != null)
{
source.PopupMessageOtherClients(Loc.GetString("{0} pushes {1}!", source.Name, target.Name));
source.PopupMessageCursor(Loc.GetString("You push {0}!", target.Name));
}
}
return true;
}

View File

@@ -9,8 +9,7 @@ namespace Content.Server.GameObjects.Components.Mobs
{
public override string Name => "VisitingMind";
[ViewVariables]
public Mind Mind { get; set; }
[ViewVariables] public Mind Mind { get; set; } = default!;
public override void OnRemove()
{