#1607 deprecate IEntityQuery (#4204)

* #1607 partial progress

* #1607 partial progress

* #1607 almost done

* #1607 PR suggestions

* #1607 PR suggestions

* #1607 PR suggestions

* #1607 PR tweak

* #1607 PR tweak

* #1607 removed unused namespaces

* #1607 PR tweak

* Fix jank

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Galactic Chimp
2021-06-27 05:40:03 +02:00
committed by GitHub
parent 71d939bed5
commit 769daedaa9
10 changed files with 45 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
@@ -34,9 +35,12 @@ namespace Content.Server.Administration.Commands
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var entities = entityManager.GetEntities(new MultipleTypeEntityQuery(components));
var entitiesWithComponents = components.Select(c => entityManager.ComponentManager.GetAllComponents(c).Select(x => x.Owner));
var entitiesWithAllComponents = entitiesWithComponents.Skip(1).Aggregate(new HashSet<IEntity>(entitiesWithComponents.First()), (h, e) => { h.IntersectWith(e); return h; });
var count = 0;
foreach (var entity in entities)
foreach (var entity in entitiesWithAllComponents)
{
entity.Delete();
count += 1;

View File

@@ -1,8 +1,9 @@
#nullable enable
#nullable enable
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using System.Linq;
namespace Content.Server.Administration.Commands
{
@@ -23,8 +24,7 @@ namespace Content.Server.Administration.Commands
var id = args[0].ToLower();
var entityManager = IoCManager.Resolve<IEntityManager>();
var query = new PredicateEntityQuery(e => e.Prototype?.ID.ToLower() == id);
var entities = entityManager.GetEntities(query);
var entities = entityManager.GetEntities().Where(e => e.Prototype?.ID.ToLower() == id);
var i = 0;
foreach (var entity in entities)

View File

@@ -1,6 +1,7 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
@@ -45,10 +46,12 @@ namespace Content.Server.Administration.Commands
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var query = new MultipleTypeEntityQuery(components);
var entityIds = new HashSet<string>();
foreach (var entity in entityManager.GetEntities(query))
var entitiesWithComponents = components.Select(c => entityManager.ComponentManager.GetAllComponents(c).Select(x => x.Owner));
var entitiesWithAllComponents = entitiesWithComponents.Skip(1).Aggregate(new HashSet<IEntity>(entitiesWithComponents.First()), (h, e) => { h.IntersectWith(e); return h; });
foreach (var entity in entitiesWithAllComponents)
{
if (entity.Prototype == null)
{