* #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:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.AI.Components;
|
using Content.Server.AI.Components;
|
||||||
@@ -58,7 +58,7 @@ namespace Content.Server.AI.Utils
|
|||||||
public static IEnumerable<IEntity> GetEntitiesInRange(EntityCoordinates grid, Type component, float range)
|
public static IEnumerable<IEntity> GetEntitiesInRange(EntityCoordinates grid, Type component, float range)
|
||||||
{
|
{
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
foreach (var entity in entityManager.GetEntities(new TypeEntityQuery(component)))
|
foreach (var entity in entityManager.ComponentManager.GetAllComponents(component).Select(c => c.Owner))
|
||||||
{
|
{
|
||||||
if (entity.Transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager))
|
if (entity.Transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -34,9 +35,12 @@ namespace Content.Server.Administration.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
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;
|
var count = 0;
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entitiesWithAllComponents)
|
||||||
{
|
{
|
||||||
entity.Delete();
|
entity.Delete();
|
||||||
count += 1;
|
count += 1;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands
|
namespace Content.Server.Administration.Commands
|
||||||
{
|
{
|
||||||
@@ -23,8 +24,7 @@ namespace Content.Server.Administration.Commands
|
|||||||
|
|
||||||
var id = args[0].ToLower();
|
var id = args[0].ToLower();
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
var query = new PredicateEntityQuery(e => e.Prototype?.ID.ToLower() == id);
|
var entities = entityManager.GetEntities().Where(e => e.Prototype?.ID.ToLower() == id);
|
||||||
var entities = entityManager.GetEntities(query);
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -45,10 +46,12 @@ namespace Content.Server.Administration.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
var query = new MultipleTypeEntityQuery(components);
|
|
||||||
var entityIds = new HashSet<string>();
|
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)
|
if (entity.Prototype == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.Battery.Components;
|
using Content.Server.Battery.Components;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
@@ -24,10 +24,11 @@ namespace Content.Server.Battery
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(BatteryComponent))))
|
foreach (var batteryComp in entityManager.ComponentManager.EntityQuery<BatteryComponent>())
|
||||||
{
|
{
|
||||||
ent.GetComponent<BatteryComponent>().CurrentCharge = 0;
|
batteryComp.CurrentCharge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.WriteLine("Done!");
|
shell.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Server.Atmos;
|
using Content.Server.Atmos;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.GameTicking.Rules;
|
using Content.Server.GameTicking.Rules;
|
||||||
@@ -11,7 +12,6 @@ using Content.Server.Players;
|
|||||||
using Content.Server.Spawners.Components;
|
using Content.Server.Spawners.Components;
|
||||||
using Content.Server.Traitor;
|
using Content.Server.Traitor;
|
||||||
using Content.Server.TraitorDeathMatch.Components;
|
using Content.Server.TraitorDeathMatch.Components;
|
||||||
using Content.Shared;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.Components;
|
using Content.Shared.Damage.Components;
|
||||||
@@ -158,7 +158,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
// On failure, the returned target is the location that we're already at.
|
// On failure, the returned target is the location that we're already at.
|
||||||
var bestTargetDistanceFromNearest = -1.0f;
|
var bestTargetDistanceFromNearest = -1.0f;
|
||||||
// Need the random shuffle or it stuffs the first person into Atmospherics pretty reliably
|
// Need the random shuffle or it stuffs the first person into Atmospherics pretty reliably
|
||||||
var ents = new List<IEntity>(_entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent))));
|
var ents = _entityManager.ComponentManager.EntityQuery<SpawnPointComponent>().Select(x => x.Owner).ToList();
|
||||||
_robustRandom.Shuffle(ents);
|
_robustRandom.Shuffle(ents);
|
||||||
var foundATarget = false;
|
var foundATarget = false;
|
||||||
bestTarget = EntityCoordinates.Invalid;
|
bestTarget = EntityCoordinates.Invalid;
|
||||||
@@ -215,9 +215,8 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
{
|
{
|
||||||
var lines = new List<string>();
|
var lines = new List<string>();
|
||||||
lines.Add("traitor-death-match-end-round-description-first-line");
|
lines.Add("traitor-death-match-end-round-description-first-line");
|
||||||
foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(PDAComponent))))
|
foreach (var pda in _entityManager.ComponentManager.EntityQuery<PDAComponent>())
|
||||||
{
|
{
|
||||||
var pda = entity.GetComponent<PDAComponent>();
|
|
||||||
var uplink = pda.SyndicateUplinkAccount;
|
var uplink = pda.SyndicateUplinkAccount;
|
||||||
if (uplink != null && _allOriginalNames.ContainsKey(uplink))
|
if (uplink != null && _allOriginalNames.ContainsKey(uplink))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Content.Shared.Examine;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Helpers;
|
using Content.Shared.Interaction.Helpers;
|
||||||
using Content.Shared.Morgue;
|
using Content.Shared.Morgue;
|
||||||
using Content.Shared.Notification;
|
|
||||||
using Content.Shared.Notification.Managers;
|
using Content.Shared.Notification.Managers;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -93,7 +92,6 @@ namespace Content.Server.Morgue.Components
|
|||||||
_tray = Owner.EntityManager.SpawnEntity(_trayPrototypeId, Owner.Transform.Coordinates);
|
_tray = Owner.EntityManager.SpawnEntity(_trayPrototypeId, Owner.Transform.Coordinates);
|
||||||
var trayComp = _tray.EnsureComponent<MorgueTrayComponent>();
|
var trayComp = _tray.EnsureComponent<MorgueTrayComponent>();
|
||||||
trayComp.Morgue = Owner;
|
trayComp.Morgue = Owner;
|
||||||
EntityQuery = new IntersectingEntityQuery(_tray);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.ParticleAccelerator.Components;
|
using Content.Server.ParticleAccelerator.Components;
|
||||||
using Content.Server.Singularity.Components;
|
using Content.Server.Singularity.Components;
|
||||||
@@ -26,20 +26,19 @@ namespace Content.Server.Singularity
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(EmitterComponent))))
|
foreach (var comp in entityManager.ComponentManager.EntityQuery<EmitterComponent>())
|
||||||
{
|
{
|
||||||
ent.GetComponent<EmitterComponent>().SwitchOn();
|
comp.SwitchOn();
|
||||||
}
|
}
|
||||||
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(RadiationCollectorComponent))))
|
foreach (var comp in entityManager.ComponentManager.EntityQuery<RadiationCollectorComponent>())
|
||||||
{
|
{
|
||||||
ent.GetComponent<RadiationCollectorComponent>().Collecting = true;
|
comp.Collecting = true;
|
||||||
}
|
}
|
||||||
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(ParticleAcceleratorControlBoxComponent))))
|
foreach (var comp in entityManager.ComponentManager.EntityQuery<ParticleAcceleratorControlBoxComponent>())
|
||||||
{
|
{
|
||||||
var pacb = ent.GetComponent<ParticleAcceleratorControlBoxComponent>();
|
comp.RescanParts();
|
||||||
pacb.RescanParts();
|
comp.SetStrength(ParticleAcceleratorPowerState.Level0);
|
||||||
pacb.SetStrength(ParticleAcceleratorPowerState.Level0);
|
comp.SwitchOn();
|
||||||
pacb.SwitchOn();
|
|
||||||
}
|
}
|
||||||
shell.WriteLine("Done!");
|
shell.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Content.Server.Storage.Components
|
|||||||
// No contents, we do nothing
|
// No contents, we do nothing
|
||||||
if (Contents.ContainedEntities.Count == 0) return;
|
if (Contents.ContainedEntities.Count == 0) return;
|
||||||
|
|
||||||
var lockers = Owner.EntityManager.GetEntities(new TypeEntityQuery(typeof(EntityStorageComponent))).ToList();
|
var lockers = Owner.EntityManager.ComponentManager.EntityQuery<EntityStorageComponent>().Select(c => c.Owner).ToList();
|
||||||
|
|
||||||
if (lockers.Contains(Owner))
|
if (lockers.Contains(Owner))
|
||||||
lockers.Remove(Owner);
|
lockers.Remove(Owner);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.Hands.Components;
|
using Content.Server.Hands.Components;
|
||||||
@@ -11,7 +12,6 @@ using Content.Shared.Body.Components;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Movement;
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Notification;
|
|
||||||
using Content.Shared.Notification.Managers;
|
using Content.Shared.Notification.Managers;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
@@ -25,6 +25,7 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Physics.Broadphase;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -59,9 +60,6 @@ namespace Content.Server.Storage.Components
|
|||||||
[DataField("IsCollidableWhenOpen")]
|
[DataField("IsCollidableWhenOpen")]
|
||||||
private bool _isCollidableWhenOpen;
|
private bool _isCollidableWhenOpen;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
protected IEntityQuery? EntityQuery;
|
|
||||||
|
|
||||||
[DataField("showContents")]
|
[DataField("showContents")]
|
||||||
private bool _showContents;
|
private bool _showContents;
|
||||||
|
|
||||||
@@ -150,8 +148,6 @@ namespace Content.Server.Storage.Components
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
Contents = Owner.EnsureContainer<Container>(nameof(EntityStorageComponent));
|
Contents = Owner.EnsureContainer<Container>(nameof(EntityStorageComponent));
|
||||||
EntityQuery = new IntersectingEntityQuery(Owner);
|
|
||||||
|
|
||||||
Contents.ShowContents = _showContents;
|
Contents.ShowContents = _showContents;
|
||||||
Contents.OccludesLight = _occludesLight;
|
Contents.OccludesLight = _occludesLight;
|
||||||
|
|
||||||
@@ -198,13 +194,12 @@ namespace Content.Server.Storage.Components
|
|||||||
protected virtual void CloseStorage()
|
protected virtual void CloseStorage()
|
||||||
{
|
{
|
||||||
Open = false;
|
Open = false;
|
||||||
EntityQuery ??= new IntersectingEntityQuery(Owner);
|
|
||||||
var entities = Owner.EntityManager.GetEntities(EntityQuery);
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var entity in entities)
|
foreach (var entity in DetermineCollidingEntities())
|
||||||
{
|
{
|
||||||
// prevents taking items out of inventories, out of containers, and orphaning child entities
|
// prevents taking items out of inventories, out of containers, and orphaning child entities
|
||||||
if(!entity.Transform.IsMapTransform)
|
if (entity.IsInContainer())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// only items that can be stored in an inventory, or a mob, can be eaten by a locker
|
// only items that can be stored in an inventory, or a mob, can be eaten by a locker
|
||||||
@@ -442,6 +437,12 @@ namespace Content.Server.Storage.Components
|
|||||||
EmptyContents();
|
EmptyContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IEnumerable<IEntity> DetermineCollidingEntities()
|
||||||
|
{
|
||||||
|
var entityLookup = IoCManager.Resolve<IEntityLookup>();
|
||||||
|
return entityLookup.GetEntitiesIntersecting(Owner);
|
||||||
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class OpenToggleVerb : Verb<EntityStorageComponent>
|
private sealed class OpenToggleVerb : Verb<EntityStorageComponent>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user