mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10ab707427 | ||
|
|
f061a8c018 | ||
|
|
91d4b32c66 | ||
|
|
e788f03a28 |
@@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
|
||||
|
||||
@@ -54,11 +54,10 @@ END TEMPLATE-->
|
||||
*None yet*
|
||||
|
||||
|
||||
## 168.0.0
|
||||
## 167.0.2
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* The Component.OnRemove method has been removed. Use SubscribeLocalEvent<TComp, ComponentRemove>(OnRemove) from an EntitySystem instead.
|
||||
## 167.0.1
|
||||
|
||||
|
||||
## 167.0.0
|
||||
@@ -105,7 +104,7 @@ END TEMPLATE-->
|
||||
|
||||
### New features
|
||||
|
||||
* The YAML validator now checks the default values of ProtoId<T> and EntProtoId data fields.
|
||||
* The YAML validator now checks the default values of ProtoId<T> and EntProtoId data fields.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Prometheus;
|
||||
using Robust.Client.GameStates;
|
||||
using Robust.Client.Player;
|
||||
@@ -85,7 +86,7 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dirty(EntityUid uid, IComponent component, MetaDataComponent? meta = null)
|
||||
public override void Dirty(EntityUid uid, Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
// Client only dirties during prediction
|
||||
if (_gameTiming.InPrediction)
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Robust.Client.GameStates
|
||||
private readonly Dictionary<EntityUid, HashSet<Type>> _pendingReapplyNetStates = new();
|
||||
private readonly HashSet<NetEntity> _stateEnts = new();
|
||||
private readonly List<EntityUid> _toDelete = new();
|
||||
private readonly List<IComponent> _toRemove = new();
|
||||
private readonly List<Component> _toRemove = new();
|
||||
private readonly Dictionary<NetEntity, Dictionary<ushort, ComponentState>> _outputData = new();
|
||||
private readonly List<(EntityUid, TransformComponent)> _queuedBroadphaseUpdates = new();
|
||||
|
||||
@@ -499,7 +499,7 @@ namespace Robust.Client.GameStates
|
||||
var countReset = 0;
|
||||
var system = _entitySystemManager.GetEntitySystem<ClientDirtySystem>();
|
||||
var metaQuery = _entityManager.GetEntityQuery<MetaDataComponent>();
|
||||
RemQueue<IComponent> toRemove = new();
|
||||
RemQueue<Component> toRemove = new();
|
||||
|
||||
foreach (var entity in system.DirtyEntities)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.2" Condition="'$(UseSystemSqlite)' != 'True'" PrivateAssets="compile" />
|
||||
<PackageReference Include="SpaceWizards.NFluidsynth" Version="0.1.1" PrivateAssets="compile" />
|
||||
<PackageReference Include="NVorbis" Version="0.10.1" PrivateAssets="compile" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.7" />
|
||||
<PackageReference Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" PrivateAssets="compile" />
|
||||
<PackageReference Include="OpenTK.OpenAL" Version="4.7.5" PrivateAssets="compile" />
|
||||
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" PrivateAssets="compile" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
@@ -187,10 +188,10 @@ namespace Robust.Shared.Scripting
|
||||
}
|
||||
|
||||
#region EntityManager proxy methods
|
||||
public T Comp<T>(EntityUid uid) where T : IComponent
|
||||
public T Comp<T>(EntityUid uid) where T : Component
|
||||
=> ent.GetComponent<T>(uid);
|
||||
|
||||
public bool TryComp<T>(EntityUid uid, out T? comp) where T : IComponent
|
||||
public bool TryComp<T>(EntityUid uid, out T? comp) where T : Component
|
||||
=> ent.TryGetComponent(uid, out comp);
|
||||
|
||||
public bool HasComp<T>(EntityUid uid)
|
||||
|
||||
@@ -132,11 +132,6 @@ namespace Robust.Shared.Configuration
|
||||
return long.Parse(input);
|
||||
}
|
||||
|
||||
if (type == typeof(ushort))
|
||||
{
|
||||
return ushort.Parse(input);
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,11 +617,6 @@ namespace Robust.Shared.Configuration
|
||||
return long.Parse(value);
|
||||
}
|
||||
|
||||
if (type == typeof(ushort))
|
||||
{
|
||||
return ushort.Parse(value);
|
||||
}
|
||||
|
||||
// Must be a string.
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -171,7 +173,7 @@ public static class CompletionHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<CompletionOption> Components<T>(string text, IEntityManager? entManager = null) where T : IComponent
|
||||
public static IEnumerable<CompletionOption> Components<T>(string text, IEntityManager? entManager = null) where T : Component
|
||||
{
|
||||
IoCManager.Resolve(ref entManager);
|
||||
|
||||
|
||||
@@ -38,6 +38,19 @@ namespace Robust.Shared.Containers
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected internal override void OnRemove()
|
||||
{
|
||||
base.OnRemove();
|
||||
|
||||
foreach (var container in Containers.Values)
|
||||
{
|
||||
container.Shutdown(_entMan, _netMan);
|
||||
}
|
||||
|
||||
Containers.Clear();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public T MakeContainer<T>(string id)
|
||||
where T : BaseContainer
|
||||
|
||||
@@ -8,7 +8,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -17,7 +16,6 @@ namespace Robust.Shared.Containers
|
||||
{
|
||||
public abstract partial class SharedContainerSystem
|
||||
{
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
@@ -36,7 +34,6 @@ namespace Robust.Shared.Containers
|
||||
SubscribeLocalEvent<EntParentChangedMessage>(OnParentChanged);
|
||||
SubscribeLocalEvent<ContainerManagerComponent, ComponentStartup>(OnStartupValidation);
|
||||
SubscribeLocalEvent<ContainerManagerComponent, ComponentGetState>(OnContainerGetState);
|
||||
SubscribeLocalEvent<ContainerManagerComponent, ComponentRemove>(OnContainerManagerRemove);
|
||||
|
||||
_gridQuery = GetEntityQuery<MapGridComponent>();
|
||||
_mapQuery = GetEntityQuery<MapComponent>();
|
||||
@@ -65,16 +62,6 @@ namespace Robust.Shared.Containers
|
||||
args.State = new ContainerManagerComponent.ContainerManagerComponentState(containerSet);
|
||||
}
|
||||
|
||||
private void OnContainerManagerRemove(EntityUid uid, ContainerManagerComponent component, ComponentRemove args)
|
||||
{
|
||||
foreach (var container in component.Containers.Values)
|
||||
{
|
||||
container.Shutdown(EntityManager, _net);
|
||||
}
|
||||
|
||||
component.Containers.Clear();
|
||||
}
|
||||
|
||||
// TODO: Make ContainerManagerComponent ECS and make these proxy methods the real deal.
|
||||
|
||||
#region Proxy Methods
|
||||
@@ -255,7 +242,7 @@ namespace Robust.Shared.Containers
|
||||
EntityQuery<T> entityQuery,
|
||||
[NotNullWhen(true)] ref T? foundComponent,
|
||||
MetaDataComponent? meta = null,
|
||||
TransformComponent? xform = null) where T : IComponent
|
||||
TransformComponent? xform = null) where T : Component
|
||||
{
|
||||
if (!MetaQuery.Resolve(uid, ref meta))
|
||||
return false;
|
||||
@@ -283,7 +270,7 @@ namespace Robust.Shared.Containers
|
||||
EntityQuery<T> entityQuery,
|
||||
List<T> foundComponents,
|
||||
MetaDataComponent? meta = null,
|
||||
TransformComponent? xform = null) where T : IComponent
|
||||
TransformComponent? xform = null) where T : Component
|
||||
{
|
||||
if (!MetaQuery.Resolve(uid, ref meta))
|
||||
return foundComponents.Any();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -7,7 +8,7 @@ using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
/// <inheritdoc cref="IComponent"/>
|
||||
/// <inheritdoc />
|
||||
[Reflect(false)]
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract partial class Component : IComponent
|
||||
@@ -16,8 +17,7 @@ namespace Robust.Shared.GameObjects
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
private bool _netSync { get; set; } = true;
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
public bool Networked { get; set; } = true;
|
||||
internal bool Networked = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool NetSyncEnabled
|
||||
@@ -33,10 +33,19 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public ComponentLifeStage LifeStage { get; [Obsolete("Do not use from content")] set; } = ComponentLifeStage.PreAdd;
|
||||
public ComponentLifeStage LifeStage { get; internal set; } = ComponentLifeStage.PreAdd;
|
||||
|
||||
/// <summary>
|
||||
/// If true, and if this is a networked component, then component data will only be sent to players if their
|
||||
/// controlled entity is the owner of this component. This is less performance intensive than <see cref="SessionSpecific"/>.
|
||||
/// </summary>
|
||||
public virtual bool SendOnlyToOwner => false;
|
||||
|
||||
/// <summary>
|
||||
/// If true, and if this is a networked component, then this component will cause <see
|
||||
/// cref="ComponentGetStateAttemptEvent"/> events to be raised to check whether a given player should
|
||||
/// receive this component's state.
|
||||
/// </summary>
|
||||
public virtual bool SessionSpecific => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -53,11 +62,21 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public GameTick CreationTick { get; [Obsolete("Do not use from content")] set; }
|
||||
public GameTick CreationTick { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public GameTick LastModifiedTick { get; [Obsolete("Do not use from content")] set; }
|
||||
public GameTick LastModifiedTick { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the component is removed from an entity.
|
||||
/// Shuts down the component.
|
||||
/// The component has already been marked as deleted in the component manager.
|
||||
/// </summary>
|
||||
protected internal virtual void OnRemove()
|
||||
{
|
||||
LifeStage = ComponentLifeStage.Deleted;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete]
|
||||
@@ -69,15 +88,13 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
// these two methods clear the LastModifiedTick/CreationTick to mark it as "not different from prototype load".
|
||||
// This is used as optimization in the game state system to avoid sending redundant component data.
|
||||
[Obsolete("Do not use from content")]
|
||||
public virtual void ClearTicks()
|
||||
internal virtual void ClearTicks()
|
||||
{
|
||||
LastModifiedTick = GameTick.Zero;
|
||||
ClearCreationTick();
|
||||
}
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
public void ClearCreationTick()
|
||||
internal void ClearCreationTick()
|
||||
{
|
||||
CreationTick = GameTick.Zero;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Component that this event relates to.
|
||||
/// </summary>
|
||||
public IComponent Component { get; }
|
||||
public Component Component { get; }
|
||||
|
||||
/// <summary>
|
||||
/// EntityUid of the entity this component belongs to.
|
||||
@@ -21,7 +21,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
/// <param name="component">The relevant component</param>
|
||||
/// <param name="owner">EntityUid of the entity this component belongs to.</param>
|
||||
public ComponentEventArgs(IComponent component, EntityUid owner)
|
||||
public ComponentEventArgs(Component component, EntityUid owner)
|
||||
{
|
||||
Component = component;
|
||||
Owner = owner;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -8,6 +7,8 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
@@ -67,7 +68,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// The components attached to the entity that are currently networked.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
internal readonly Dictionary<ushort, IComponent> NetComponents = new();
|
||||
internal readonly Dictionary<ushort, Component> NetComponents = new();
|
||||
|
||||
/// <summary>
|
||||
/// Network identifier for this entity.
|
||||
@@ -198,8 +199,7 @@ namespace Robust.Shared.GameObjects
|
||||
public bool EntityInitializing => EntityLifeStage == EntityLifeStage.Initializing;
|
||||
public bool EntityDeleted => EntityLifeStage >= EntityLifeStage.Deleted;
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
public override void ClearTicks()
|
||||
internal override void ClearTicks()
|
||||
{
|
||||
// Do not clear modified ticks.
|
||||
// MetaDataComponent is used in the game state system to carry initial data like prototype ID.
|
||||
|
||||
@@ -36,15 +36,15 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private static readonly ComponentState DefaultComponentState = new();
|
||||
|
||||
private readonly Dictionary<Type, Dictionary<EntityUid, IComponent>> _entTraitDict
|
||||
private readonly Dictionary<Type, Dictionary<EntityUid, Component>> _entTraitDict
|
||||
= new();
|
||||
|
||||
private Dictionary<EntityUid, IComponent>[] _entTraitArray
|
||||
= Array.Empty<Dictionary<EntityUid, IComponent>>();
|
||||
private Dictionary<EntityUid, Component>[] _entTraitArray
|
||||
= Array.Empty<Dictionary<EntityUid, Component>>();
|
||||
|
||||
private readonly HashSet<IComponent> _deleteSet = new(TypeCapacity);
|
||||
private readonly HashSet<Component> _deleteSet = new(TypeCapacity);
|
||||
|
||||
private UniqueIndexHkm<EntityUid, IComponent> _entCompIndex =
|
||||
private UniqueIndexHkm<EntityUid, Component> _entCompIndex =
|
||||
new(ComponentCollectionCapacity);
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -78,7 +78,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void AddComponentRefType(CompIdx type)
|
||||
{
|
||||
var dict = new Dictionary<EntityUid, IComponent>();
|
||||
var dict = new Dictionary<EntityUid, Component>();
|
||||
_entTraitDict.Add(_componentFactory.IdxToType(type), dict);
|
||||
CompIdx.AssignArray(ref _entTraitArray, type, dict);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Robust.Shared.GameObjects
|
||||
#region Component Management
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Count<T>() where T : IComponent
|
||||
public int Count<T>() where T : Component
|
||||
{
|
||||
var dict = _entTraitDict[typeof(T)];
|
||||
return dict.Count;
|
||||
@@ -114,7 +114,7 @@ namespace Robust.Shared.GameObjects
|
||||
metadata.EntityLifeStage = EntityLifeStage.Initializing;
|
||||
|
||||
// Initialize() can modify the collection of components. Copy them.
|
||||
FixedArray32<IComponent?> compsFixed = default;
|
||||
FixedArray32<Component?> compsFixed = default;
|
||||
|
||||
var comps = compsFixed.AsSpan;
|
||||
CopyComponentsInto(ref comps, uid);
|
||||
@@ -145,7 +145,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
// Startup() can modify _components
|
||||
// This code can only handle additions to the list. Is there a better way? Probably not.
|
||||
FixedArray32<IComponent?> compsFixed = default;
|
||||
FixedArray32<Component?> compsFixed = default;
|
||||
|
||||
var comps = compsFixed.AsSpan;
|
||||
CopyComponentsInto(ref comps, uid);
|
||||
@@ -182,7 +182,7 @@ namespace Robust.Shared.GameObjects
|
||||
return newComponent;
|
||||
}
|
||||
|
||||
public T AddComponent<T>(EntityUid uid) where T : IComponent, new()
|
||||
public T AddComponent<T>(EntityUid uid) where T : Component, new()
|
||||
{
|
||||
var newComponent = _componentFactory.GetComponent<T>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
@@ -193,7 +193,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public readonly struct CompInitializeHandle<T> : IDisposable
|
||||
where T : IComponent
|
||||
where T : Component
|
||||
{
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly EntityUid _owner;
|
||||
@@ -230,7 +230,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete]
|
||||
public CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : IComponent, new()
|
||||
public CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : Component, new()
|
||||
{
|
||||
var reg = _componentFactory.GetRegistration<T>();
|
||||
var newComponent = (T)_componentFactory.GetComponent(reg);
|
||||
@@ -247,7 +247,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : IComponent
|
||||
public void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : Component
|
||||
{
|
||||
if (!uid.IsValid() || !EntityExists(uid))
|
||||
throw new ArgumentException($"Entity {uid} is not valid.", nameof(uid));
|
||||
@@ -268,14 +268,14 @@ namespace Robust.Shared.GameObjects
|
||||
AddComponentInternal(uid, component, overwrite, false, metadata);
|
||||
}
|
||||
|
||||
private void AddComponentInternal<T>(EntityUid uid, T component, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : IComponent
|
||||
private void AddComponentInternal<T>(EntityUid uid, T component, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : Component
|
||||
{
|
||||
// get interface aliases for mapping
|
||||
var reg = _componentFactory.GetRegistration(component);
|
||||
AddComponentInternal(uid, component, reg, overwrite, skipInit, metadata);
|
||||
}
|
||||
|
||||
private void AddComponentInternal<T>(EntityUid uid, T component, ComponentRegistration reg, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : IComponent
|
||||
private void AddComponentInternal<T>(EntityUid uid, T component, ComponentRegistration reg, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : Component
|
||||
{
|
||||
// We can't use typeof(T) here in case T is just Component
|
||||
DebugTools.Assert(component is MetaDataComponent ||
|
||||
@@ -440,7 +440,7 @@ namespace Robust.Shared.GameObjects
|
||||
RemoveComponentDeferred(component, owner, false);
|
||||
}
|
||||
|
||||
private static IEnumerable<IComponent> InSafeOrder(IEnumerable<IComponent> comps, bool forCreation = false)
|
||||
private static IEnumerable<Component> InSafeOrder(IEnumerable<Component> comps, bool forCreation = false)
|
||||
{
|
||||
static int Sequence(IComponent x)
|
||||
=> x switch
|
||||
@@ -527,7 +527,7 @@ namespace Robust.Shared.GameObjects
|
||||
#endif
|
||||
}
|
||||
|
||||
private void RemoveComponentImmediate(IComponent component, EntityUid uid, bool terminating,
|
||||
private void RemoveComponentImmediate(Component component, EntityUid uid, bool terminating,
|
||||
MetaDataComponent? meta)
|
||||
{
|
||||
if (component.Deleted)
|
||||
@@ -602,7 +602,7 @@ namespace Robust.Shared.GameObjects
|
||||
_deleteSet.Clear();
|
||||
}
|
||||
|
||||
private void DeleteComponent(EntityUid entityUid, IComponent component, bool terminating, MetaDataComponent? metadata = null)
|
||||
private void DeleteComponent(EntityUid entityUid, Component component, bool terminating, MetaDataComponent? metadata = null)
|
||||
{
|
||||
if (!MetaQuery.ResolveInternal(entityUid, ref metadata))
|
||||
return;
|
||||
@@ -643,7 +643,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
|
||||
return dict.TryGetValue(uid, out var comp) && !comp.Deleted;
|
||||
return dict!.TryGetValue(uid, out var comp) && !comp.Deleted;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -699,14 +699,15 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public T EnsureComponent<T>(EntityUid uid) where T : IComponent, new()
|
||||
public T EnsureComponent<T>(EntityUid uid) where T : Component, new()
|
||||
{
|
||||
if (TryGetComponent<T>(uid, out var component))
|
||||
{
|
||||
// Check for deferred component removal.
|
||||
if (component.LifeStage <= ComponentLifeStage.Running)
|
||||
return component;
|
||||
RemoveComponent(uid, component);
|
||||
else
|
||||
RemoveComponent(uid, component);
|
||||
}
|
||||
|
||||
return AddComponent<T>(uid);
|
||||
@@ -714,7 +715,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool EnsureComponent<T>(EntityUid entity, out T component) where T : IComponent, new()
|
||||
public bool EnsureComponent<T>(EntityUid entity, out T component) where T : Component, new()
|
||||
{
|
||||
if (TryGetComponent<T>(entity, out var comp))
|
||||
{
|
||||
@@ -724,8 +725,8 @@ namespace Robust.Shared.GameObjects
|
||||
component = comp;
|
||||
return true;
|
||||
}
|
||||
|
||||
RemoveComponent(entity, comp);
|
||||
else
|
||||
RemoveComponent(entity, comp);
|
||||
}
|
||||
|
||||
component = AddComponent<T>(entity);
|
||||
@@ -738,11 +739,11 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
|
||||
if (dict.TryGetValue(uid, out var comp))
|
||||
if (dict!.TryGetValue(uid, out var comp))
|
||||
{
|
||||
if (!comp.Deleted)
|
||||
if (!comp!.Deleted)
|
||||
{
|
||||
return (T)comp;
|
||||
return (T)(IComponent) comp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,11 +802,11 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
|
||||
if (dict.TryGetValue(uid, out var comp))
|
||||
if (dict!.TryGetValue(uid, out var comp))
|
||||
{
|
||||
if (!comp.Deleted)
|
||||
{
|
||||
component = (T)comp;
|
||||
component = (T)(IComponent)comp;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -921,25 +922,25 @@ namespace Robust.Shared.GameObjects
|
||||
return TryGetComponent(uid.Value, netId, out component, meta);
|
||||
}
|
||||
|
||||
public EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : IComponent
|
||||
public EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : Component
|
||||
{
|
||||
var comps = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
DebugTools.Assert(comps != null, $"Unknown component: {typeof(TComp1).Name}");
|
||||
return new EntityQuery<TComp1>(comps, _resolveSawmill);
|
||||
return new EntityQuery<TComp1>(comps!, _resolveSawmill);
|
||||
}
|
||||
|
||||
public EntityQuery<IComponent> GetEntityQuery(Type type)
|
||||
public EntityQuery<Component> GetEntityQuery(Type type)
|
||||
{
|
||||
var comps = _entTraitArray[CompIdx.ArrayIndex(type)];
|
||||
DebugTools.Assert(comps != null, $"Unknown component: {type.Name}");
|
||||
return new EntityQuery<IComponent>(comps, _resolveSawmill);
|
||||
return new EntityQuery<Component>(comps!, _resolveSawmill);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IComponent> GetComponents(EntityUid uid)
|
||||
{
|
||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
foreach (var comp in _entCompIndex[uid].ToArray())
|
||||
foreach (Component comp in _entCompIndex[uid].ToArray())
|
||||
{
|
||||
if (comp.Deleted) continue;
|
||||
|
||||
@@ -956,14 +957,14 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <summary>
|
||||
/// Copy the components for an entity into the given span,
|
||||
/// or re-allocate the span as an array if there's not enough space.º
|
||||
/// or re-allocate the span as an array if there's not enough space.
|
||||
/// </summary>
|
||||
private void CopyComponentsInto(ref Span<IComponent?> comps, EntityUid uid)
|
||||
private void CopyComponentsInto(ref Span<Component?> comps, EntityUid uid)
|
||||
{
|
||||
var set = _entCompIndex[uid];
|
||||
if (set.Count > comps.Length)
|
||||
{
|
||||
comps = new IComponent[set.Count];
|
||||
comps = new Component[set.Count];
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
@@ -1002,7 +1003,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
#region Join Functions
|
||||
|
||||
public (EntityUid Uid, T Component)[] AllComponents<T>() where T : IComponent
|
||||
public (EntityUid Uid, T Component)[] AllComponents<T>() where T : Component
|
||||
{
|
||||
var query = AllEntityQueryEnumerator<T>();
|
||||
var comps = new (EntityUid Uid, T Component)[Count<T>()];
|
||||
@@ -1017,7 +1018,7 @@ namespace Robust.Shared.GameObjects
|
||||
return comps;
|
||||
}
|
||||
|
||||
public List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : IComponent
|
||||
public List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : Component
|
||||
{
|
||||
var query = AllEntityQueryEnumerator<T>();
|
||||
var comps = new List<(EntityUid Uid, T Component)>(Count<T>());
|
||||
@@ -1031,15 +1032,15 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public AllEntityQueryEnumerator<TComp1> AllEntityQueryEnumerator<TComp1>()
|
||||
where TComp1 : IComponent
|
||||
where TComp1 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
return new AllEntityQueryEnumerator<TComp1>(trait1);
|
||||
}
|
||||
|
||||
public AllEntityQueryEnumerator<TComp1, TComp2> AllEntityQueryEnumerator<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1047,9 +1048,9 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public AllEntityQueryEnumerator<TComp1, TComp2, TComp3> AllEntityQueryEnumerator<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1058,10 +1059,10 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1071,15 +1072,15 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public EntityQueryEnumerator<TComp1> EntityQueryEnumerator<TComp1>()
|
||||
where TComp1 : IComponent
|
||||
where TComp1 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
return new EntityQueryEnumerator<TComp1>(trait1, MetaQuery);
|
||||
}
|
||||
|
||||
public EntityQueryEnumerator<TComp1, TComp2> EntityQueryEnumerator<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1087,9 +1088,9 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public EntityQueryEnumerator<TComp1, TComp2, TComp3> EntityQueryEnumerator<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1098,10 +1099,10 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
public EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
|
||||
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
|
||||
@@ -1119,11 +1120,11 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
if (includePaused)
|
||||
{
|
||||
foreach (var t1Comp in comps.Values)
|
||||
foreach (var t1Comp in comps!.Values)
|
||||
{
|
||||
if (t1Comp.Deleted) continue;
|
||||
|
||||
yield return (T)t1Comp;
|
||||
yield return (T)(object)t1Comp;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1134,7 +1135,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
if (metaComp.EntityPaused) continue;
|
||||
|
||||
yield return (T)t1Comp;
|
||||
yield return (T)(object)t1Comp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1157,8 +1158,8 @@ namespace Robust.Shared.GameObjects
|
||||
continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1178,8 +1179,8 @@ namespace Robust.Shared.GameObjects
|
||||
if (meta.EntityPaused) continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1205,9 +1206,9 @@ namespace Robust.Shared.GameObjects
|
||||
continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp,
|
||||
(TComp3) t3Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp,
|
||||
(TComp3)(object)t3Comp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1230,9 +1231,9 @@ namespace Robust.Shared.GameObjects
|
||||
if (meta.EntityPaused) continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp,
|
||||
(TComp3) t3Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp,
|
||||
(TComp3)(object)t3Comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1264,10 +1265,10 @@ namespace Robust.Shared.GameObjects
|
||||
continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp,
|
||||
(TComp3) t3Comp,
|
||||
(TComp4) t4Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp,
|
||||
(TComp3)(object)t3Comp,
|
||||
(TComp4)(object)t4Comp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1293,10 +1294,10 @@ namespace Robust.Shared.GameObjects
|
||||
if (meta.EntityPaused) continue;
|
||||
|
||||
yield return (
|
||||
(TComp1) t1Comp,
|
||||
(TComp2) t2Comp,
|
||||
(TComp3) t3Comp,
|
||||
(TComp4) t4Comp);
|
||||
(TComp1)(object)t1Comp,
|
||||
(TComp2)(object)t2Comp,
|
||||
(TComp3)(object)t3Comp,
|
||||
(TComp4)(object)t4Comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1304,7 +1305,7 @@ namespace Robust.Shared.GameObjects
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<(EntityUid Uid, IComponent Component)> GetAllComponents(Type type, bool includePaused = false)
|
||||
public IEnumerable<(EntityUid Uid, Component Component)> GetAllComponents(Type type, bool includePaused = false)
|
||||
{
|
||||
var comps = _entTraitDict[type];
|
||||
|
||||
@@ -1362,23 +1363,23 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public readonly struct NetComponentEnumerable
|
||||
{
|
||||
private readonly Dictionary<ushort, IComponent> _dictionary;
|
||||
private readonly Dictionary<ushort, Component> _dictionary;
|
||||
|
||||
public NetComponentEnumerable(Dictionary<ushort, IComponent> dictionary) => _dictionary = dictionary;
|
||||
public NetComponentEnumerable(Dictionary<ushort, Component> dictionary) => _dictionary = dictionary;
|
||||
public NetComponentEnumerator GetEnumerator() => new(_dictionary);
|
||||
}
|
||||
|
||||
public struct NetComponentEnumerator
|
||||
{
|
||||
// DO NOT MAKE THIS READONLY
|
||||
private Dictionary<ushort, IComponent>.Enumerator _dictEnum;
|
||||
private Dictionary<ushort, Component>.Enumerator _dictEnum;
|
||||
|
||||
public NetComponentEnumerator(Dictionary<ushort, IComponent> dictionary) =>
|
||||
public NetComponentEnumerator(Dictionary<ushort, Component> dictionary) =>
|
||||
_dictEnum = dictionary.GetEnumerator();
|
||||
|
||||
public bool MoveNext() => _dictEnum.MoveNext();
|
||||
|
||||
public (ushort netId, IComponent component) Current
|
||||
public (ushort netId, Component component) Current
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -1388,12 +1389,12 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct EntityQuery<TComp1> where TComp1 : IComponent
|
||||
public readonly struct EntityQuery<TComp1> where TComp1 : Component
|
||||
{
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict;
|
||||
private readonly ISawmill _sawmill;
|
||||
|
||||
public EntityQuery(Dictionary<EntityUid, IComponent> traitDict, ISawmill sawmill)
|
||||
public EntityQuery(Dictionary<EntityUid, Component> traitDict, ISawmill sawmill)
|
||||
{
|
||||
_traitDict = traitDict;
|
||||
_sawmill = sawmill;
|
||||
@@ -1481,7 +1482,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (TryGetComponent(uid, out var comp))
|
||||
return comp;
|
||||
|
||||
return default;
|
||||
return null;
|
||||
}
|
||||
|
||||
#region Internal
|
||||
@@ -1533,7 +1534,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elides the component.Deleted check of <see cref="HasComponent(EntityUid)"/>
|
||||
/// Elides the component.Deleted check of <see cref="HasComponent"/>
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
@@ -1578,7 +1579,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (TryGetComponent(uid, out var comp))
|
||||
return comp;
|
||||
|
||||
return default;
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1590,13 +1591,13 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching unpaused components.
|
||||
/// </summary>
|
||||
public struct EntityQueryEnumerator<TComp1> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp1 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly EntityQuery<MetaDataComponent> _metaQuery;
|
||||
|
||||
public EntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
EntityQuery<MetaDataComponent> metaQuery)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
@@ -1610,7 +1611,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp1 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1648,16 +1649,16 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching unpaused components.
|
||||
/// </summary>
|
||||
public struct EntityQueryEnumerator<TComp1, TComp2> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
private readonly EntityQuery<MetaDataComponent> _metaQuery;
|
||||
|
||||
public EntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2,
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2,
|
||||
EntityQuery<MetaDataComponent> metaQuery)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
@@ -1672,8 +1673,8 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1717,19 +1718,19 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching unpaused components.
|
||||
/// </summary>
|
||||
public struct EntityQueryEnumerator<TComp1, TComp2, TComp3> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict3;
|
||||
private readonly EntityQuery<MetaDataComponent> _metaQuery;
|
||||
|
||||
public EntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2,
|
||||
Dictionary<EntityUid, IComponent> traitDict3,
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2,
|
||||
Dictionary<EntityUid, Component> traitDict3,
|
||||
EntityQuery<MetaDataComponent> metaQuery)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
@@ -1745,9 +1746,9 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp3 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
comp3 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1800,22 +1801,22 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching unpaused components.
|
||||
/// </summary>
|
||||
public struct EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict4;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict3;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict4;
|
||||
private readonly EntityQuery<MetaDataComponent> _metaQuery;
|
||||
|
||||
public EntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2,
|
||||
Dictionary<EntityUid, IComponent> traitDict3,
|
||||
Dictionary<EntityUid, IComponent> traitDict4,
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2,
|
||||
Dictionary<EntityUid, Component> traitDict3,
|
||||
Dictionary<EntityUid, Component> traitDict4,
|
||||
EntityQuery<MetaDataComponent> metaQuery)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
@@ -1832,10 +1833,10 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp3 = default;
|
||||
comp4 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
comp3 = null;
|
||||
comp4 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1899,12 +1900,12 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching components, paused or not.
|
||||
/// </summary>
|
||||
public struct AllEntityQueryEnumerator<TComp1> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp1 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
|
||||
public AllEntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict)
|
||||
Dictionary<EntityUid, Component> traitDict)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
}
|
||||
@@ -1916,7 +1917,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp1 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1949,15 +1950,15 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching components, paused or not.
|
||||
/// </summary>
|
||||
public struct AllEntityQueryEnumerator<TComp1, TComp2> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
|
||||
public AllEntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2)
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
_traitDict2 = traitDict2;
|
||||
@@ -1970,8 +1971,8 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2010,18 +2011,18 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching components, paused or not.
|
||||
/// </summary>
|
||||
public struct AllEntityQueryEnumerator<TComp1, TComp2, TComp3> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict3;
|
||||
|
||||
public AllEntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2,
|
||||
Dictionary<EntityUid, IComponent> traitDict3)
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2,
|
||||
Dictionary<EntityUid, Component> traitDict3)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
_traitDict2 = traitDict2;
|
||||
@@ -2035,9 +2036,9 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp3 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
comp3 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2085,21 +2086,21 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all matching components, paused or not.
|
||||
/// </summary>
|
||||
public struct AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> : IDisposable
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
|
||||
private readonly Dictionary<EntityUid, IComponent> _traitDict4;
|
||||
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict2;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict3;
|
||||
private readonly Dictionary<EntityUid, Component> _traitDict4;
|
||||
|
||||
public AllEntityQueryEnumerator(
|
||||
Dictionary<EntityUid, IComponent> traitDict,
|
||||
Dictionary<EntityUid, IComponent> traitDict2,
|
||||
Dictionary<EntityUid, IComponent> traitDict3,
|
||||
Dictionary<EntityUid, IComponent> traitDict4)
|
||||
Dictionary<EntityUid, Component> traitDict,
|
||||
Dictionary<EntityUid, Component> traitDict2,
|
||||
Dictionary<EntityUid, Component> traitDict3,
|
||||
Dictionary<EntityUid, Component> traitDict4)
|
||||
{
|
||||
_traitDict = traitDict.GetEnumerator();
|
||||
_traitDict2 = traitDict2;
|
||||
@@ -2114,10 +2115,10 @@ namespace Robust.Shared.GameObjects
|
||||
if (!_traitDict.MoveNext())
|
||||
{
|
||||
uid = default;
|
||||
comp1 = default;
|
||||
comp2 = default;
|
||||
comp3 = default;
|
||||
comp4 = default;
|
||||
comp1 = null;
|
||||
comp2 = null;
|
||||
comp3 = null;
|
||||
comp4 = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class EntityManager
|
||||
/// Increases the life stage from <see cref="ComponentLifeStage.PreAdd" /> to <see cref="ComponentLifeStage.Added" />,
|
||||
/// after raising a <see cref="ComponentAdd"/> event.
|
||||
/// </summary>
|
||||
internal void LifeAddToEntity(IComponent component, CompIdx type)
|
||||
internal void LifeAddToEntity(Component component, CompIdx type)
|
||||
{
|
||||
DebugTools.Assert(component.LifeStage == ComponentLifeStage.PreAdd);
|
||||
|
||||
@@ -30,7 +30,7 @@ public partial class EntityManager
|
||||
/// Increases the life stage from <see cref="ComponentLifeStage.Added" /> to <see cref="ComponentLifeStage.Initialized" />,
|
||||
/// calling <see cref="Initialize" />.
|
||||
/// </summary>
|
||||
internal void LifeInitialize(IComponent component, CompIdx type)
|
||||
internal void LifeInitialize(Component component, CompIdx type)
|
||||
{
|
||||
DebugTools.Assert(component.LifeStage == ComponentLifeStage.Added);
|
||||
|
||||
@@ -43,7 +43,7 @@ public partial class EntityManager
|
||||
/// Increases the life stage from <see cref="ComponentLifeStage.Initialized" /> to
|
||||
/// <see cref="ComponentLifeStage.Running" />, calling <see cref="Startup" />.
|
||||
/// </summary>
|
||||
internal void LifeStartup(IComponent component)
|
||||
internal void LifeStartup(Component component)
|
||||
{
|
||||
DebugTools.Assert(component.LifeStage == ComponentLifeStage.Initialized);
|
||||
|
||||
@@ -59,7 +59,7 @@ public partial class EntityManager
|
||||
/// <remarks>
|
||||
/// Components are allowed to remove themselves in their own Startup function.
|
||||
/// </remarks>
|
||||
internal void LifeShutdown(IComponent component)
|
||||
internal void LifeShutdown(Component component)
|
||||
{
|
||||
DebugTools.Assert(component.LifeStage is >= ComponentLifeStage.Initializing and < ComponentLifeStage.Stopping);
|
||||
|
||||
@@ -79,13 +79,21 @@ public partial class EntityManager
|
||||
/// Increases the life stage from <see cref="ComponentLifeStage.Stopped" /> to <see cref="ComponentLifeStage.Deleted" />,
|
||||
/// calling <see cref="Component.OnRemove" />.
|
||||
/// </summary>
|
||||
internal void LifeRemoveFromEntity(IComponent component)
|
||||
internal void LifeRemoveFromEntity(Component component)
|
||||
{
|
||||
// can be called at any time after PreAdd, including inside other life stage events.
|
||||
DebugTools.Assert(component.LifeStage != ComponentLifeStage.PreAdd);
|
||||
|
||||
component.LifeStage = ComponentLifeStage.Removing;
|
||||
EventBus.RaiseComponentEvent(component, CompRemoveInstance);
|
||||
component.LifeStage = ComponentLifeStage.Deleted;
|
||||
|
||||
component.OnRemove();
|
||||
|
||||
#if DEBUG
|
||||
if (component.LifeStage != ComponentLifeStage.Deleted)
|
||||
{
|
||||
DebugTools.Assert($"Component {component.GetType().Name} did not call base {nameof(component.OnRemove)} in derived method.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
public delegate void EntityUidQueryCallback(EntityUid uid);
|
||||
|
||||
public delegate void ComponentQueryCallback<T>(EntityUid uid, T component) where T : IComponent;
|
||||
public delegate void ComponentQueryCallback<T>(EntityUid uid, T component) where T : Component;
|
||||
|
||||
/// <inheritdoc />
|
||||
[Virtual]
|
||||
@@ -387,13 +387,13 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete("use override with an EntityUid")]
|
||||
public void Dirty(IComponent component, MetaDataComponent? meta = null)
|
||||
public void Dirty(Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
Dirty(component.Owner, component, meta);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Dirty(EntityUid uid, IComponent component, MetaDataComponent? meta = null)
|
||||
public virtual void Dirty(EntityUid uid, Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
if (component.LifeStage >= ComponentLifeStage.Removing || !component.NetSyncEnabled)
|
||||
return;
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
public static class EntityManagerExt
|
||||
{
|
||||
public static T? GetComponentOrNull<T>(this IEntityManager entityManager, EntityUid entityUid)
|
||||
where T : IComponent
|
||||
where T : class, IComponent
|
||||
{
|
||||
if (entityManager.TryGetComponent(entityUid, out T? component))
|
||||
return component;
|
||||
|
||||
return default;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static T? GetComponentOrNull<T>(this IEntityManager entityManager, EntityUid? entityUid)
|
||||
where T : IComponent
|
||||
where T : class, IComponent
|
||||
{
|
||||
if (entityUid.HasValue && entityManager.TryGetComponent(entityUid.Value, out T? component))
|
||||
return component;
|
||||
|
||||
return default;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public partial class EntitySystem
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Obsolete("Use Dirty(EntityUid, Component, MetaDataComponent?")]
|
||||
protected void Dirty(IComponent component, MetaDataComponent? meta = null)
|
||||
protected void Dirty(Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
EntityManager.Dirty(component, meta);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public partial class EntitySystem
|
||||
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void Dirty(EntityUid uid, IComponent component, MetaDataComponent? meta = null)
|
||||
protected void Dirty(EntityUid uid, Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
EntityManager.Dirty(uid, component, meta);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ public partial class EntitySystem
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.GetComponent<T>"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T Comp<T>(EntityUid uid) where T : IComponent
|
||||
protected T Comp<T>(EntityUid uid) where T : Component
|
||||
{
|
||||
return EntityManager.GetComponent<T>(uid);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ public partial class EntitySystem
|
||||
/// Returns the component of a specific type, or null when it's missing or the entity does not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T? CompOrNull<T>(EntityUid uid) where T : IComponent
|
||||
protected T? CompOrNull<T>(EntityUid uid) where T : class, IComponent
|
||||
{
|
||||
return EntityManager.GetComponentOrNull<T>(uid);
|
||||
}
|
||||
@@ -451,9 +451,9 @@ public partial class EntitySystem
|
||||
/// Returns the component of a specific type, or null when it's missing or the entity does not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T? CompOrNull<T>(EntityUid? uid) where T : IComponent
|
||||
protected T? CompOrNull<T>(EntityUid? uid) where T : class, IComponent
|
||||
{
|
||||
return uid.HasValue ? EntityManager.GetComponentOrNull<T>(uid.Value) : default;
|
||||
return uid.HasValue ? EntityManager.GetComponentOrNull<T>(uid.Value) : null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.TryGetComponent<T>(EntityUid, out T)"/>
|
||||
@@ -614,14 +614,14 @@ public partial class EntitySystem
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.AddComponent<T>(EntityUid, T, bool)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void AddComp<T>(EntityUid uid, T component, bool overwrite = false) where T : IComponent
|
||||
protected void AddComp<T>(EntityUid uid, T component, bool overwrite = false) where T : Component
|
||||
{
|
||||
EntityManager.AddComponent(uid, component, overwrite);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.EnsureComponent<T>(EntityUid)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T EnsureComp<T>(EntityUid uid) where T : IComponent, new()
|
||||
protected T EnsureComp<T>(EntityUid uid) where T : Component, new()
|
||||
{
|
||||
return EntityManager.EnsureComponent<T>(uid);
|
||||
}
|
||||
@@ -632,7 +632,7 @@ public partial class EntitySystem
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponentDeferred<T>(EntityUid)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool RemCompDeferred<T>(EntityUid uid) where T : IComponent
|
||||
protected bool RemCompDeferred<T>(EntityUid uid) where T : class, IComponent
|
||||
{
|
||||
return EntityManager.RemoveComponentDeferred<T>(uid);
|
||||
}
|
||||
@@ -663,7 +663,7 @@ public partial class EntitySystem
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.Count" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected int Count<T>() where T : IComponent
|
||||
protected int Count<T>() where T : Component
|
||||
{
|
||||
return EntityManager.Count<T>();
|
||||
}
|
||||
@@ -681,7 +681,7 @@ public partial class EntitySystem
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponent<T>(EntityUid)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool RemComp<T>(EntityUid uid) where T : IComponent
|
||||
protected bool RemComp<T>(EntityUid uid) where T : class, IComponent
|
||||
{
|
||||
return EntityManager.RemoveComponent<T>(uid);
|
||||
}
|
||||
@@ -819,34 +819,34 @@ public partial class EntitySystem
|
||||
#region All Entity Query
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected AllEntityQueryEnumerator<TComp1> AllEntityQuery<TComp1>() where TComp1 : IComponent
|
||||
protected AllEntityQueryEnumerator<TComp1> AllEntityQuery<TComp1>() where TComp1 : Component
|
||||
{
|
||||
return EntityManager.AllEntityQueryEnumerator<TComp1>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected AllEntityQueryEnumerator<TComp1, TComp2> AllEntityQuery<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
return EntityManager.AllEntityQueryEnumerator<TComp1, TComp2>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected AllEntityQueryEnumerator<TComp1, TComp2, TComp3> AllEntityQuery<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
return EntityManager.AllEntityQueryEnumerator<TComp1, TComp2, TComp3>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> AllEntityQuery<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
return EntityManager.AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>();
|
||||
}
|
||||
@@ -856,34 +856,34 @@ public partial class EntitySystem
|
||||
#region Get Entity Query
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected EntityQueryEnumerator<TComp1> EntityQueryEnumerator<TComp1>() where TComp1 : IComponent
|
||||
protected EntityQueryEnumerator<TComp1> EntityQueryEnumerator<TComp1>() where TComp1 : Component
|
||||
{
|
||||
return EntityManager.EntityQueryEnumerator<TComp1>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected EntityQueryEnumerator<TComp1, TComp2> EntityQueryEnumerator<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
return EntityManager.EntityQueryEnumerator<TComp1, TComp2>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected EntityQueryEnumerator<TComp1, TComp2, TComp3> EntityQueryEnumerator<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
return EntityManager.EntityQueryEnumerator<TComp1, TComp2, TComp3>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
return EntityManager.EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>();
|
||||
}
|
||||
@@ -897,7 +897,7 @@ public partial class EntitySystem
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
protected EntityQuery<T> GetEntityQuery<T>() where T : IComponent
|
||||
protected EntityQuery<T> GetEntityQuery<T>() where T : Component
|
||||
{
|
||||
return EntityManager.GetEntityQuery<T>();
|
||||
}
|
||||
@@ -906,7 +906,7 @@ public partial class EntitySystem
|
||||
/// If you need the EntityUid, use <see cref="EntityQueryEnumerator{TComp1}"/>
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected IEnumerable<TComp1> EntityQuery<TComp1>(bool includePaused = false) where TComp1 : IComponent
|
||||
protected IEnumerable<TComp1> EntityQuery<TComp1>(bool includePaused = false) where TComp1 : Component
|
||||
{
|
||||
return EntityManager.EntityQuery<TComp1>(includePaused);
|
||||
}
|
||||
@@ -916,8 +916,8 @@ public partial class EntitySystem
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected IEnumerable<(TComp1, TComp2)> EntityQuery<TComp1, TComp2>(bool includePaused = false)
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
{
|
||||
return EntityManager.EntityQuery<TComp1, TComp2>(includePaused);
|
||||
}
|
||||
@@ -927,9 +927,9 @@ public partial class EntitySystem
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected IEnumerable<(TComp1, TComp2, TComp3)> EntityQuery<TComp1, TComp2, TComp3>(bool includePaused = false)
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
{
|
||||
return EntityManager.EntityQuery<TComp1, TComp2, TComp3>(includePaused);
|
||||
}
|
||||
@@ -939,10 +939,10 @@ public partial class EntitySystem
|
||||
/// </remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected IEnumerable<(TComp1, TComp2, TComp3, TComp4)> EntityQuery<TComp1, TComp2, TComp3, TComp4>(bool includePaused = false)
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component
|
||||
{
|
||||
return EntityManager.EntityQuery<TComp1, TComp2, TComp3, TComp4>(includePaused);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
/// <remarks>
|
||||
/// Base component for the ECS system.
|
||||
/// All discoverable implementations of IComponent must override the <see cref="Name" />.
|
||||
/// Instances are dynamically instantiated by a <c>ComponentFactory</c>, and will have their IoC Dependencies resolved.
|
||||
/// </remarks>
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
@@ -16,10 +17,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// The current lifetime stage of this component. You can use this to check
|
||||
/// if the component is initialized or being deleted.
|
||||
/// </summary>
|
||||
ComponentLifeStage LifeStage { get; [Obsolete("Do not use from content")] set; }
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
bool Networked { get; set; }
|
||||
ComponentLifeStage LifeStage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this component should be synchronized with clients when modified.
|
||||
@@ -30,24 +28,11 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
bool NetSyncEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, and if this is a networked component, then component data will only be sent to players if their
|
||||
/// controlled entity is the owner of this component. This is less performance intensive than <see cref="SessionSpecific"/>.
|
||||
/// </summary>
|
||||
bool SendOnlyToOwner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, and if this is a networked component, then this component will cause <see
|
||||
/// cref="ComponentGetStateAttemptEvent"/> events to be raised to check whether a given player should
|
||||
/// receive this component's state.
|
||||
/// </summary>
|
||||
bool SessionSpecific { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that this component is attached to.
|
||||
/// </summary>
|
||||
/// <seealso cref="EntityQueryEnumerator{TComp1}"/>
|
||||
EntityUid Owner { get; set; }
|
||||
EntityUid Owner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Component has been (or is currently being) initialized.
|
||||
@@ -72,17 +57,11 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// This is the tick the component was created.
|
||||
/// </summary>
|
||||
GameTick CreationTick { get; [Obsolete("Do not use from content")] set; }
|
||||
GameTick CreationTick { get; }
|
||||
|
||||
/// <summary>
|
||||
/// This is the last game tick Dirty() was called.
|
||||
/// </summary>
|
||||
GameTick LastModifiedTick { get; [Obsolete("Do not use from content")] set; }
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
void ClearTicks();
|
||||
|
||||
[Obsolete("Do not use from content")]
|
||||
void ClearCreationTick();
|
||||
GameTick LastModifiedTick { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Gets the number of a specific component.
|
||||
/// </summary>
|
||||
public int Count<T>() where T : IComponent;
|
||||
public int Count<T>() where T : Component;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of a specific component.
|
||||
@@ -44,7 +44,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Concrete component type to add.</typeparam>
|
||||
/// <returns>The newly added component.</returns>
|
||||
T AddComponent<T>(EntityUid uid) where T : IComponent, new();
|
||||
T AddComponent<T>(EntityUid uid) where T : Component, new();
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Component with a given network id to an entity.
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid">Entity being modified.</param>
|
||||
/// <returns>Component initialization handle. When you are done setting up the component, make sure to dispose this.</returns>
|
||||
[Obsolete]
|
||||
EntityManager.CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : IComponent, new();
|
||||
EntityManager.CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : Component, new();
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Component to an entity. If the entity is already Initialized, the component will
|
||||
@@ -71,7 +71,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid">Entity being modified.</param>
|
||||
/// <param name="component">Component to add.</param>
|
||||
/// <param name="overwrite">Should it overwrite existing components?</param>
|
||||
void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : IComponent;
|
||||
void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : Component;
|
||||
|
||||
/// <summary>
|
||||
/// Removes the component with the specified reference type,
|
||||
@@ -214,7 +214,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid">Entity to modify.</param>
|
||||
/// <typeparam name="T">Component to add.</typeparam>
|
||||
/// <returns>The component in question</returns>
|
||||
T EnsureComponent<T>(EntityUid uid) where T : IComponent, new();
|
||||
T EnsureComponent<T>(EntityUid uid) where T : Component, new();
|
||||
|
||||
/// <summary>
|
||||
/// This method will always return a component for a certain entity, adding it if it's not there already.
|
||||
@@ -223,7 +223,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="component">The output component after being ensured.</param>
|
||||
/// <typeparam name="T">Component to add.</typeparam>
|
||||
/// <returns>True if the component already existed</returns>
|
||||
bool EnsureComponent<T>(EntityUid uid, out T component) where T : IComponent, new();
|
||||
bool EnsureComponent<T>(EntityUid uid, out T component) where T : Component, new();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component of a specific type.
|
||||
@@ -334,9 +334,9 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Returns a cached struct enumerator with the specified component.
|
||||
/// </summary>
|
||||
EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : IComponent;
|
||||
EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : Component;
|
||||
|
||||
EntityQuery<IComponent> GetEntityQuery(Type type);
|
||||
EntityQuery<Component> GetEntityQuery(Type type);
|
||||
|
||||
/// <summary>
|
||||
/// Returns ALL component type instances on an entity. A single component instance
|
||||
@@ -398,49 +398,49 @@ namespace Robust.Shared.GameObjects
|
||||
/// Returns all instances of a component in an array.
|
||||
/// Use sparingly.
|
||||
/// </summary>
|
||||
(EntityUid Uid, T Component)[] AllComponents<T>() where T : IComponent;
|
||||
(EntityUid Uid, T Component)[] AllComponents<T>() where T : Component;
|
||||
|
||||
/// <summary>
|
||||
/// Returns all instances of a component in a List.
|
||||
/// Use sparingly.
|
||||
/// </summary>
|
||||
List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : IComponent;
|
||||
List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : Component;
|
||||
|
||||
AllEntityQueryEnumerator<TComp1> AllEntityQueryEnumerator<TComp1>()
|
||||
where TComp1 : IComponent;
|
||||
where TComp1 : Component;
|
||||
|
||||
AllEntityQueryEnumerator<TComp1, TComp2> AllEntityQueryEnumerator<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component;
|
||||
|
||||
AllEntityQueryEnumerator<TComp1, TComp2, TComp3> AllEntityQueryEnumerator<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component;
|
||||
|
||||
AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component;
|
||||
|
||||
EntityQueryEnumerator<TComp1> EntityQueryEnumerator<TComp1>()
|
||||
where TComp1 : IComponent;
|
||||
where TComp1 : Component;
|
||||
|
||||
EntityQueryEnumerator<TComp1, TComp2> EntityQueryEnumerator<TComp1, TComp2>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component;
|
||||
|
||||
EntityQueryEnumerator<TComp1, TComp2, TComp3> EntityQueryEnumerator<TComp1, TComp2, TComp3>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component;
|
||||
|
||||
EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
|
||||
where TComp1 : IComponent
|
||||
where TComp2 : IComponent
|
||||
where TComp3 : IComponent
|
||||
where TComp4 : IComponent;
|
||||
where TComp1 : Component
|
||||
where TComp2 : Component
|
||||
where TComp3 : Component
|
||||
where TComp4 : Component;
|
||||
|
||||
/// <summary>
|
||||
/// Returns ALL component instances of a specified type.
|
||||
@@ -491,7 +491,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="type">A trait or component type to check for.</param>
|
||||
/// <param name="includePaused"></param>
|
||||
/// <returns>All components that are the specified type.</returns>
|
||||
IEnumerable<(EntityUid Uid, IComponent Component)> GetAllComponents(Type type, bool includePaused = false);
|
||||
IEnumerable<(EntityUid Uid, Component Component)> GetAllComponents(Type type, bool includePaused = false);
|
||||
|
||||
/// <summary>
|
||||
/// Culls all components from the collection that are marked as deleted. This needs to be called often.
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public void DirtyEntity(EntityUid uid, MetaDataComponent? metadata = null);
|
||||
|
||||
public void Dirty(IComponent component, MetaDataComponent? metadata = null);
|
||||
public void Dirty(Component component, MetaDataComponent? metadata = null);
|
||||
|
||||
public void Dirty(EntityUid uid, IComponent component, MetaDataComponent? meta = null);
|
||||
public void Dirty(EntityUid uid, Component component, MetaDataComponent? meta = null);
|
||||
|
||||
public void QueueDeleteEntity(EntityUid? uid);
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -19,7 +21,7 @@ public sealed partial class EntityLookupSystem
|
||||
HashSet<T> intersecting,
|
||||
Box2 worldAABB,
|
||||
LookupFlags flags,
|
||||
EntityQuery<T> query) where T : IComponent
|
||||
EntityQuery<T> query) where T : Component
|
||||
{
|
||||
var lookup = _broadQuery.GetComponent(lookupUid);
|
||||
var invMatrix = _transform.GetInvWorldMatrix(lookupUid);
|
||||
@@ -80,7 +82,7 @@ public sealed partial class EntityLookupSystem
|
||||
Box2 worldAABB,
|
||||
LookupFlags flags,
|
||||
EntityQuery<T> query,
|
||||
EntityUid? ignored = null) where T : IComponent
|
||||
EntityUid? ignored = null) where T : Component
|
||||
{
|
||||
var lookup = _broadQuery.GetComponent(lookupUid);
|
||||
var invMatrix = _transform.GetInvWorldMatrix(lookupUid);
|
||||
@@ -151,7 +153,7 @@ public sealed partial class EntityLookupSystem
|
||||
return state.found;
|
||||
}
|
||||
|
||||
private void RecursiveAdd<T>(EntityUid uid, ref ValueList<T> toAdd, EntityQuery<T> query) where T : IComponent
|
||||
private void RecursiveAdd<T>(EntityUid uid, ref ValueList<T> toAdd, EntityQuery<T> query) where T : Component
|
||||
{
|
||||
var childEnumerator = _xformQuery.GetComponent(uid).ChildEnumerator;
|
||||
|
||||
@@ -166,7 +168,7 @@ public sealed partial class EntityLookupSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void AddContained<T>(HashSet<T> intersecting, LookupFlags flags, EntityQuery<T> query) where T : IComponent
|
||||
private void AddContained<T>(HashSet<T> intersecting, LookupFlags flags, EntityQuery<T> query) where T : Component
|
||||
{
|
||||
if ((flags & LookupFlags.Contained) == 0x0) return;
|
||||
|
||||
@@ -207,7 +209,7 @@ public sealed partial class EntityLookupSystem
|
||||
/// <summary>
|
||||
/// Should we just iterate every component and check position or do bounds checks.
|
||||
/// </summary>
|
||||
private bool UseBoundsQuery<T>(float area) where T : IComponent
|
||||
private bool UseBoundsQuery<T>(float area) where T : Component
|
||||
{
|
||||
// If the component has a low count we'll just do an estimate if it's faster to iterate every comp directly
|
||||
// Might be useful to have some way to expose this to content?
|
||||
@@ -222,7 +224,7 @@ public sealed partial class EntityLookupSystem
|
||||
|
||||
public bool AnyComponentsIntersecting(Type type, MapId mapId, Box2 worldAABB, EntityUid? ignored = null, LookupFlags flags = DefaultFlags)
|
||||
{
|
||||
DebugTools.Assert(typeof(IComponent).IsAssignableFrom(type));
|
||||
DebugTools.Assert(typeof(Component).IsAssignableFrom(type));
|
||||
if (mapId == MapId.Nullspace) return false;
|
||||
|
||||
if (!UseBoundsQuery(type, worldAABB.Height * worldAABB.Width))
|
||||
@@ -254,7 +256,7 @@ public sealed partial class EntityLookupSystem
|
||||
(EntityLookupSystem system,
|
||||
Box2 worldAABB,
|
||||
LookupFlags flags,
|
||||
EntityQuery<IComponent> query,
|
||||
EntityQuery<Component> query,
|
||||
EntityUid? ignored,
|
||||
bool found) tuple) =>
|
||||
{
|
||||
@@ -272,13 +274,13 @@ public sealed partial class EntityLookupSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashSet<IComponent> GetComponentsIntersecting(Type type, MapId mapId, Box2 worldAABB, LookupFlags flags = DefaultFlags)
|
||||
public HashSet<Component> GetComponentsIntersecting(Type type, MapId mapId, Box2 worldAABB, LookupFlags flags = DefaultFlags)
|
||||
{
|
||||
DebugTools.Assert(typeof(IComponent).IsAssignableFrom(type));
|
||||
DebugTools.Assert(typeof(Component).IsAssignableFrom(type));
|
||||
if (mapId == MapId.Nullspace)
|
||||
return new HashSet<IComponent>();
|
||||
return new HashSet<Component>();
|
||||
|
||||
var intersecting = new HashSet<IComponent>();
|
||||
var intersecting = new HashSet<Component>();
|
||||
|
||||
if (!UseBoundsQuery(type, worldAABB.Height * worldAABB.Width))
|
||||
{
|
||||
@@ -309,8 +311,8 @@ public sealed partial class EntityLookupSystem
|
||||
ref (EntityLookupSystem system,
|
||||
Box2 worldAABB,
|
||||
LookupFlags flags,
|
||||
EntityQuery<IComponent> query,
|
||||
HashSet<IComponent> intersecting) tuple) =>
|
||||
EntityQuery<Component> query,
|
||||
HashSet<Component> intersecting) tuple) =>
|
||||
{
|
||||
tuple.system.AddComponentsIntersecting(uid, tuple.intersecting, tuple.worldAABB, tuple.flags, tuple.query);
|
||||
return true;
|
||||
@@ -325,7 +327,7 @@ public sealed partial class EntityLookupSystem
|
||||
return intersecting;
|
||||
}
|
||||
|
||||
public HashSet<T> GetComponentsIntersecting<T>(MapId mapId, Box2 worldAABB, LookupFlags flags = DefaultFlags) where T : IComponent
|
||||
public HashSet<T> GetComponentsIntersecting<T>(MapId mapId, Box2 worldAABB, LookupFlags flags = DefaultFlags) where T : Component
|
||||
{
|
||||
if (mapId == MapId.Nullspace) return new HashSet<T>();
|
||||
|
||||
@@ -373,7 +375,7 @@ public sealed partial class EntityLookupSystem
|
||||
|
||||
#region EntityCoordinates
|
||||
|
||||
public HashSet<T> GetComponentsInRange<T>(EntityCoordinates coordinates, float range) where T : IComponent
|
||||
public HashSet<T> GetComponentsInRange<T>(EntityCoordinates coordinates, float range) where T : Component
|
||||
{
|
||||
var mapPos = coordinates.ToMap(EntityManager, _transform);
|
||||
return GetComponentsInRange<T>(mapPos, range);
|
||||
@@ -382,13 +384,13 @@ public sealed partial class EntityLookupSystem
|
||||
|
||||
#region MapCoordinates
|
||||
|
||||
public HashSet<IComponent> GetComponentsInRange(Type type, MapCoordinates coordinates, float range)
|
||||
public HashSet<Component> GetComponentsInRange(Type type, MapCoordinates coordinates, float range)
|
||||
{
|
||||
DebugTools.Assert(typeof(IComponent).IsAssignableFrom(type));
|
||||
DebugTools.Assert(typeof(Component).IsAssignableFrom(type));
|
||||
return GetComponentsInRange(type, coordinates.MapId, coordinates.Position, range);
|
||||
}
|
||||
|
||||
public HashSet<T> GetComponentsInRange<T>(MapCoordinates coordinates, float range) where T : IComponent
|
||||
public HashSet<T> GetComponentsInRange<T>(MapCoordinates coordinates, float range) where T : Component
|
||||
{
|
||||
return GetComponentsInRange<T>(coordinates.MapId, coordinates.Position, range);
|
||||
}
|
||||
@@ -399,7 +401,7 @@ public sealed partial class EntityLookupSystem
|
||||
|
||||
public bool AnyComponentsInRange(Type type, MapId mapId, Vector2 worldPos, float range)
|
||||
{
|
||||
DebugTools.Assert(typeof(IComponent).IsAssignableFrom(type));
|
||||
DebugTools.Assert(typeof(Component).IsAssignableFrom(type));
|
||||
DebugTools.Assert(range > 0, "Range must be a positive float");
|
||||
|
||||
if (mapId == MapId.Nullspace) return false;
|
||||
@@ -411,12 +413,12 @@ public sealed partial class EntityLookupSystem
|
||||
return AnyComponentsIntersecting(type, mapId, worldAABB);
|
||||
}
|
||||
|
||||
public HashSet<IComponent> GetComponentsInRange(Type type, MapId mapId, Vector2 worldPos, float range)
|
||||
public HashSet<Component> GetComponentsInRange(Type type, MapId mapId, Vector2 worldPos, float range)
|
||||
{
|
||||
DebugTools.Assert(typeof(IComponent).IsAssignableFrom(type));
|
||||
DebugTools.Assert(typeof(Component).IsAssignableFrom(type));
|
||||
DebugTools.Assert(range > 0, "Range must be a positive float");
|
||||
|
||||
if (mapId == MapId.Nullspace) return new HashSet<IComponent>();
|
||||
if (mapId == MapId.Nullspace) return new HashSet<Component>();
|
||||
|
||||
// TODO: Actual circles
|
||||
var rangeVec = new Vector2(range, range);
|
||||
@@ -425,7 +427,7 @@ public sealed partial class EntityLookupSystem
|
||||
return GetComponentsIntersecting(type, mapId, worldAABB);
|
||||
}
|
||||
|
||||
public HashSet<T> GetComponentsInRange<T>(MapId mapId, Vector2 worldPos, float range) where T : IComponent
|
||||
public HashSet<T> GetComponentsInRange<T>(MapId mapId, Vector2 worldPos, float range) where T : Component
|
||||
{
|
||||
DebugTools.Assert(range > 0, "Range must be a positive float");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using System;
|
||||
|
||||
namespace Robust.Shared.Physics;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Robust.Shared.Physics;
|
||||
/// overriden, such that we can remove entries without needing to fetch the transform component of a possible
|
||||
/// deleted entity.
|
||||
/// </summary>
|
||||
public readonly struct ComponentTreeEntry<T> : IEquatable<ComponentTreeEntry<T>>, IComparable<ComponentTreeEntry<T>> where T : IComponent
|
||||
public readonly struct ComponentTreeEntry<T> : IEquatable<ComponentTreeEntry<T>>, IComparable<ComponentTreeEntry<T>> where T : Component
|
||||
{
|
||||
public T Component { get; init; }
|
||||
public TransformComponent Transform { get; init; }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<PackageReference Include="Linguini.Bundle" Version="0.1.3" />
|
||||
<PackageReference Include="SharpZstd.Interop" Version="1.5.2-beta2" PrivateAssets="compile" />
|
||||
<PackageReference Include="SpaceWizards.Sodium" Version="0.2.1" PrivateAssets="compile" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.7" />
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-rc2" PrivateAssets="compile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -28,7 +28,7 @@ internal sealed class CompCommand : ToolshedCommand
|
||||
|
||||
[CommandImplementation("add")]
|
||||
public EntityUid Add<T>([PipedArgument] EntityUid input)
|
||||
where T: IComponent, new()
|
||||
where T: Component, new()
|
||||
{
|
||||
AddComp<T>(input);
|
||||
return input;
|
||||
@@ -36,13 +36,13 @@ internal sealed class CompCommand : ToolshedCommand
|
||||
|
||||
[CommandImplementation("add")]
|
||||
public IEnumerable<EntityUid> Add<T>([PipedArgument] IEnumerable<EntityUid> input)
|
||||
where T : IComponent, new()
|
||||
where T : Component, new()
|
||||
=> input.Select(Add<T>);
|
||||
|
||||
|
||||
[CommandImplementation("rm")]
|
||||
public EntityUid Rm<T>([PipedArgument] EntityUid input)
|
||||
where T: IComponent, new()
|
||||
where T: Component, new()
|
||||
{
|
||||
RemComp<T>(input);
|
||||
return input;
|
||||
@@ -50,12 +50,12 @@ internal sealed class CompCommand : ToolshedCommand
|
||||
|
||||
[CommandImplementation("rm")]
|
||||
public IEnumerable<EntityUid> Rm<T>([PipedArgument] IEnumerable<EntityUid> input)
|
||||
where T : IComponent, new()
|
||||
where T : Component, new()
|
||||
=> input.Select(Rm<T>);
|
||||
|
||||
[CommandImplementation("ensure")]
|
||||
public EntityUid Ensure<T>([PipedArgument] EntityUid input)
|
||||
where T: IComponent, new()
|
||||
where T: Component, new()
|
||||
{
|
||||
EnsureComp<T>(input);
|
||||
return input;
|
||||
@@ -63,7 +63,7 @@ internal sealed class CompCommand : ToolshedCommand
|
||||
|
||||
[CommandImplementation("ensure")]
|
||||
public IEnumerable<EntityUid> Ensure<T>([PipedArgument] IEnumerable<EntityUid> input)
|
||||
where T : IComponent, new()
|
||||
where T : Component, new()
|
||||
=> input.Select(Ensure<T>);
|
||||
|
||||
[CommandImplementation("has")]
|
||||
|
||||
@@ -126,7 +126,7 @@ public abstract partial class ToolshedCommand
|
||||
/// </summary>
|
||||
[PublicAPI, MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T AddComp<T>(EntityUid entity)
|
||||
where T : IComponent, new()
|
||||
where T : Component, new()
|
||||
=> EntityManager.AddComponent<T>(entity);
|
||||
|
||||
/// <summary>
|
||||
@@ -142,7 +142,7 @@ public abstract partial class ToolshedCommand
|
||||
/// </summary>
|
||||
[PublicAPI, MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected T EnsureComp<T>(EntityUid entity)
|
||||
where T: IComponent, new()
|
||||
where T: Component, new()
|
||||
=> EntityManager.EnsureComponent<T>(entity);
|
||||
|
||||
/// <summary>
|
||||
@@ -159,6 +159,6 @@ public abstract partial class ToolshedCommand
|
||||
/// </summary>
|
||||
[PublicAPI, MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected EntityQuery<T> GetEntityQuery<T>()
|
||||
where T : IComponent
|
||||
where T : Component
|
||||
=> EntityManager.GetEntityQuery<T>();
|
||||
}
|
||||
|
||||
6
global.json
Normal file
6
global.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "7.0.100",
|
||||
"rollForward": "latestFeature"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user