Fix Prototype inline errors

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:28:14 +01:00
parent ce11bf4564
commit 61aa73ffe3
3 changed files with 7 additions and 6 deletions

View File

@@ -30,13 +30,13 @@ namespace Robust.Shared.Localization
return true;
}
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype == null)
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype is not {} prototype)
{
value = null;
return false;
}
var data = GetEntityData(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype.ID);
var data = GetEntityData(prototype.ID);
return data.Attributes.TryGetValue(attribute, out value);
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -185,12 +186,12 @@ namespace Robust.Shared.Prototypes
var factory = IoCManager.Resolve<IComponentFactory>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var oldPrototype = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype;
var oldPrototype = entityManager.GetComponent<MetaDataComponent>(entity.Uid).EntityPrototype;
var oldPrototypeComponents = oldPrototype.Components.Keys
var oldPrototypeComponents = oldPrototype?.Components.Keys
.Where(n => n != "Transform" && n != "MetaData")
.Select(name => (name, factory.GetRegistration(name).Type))
.ToList();
.ToList() ?? new List<(string name, Type Type)>();
var newPrototypeComponents = Components.Keys
.Where(n => n != "Transform" && n != "MetaData")
.Select(name => (name, factory.GetRegistration(name).Type))

View File

@@ -362,7 +362,7 @@ namespace Robust.Shared.Prototypes
foreach (var prototype in pushed[typeof(EntityPrototype)])
{
foreach (var entity in _entityManager.GetEntities()
.Where(e => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e.Uid).EntityPrototype != null && IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e.Uid).EntityPrototype.ID == prototype))
.Where(e => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e.Uid).EntityPrototype != null && IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e.Uid).EntityPrototype?.ID == prototype))
{
((EntityPrototype) entityPrototypes[prototype]).UpdateEntity((IEntity) entity);
}