Replace count prototype (#10212)

* Replace count prototype

* Doc improvement
This commit is contained in:
wrexbe
2022-08-01 12:32:42 -07:00
committed by GitHub
parent 13beb5f40e
commit 5eaa7149e2
2 changed files with 31 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
using Content.Server.Containers;
using Content.Server.Objectives.Interfaces;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
@@ -47,15 +46,9 @@ namespace Content.Server.Objectives.Conditions
{
get
{
if (_mind?.OwnedEntity is not {Valid: true} owned) return 0f;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(owned, out var containerManagerComponent)) return 0f;
// slightly ugly but fixing it would just be duplicating it with a different return value
float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId);
if (count >= 1)
return 1;
else
return 0;
if (_mind?.OwnedEntity is not {Valid: true} owned)
return 0f;
return owned.ContainsPrototypeRecursive(_prototypeId)? 1f : 0f;
}
}