Enable nullability in Content.Shared (#3626)
* Enable nullability in Content.Shared * Fix null errors in server * aye github i swear on me mom
This commit is contained in:
@@ -239,7 +239,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
||||
if (activeHandEntity == null || !activeHandEntity.TryGetComponent(out GasAnalyzerComponent? gasAnalyzer))
|
||||
{
|
||||
serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("You need a Gas Analyzer in your hand!"));
|
||||
serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("You need a Gas Analyzer in your hand!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
}
|
||||
else // If surgery cannot be performed, show message saying so.
|
||||
{
|
||||
eventArgs.Target.PopupMessage(eventArgs.User,
|
||||
eventArgs.Target?.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("You see no way to install the {0}.", Owner.Name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Content.Server.GameObjects.Components.Body.Part
|
||||
}
|
||||
else // If surgery cannot be performed, show message saying so.
|
||||
{
|
||||
eventArgs.Target.PopupMessage(eventArgs.User,
|
||||
eventArgs.Target?.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("You see no way to install {0:theName}.", Owner));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -246,7 +244,9 @@ namespace Content.Server.GameObjects.Components.Body.Surgery
|
||||
private void HandleReceiveMechanism(int key)
|
||||
{
|
||||
// TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc
|
||||
if (!_optionsCache.TryGetValue(key, out var targetObject) ||
|
||||
if (BodyCache == null ||
|
||||
!_optionsCache.TryGetValue(key, out var targetObject) ||
|
||||
targetObject is not MechanismComponent target ||
|
||||
PerformerCache == null ||
|
||||
!PerformerCache.TryGetComponent(out IActorComponent? actor))
|
||||
{
|
||||
@@ -254,20 +254,22 @@ namespace Content.Server.GameObjects.Components.Body.Surgery
|
||||
return;
|
||||
}
|
||||
|
||||
var target = targetObject as MechanismComponent;
|
||||
|
||||
CloseSurgeryUI(actor.playerSession);
|
||||
_callbackCache?.Invoke(target, BodyCache, this, PerformerCache);
|
||||
}
|
||||
|
||||
private void NotUsefulPopup()
|
||||
{
|
||||
if (PerformerCache == null) return;
|
||||
|
||||
BodyCache?.Owner.PopupMessage(PerformerCache,
|
||||
Loc.GetString("You see no useful way to use {0:theName}.", Owner));
|
||||
}
|
||||
|
||||
private void NotUsefulAnymorePopup()
|
||||
{
|
||||
if (PerformerCache == null) return;
|
||||
|
||||
BodyCache?.Owner.PopupMessage(PerformerCache,
|
||||
Loc.GetString("You see no useful way to use {0:theName} anymore.", Owner));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ using Content.Shared.GameObjects.Components.Strap;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.Interfaces;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -237,7 +236,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
public override bool TryBuckle(IEntity? user, IEntity to)
|
||||
{
|
||||
if (!CanBuckle(user, to, out var strap))
|
||||
if (user == null || !CanBuckle(user, to, out var strap))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -410,7 +409,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
return new BuckleComponentState(Buckled, drawDepth, LastEntityBuckledTo, DontCollide);
|
||||
}
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!DontCollide || Physics == null)
|
||||
|
||||
@@ -15,8 +15,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -201,11 +199,11 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
{
|
||||
if (_laggedBatches == (int) (maxMidiLaggedBatches * (1 / 3d) + 1))
|
||||
{
|
||||
Owner.PopupMessage(InstrumentPlayer.AttachedEntity,
|
||||
InstrumentPlayer.AttachedEntity?.PopupMessage(
|
||||
Loc.GetString("Your fingers are beginning to a cramp a little!"));
|
||||
} else if (_laggedBatches == (int) (maxMidiLaggedBatches * (2 / 3d) + 1))
|
||||
{
|
||||
Owner.PopupMessage(InstrumentPlayer.AttachedEntity,
|
||||
InstrumentPlayer.AttachedEntity?.PopupMessage(
|
||||
Loc.GetString("Your fingers are seriously cramping up!"));
|
||||
}
|
||||
}
|
||||
@@ -360,11 +358,11 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
stun.Stun(1);
|
||||
Clean();
|
||||
}
|
||||
|
||||
Owner.PopupMessage(mob, "Your fingers cramp up from playing!");
|
||||
}
|
||||
|
||||
InstrumentPlayer = null;
|
||||
|
||||
Owner.PopupMessage(mob, "Your fingers cramp up from playing!");
|
||||
}
|
||||
|
||||
_timer += delta;
|
||||
|
||||
@@ -21,8 +21,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -139,20 +137,24 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
if (!WelderLit)
|
||||
{
|
||||
if(!silent) Owner.PopupMessage(user, Loc.GetString("The welder is turned off!"));
|
||||
if (!silent && user != null)
|
||||
Owner.PopupMessage(user, Loc.GetString("The welder is turned off!"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanWeld(value))
|
||||
{
|
||||
if(!silent) Owner.PopupMessage(user, Loc.GetString("The welder does not have enough fuel for that!"));
|
||||
if (!silent && user != null)
|
||||
Owner.PopupMessage(user, Loc.GetString("The welder does not have enough fuel for that!"));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_solutionComponent == null)
|
||||
return false;
|
||||
|
||||
bool succeeded = _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value));
|
||||
var succeeded = _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value));
|
||||
|
||||
if (succeeded && !silent)
|
||||
{
|
||||
@@ -192,7 +194,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CanLitWelder())
|
||||
if (!CanLitWelder() && user != null)
|
||||
{
|
||||
Owner.PopupMessage(user, Loc.GetString("The welder has no fuel left!"));
|
||||
return false;
|
||||
|
||||
@@ -23,8 +23,6 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -481,7 +479,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
((IUse) this).UseEntity(new UseEntityEventArgs { User = eventArgs.User });
|
||||
((IUse) this).UseEntity(new UseEntityEventArgs(eventArgs.User));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,13 +15,9 @@ namespace Content.Server.GameObjects.Components.Morgue
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if(Morgue != null && !Morgue.Deleted && Morgue.TryGetComponent<MorgueEntityStorageComponent>(out var comp))
|
||||
if (Morgue != null && !Morgue.Deleted && Morgue.TryGetComponent<MorgueEntityStorageComponent>(out var comp))
|
||||
{
|
||||
comp.Activate(new ActivateEventArgs()
|
||||
{
|
||||
User = eventArgs.User,
|
||||
Target = Morgue
|
||||
});
|
||||
comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user