Kill ComponentExt (#20907)

This commit is contained in:
Kara
2023-10-11 02:19:46 -07:00
committed by GitHub
parent dbb7c7065a
commit 7dd20f7af1
6 changed files with 20 additions and 40 deletions

View File

@@ -63,11 +63,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
user = sEntities.SpawnEntity(null, coords); user = sEntities.SpawnEntity(null, coords);
user.EnsureComponent<HandsComponent>(); sEntities.EnsureComponent<HandsComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left); handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, coords); target = sEntities.SpawnEntity(null, coords);
item = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords);
item.EnsureComponent<ItemComponent>(); sEntities.EnsureComponent<ItemComponent>(item);
}); });
await server.WaitRunTicks(1); await server.WaitRunTicks(1);
@@ -134,11 +134,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
user = sEntities.SpawnEntity(null, coords); user = sEntities.SpawnEntity(null, coords);
user.EnsureComponent<HandsComponent>(); sEntities.EnsureComponent<HandsComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left); handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(1.9f, 0), mapId)); target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(1.9f, 0), mapId));
item = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords);
item.EnsureComponent<ItemComponent>(); sEntities.EnsureComponent<ItemComponent>(item);
wall = sEntities.SpawnEntity("DummyDebugWall", new MapCoordinates(new Vector2(1, 0), sEntities.GetComponent<TransformComponent>(user).MapID)); wall = sEntities.SpawnEntity("DummyDebugWall", new MapCoordinates(new Vector2(1, 0), sEntities.GetComponent<TransformComponent>(user).MapID));
}); });
@@ -204,11 +204,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
user = sEntities.SpawnEntity(null, coords); user = sEntities.SpawnEntity(null, coords);
user.EnsureComponent<HandsComponent>(); sEntities.EnsureComponent<HandsComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left); handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange - 0.1f, 0), mapId)); target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange - 0.1f, 0), mapId));
item = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords);
item.EnsureComponent<ItemComponent>(); sEntities.EnsureComponent<ItemComponent>(item);
}); });
await server.WaitRunTicks(1); await server.WaitRunTicks(1);
@@ -274,11 +274,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
user = sEntities.SpawnEntity(null, coords); user = sEntities.SpawnEntity(null, coords);
user.EnsureComponent<HandsComponent>(); sEntities.EnsureComponent<HandsComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left); handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange + 0.01f, 0), mapId)); target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange + 0.01f, 0), mapId));
item = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords);
item.EnsureComponent<ItemComponent>(); sEntities.EnsureComponent<ItemComponent>(item);
}); });
await server.WaitRunTicks(1); await server.WaitRunTicks(1);
@@ -346,11 +346,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
user = sEntities.SpawnEntity(null, coords); user = sEntities.SpawnEntity(null, coords);
user.EnsureComponent<HandsComponent>(); sEntities.EnsureComponent<HandsComponent>(user);
handSys.AddHand(user, "hand", HandLocation.Left); handSys.AddHand(user, "hand", HandLocation.Left);
target = sEntities.SpawnEntity(null, coords); target = sEntities.SpawnEntity(null, coords);
item = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords);
item.EnsureComponent<ItemComponent>(); sEntities.EnsureComponent<ItemComponent>(item);
containerEntity = sEntities.SpawnEntity(null, coords); containerEntity = sEntities.SpawnEntity(null, coords);
container = conSystem.EnsureContainer<Container>(containerEntity, "InteractionTestContainer"); container = conSystem.EnsureContainer<Container>(containerEntity, "InteractionTestContainer");
}); });

View File

@@ -22,16 +22,9 @@ namespace Content.Server.Chemistry.EntitySystems
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SolutionInjectOnCollideComponent, ComponentInit>(HandleInit);
SubscribeLocalEvent<SolutionInjectOnCollideComponent, StartCollideEvent>(HandleInjection); SubscribeLocalEvent<SolutionInjectOnCollideComponent, StartCollideEvent>(HandleInjection);
} }
private void HandleInit(EntityUid uid, SolutionInjectOnCollideComponent component, ComponentInit args)
{
component.Owner
.EnsureComponentWarn<SolutionContainerManagerComponent>($"{nameof(SolutionInjectOnCollideComponent)} requires a SolutionContainerManager on {component.Owner}!");
}
private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, ref StartCollideEvent args) private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, ref StartCollideEvent args)
{ {
var target = args.OtherEntity; var target = args.OtherEntity;

View File

@@ -343,7 +343,7 @@ namespace Content.Server.Ghost.Roles
if (ghostRole.MakeSentient) if (ghostRole.MakeSentient)
MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech); MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
mob.EnsureComponent<MindContainerComponent>(); EnsureComp<MindContainerComponent>(mob);
GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole); GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);

View File

@@ -81,7 +81,7 @@ namespace Content.Server.Tabletop
CloseSessionFor(player, gamer.Tabletop, false); CloseSessionFor(player, gamer.Tabletop, false);
// Set the entity as an absolute GAMER. // Set the entity as an absolute GAMER.
attachedEntity.EnsureComponent<TabletopGamerComponent>().Tabletop = uid; EnsureComp<TabletopGamerComponent>(attachedEntity).Tabletop = uid;
// Create a camera for the gamer to use // Create a camera for the gamer to use
var camera = CreateCamera(tabletop, player); var camera = CreateCamera(tabletop, player);
@@ -139,7 +139,7 @@ namespace Content.Server.Tabletop
var camera = EntityManager.SpawnEntity(null, session.Position.Offset(offset)); var camera = EntityManager.SpawnEntity(null, session.Position.Offset(offset));
// Add an eye component and disable FOV // Add an eye component and disable FOV
var eyeComponent = camera.EnsureComponent<EyeComponent>(); var eyeComponent = EnsureComp<EyeComponent>(camera);
_eye.SetDrawFov(camera, false, eyeComponent); _eye.SetDrawFov(camera, false, eyeComponent);
_eye.SetZoom(camera, tabletop.CameraZoom, eyeComponent); _eye.SetZoom(camera, tabletop.CameraZoom, eyeComponent);

View File

@@ -1,31 +1,17 @@
using Content.Shared.Singularity.EntitySystems;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Singularity.Components namespace Content.Shared.Singularity.Components
{ {
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState] [AutoGenerateComponentState]
[Access(typeof(SharedSingularitySystem))]
public sealed partial class SingularityDistortionComponent : Component public sealed partial class SingularityDistortionComponent : Component
{ {
// TODO: use access and remove this funny stuff [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
[DataField("intensity")] public float Intensity = 31.25f;
private float _intensity = 31.25f;
[DataField("falloffPower")] [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
private float _falloffPower = MathF.Sqrt(2f); public float FalloffPower = MathF.Sqrt(2f);
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float Intensity
{
get => _intensity;
set => this.SetAndDirtyIfChanged(ref _intensity, value);
}
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float FalloffPower
{
get => _falloffPower;
set => this.SetAndDirtyIfChanged(ref _falloffPower, value);
}
} }
} }

View File

@@ -312,6 +312,7 @@ public abstract class SharedSingularitySystem : EntitySystem
comp.FalloffPower = newFalloffPower; comp.FalloffPower = newFalloffPower;
comp.Intensity = newIntensity; comp.Intensity = newIntensity;
Dirty(uid, comp);
} }
/// <summary> /// <summary>