Resolves that make you flinch (#2423)

* argh

* ouch

* zap

* adds default!

* adressed review
This commit is contained in:
Paul Ritter
2020-10-30 01:13:35 +01:00
committed by GitHub
parent 12d8737e09
commit 1b3cbd4d3a
3 changed files with 38 additions and 32 deletions

View File

@@ -34,10 +34,8 @@ namespace Content.Shared.Prototypes.Cargo
{
if (_name.Trim().Length != 0)
return _name;
var protoMan = IoCManager.Resolve<IPrototypeManager>();
if (protoMan == null)
return _name;
protoMan.TryIndex(_product, out EntityPrototype prototype);
EntityPrototype prototype = null;
IoCManager.Resolve<IPrototypeManager>()?.TryIndex(_product, out prototype);
if (prototype?.Name != null)
_name = prototype.Name;
return _name;
@@ -54,10 +52,8 @@ namespace Content.Shared.Prototypes.Cargo
{
if (_description.Trim().Length != 0)
return _description;
var protoMan = IoCManager.Resolve<IPrototypeManager>();
if (protoMan == null)
return _description;
protoMan.TryIndex(_product, out EntityPrototype prototype);
EntityPrototype prototype = null;
IoCManager.Resolve<IPrototypeManager>()?.TryIndex(_product, out prototype);
if (prototype?.Description != null)
_description = prototype.Description;
return _description;
@@ -94,6 +90,11 @@ namespace Content.Shared.Prototypes.Cargo
[ViewVariables]
public string Group => _group;
public CargoProductPrototype()
{
IoCManager.InjectDependencies(this);
}
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);