From c25b103316b54596683cce52709cee9bce5198c5 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 27 Jun 2021 15:57:02 +1000 Subject: [PATCH] Gravity fixes (#4231) git was being dumb so I just made a diff pr --- .../Tests/Gravity/WeightlessStatusTests.cs | 1 + Content.IntegrationTests/Tests/GravityGridTest.cs | 4 ++-- Content.Server/Gravity/EntitySystems/GravitySystem.cs | 5 +++++ Content.Server/Gravity/EntitySystems/WeightlessSystem.cs | 4 ++-- Content.Shared/Gravity/SharedGravitySystem.cs | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs index 8557d4c21b..14b0a87871 100644 --- a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs +++ b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs @@ -4,6 +4,7 @@ using Content.Server.Gravity.EntitySystems; using Content.Shared.Acts; using Content.Shared.Alert; using Content.Shared.Coordinates; +using Content.Shared.Gravity; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; diff --git a/Content.IntegrationTests/Tests/GravityGridTest.cs b/Content.IntegrationTests/Tests/GravityGridTest.cs index 6e1d3bc859..078d69762a 100644 --- a/Content.IntegrationTests/Tests/GravityGridTest.cs +++ b/Content.IntegrationTests/Tests/GravityGridTest.cs @@ -66,8 +66,8 @@ namespace Content.IntegrationTests.Tests var grid1Entity = entityMan.GetEntity(grid1.GridEntityId); var grid2Entity = entityMan.GetEntity(grid2.GridEntityId); - Assert.That(!grid1Entity.HasComponent()); - Assert.That(grid2Entity.HasComponent()); + Assert.That(!grid1Entity.GetComponent().Enabled); + Assert.That(grid2Entity.GetComponent().Enabled); }); await server.WaitIdleAsync(); diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index 9fbb1776ef..3141128599 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -56,17 +56,22 @@ namespace Content.Server.Gravity.EntitySystems { // Incase there's already a generator on the grid we'll just set it now. var gridId = component.Owner.Transform.GridID; + GravityChangedMessage message; foreach (var generator in ComponentManager.EntityQuery(true)) { if (generator.Owner.Transform.GridID == gridId && generator.Status == GravityGeneratorStatus.On) { component.Enabled = true; + message = new GravityChangedMessage(gridId, true); + RaiseLocalEvent(message); return; } } component.Enabled = false; + message = new GravityChangedMessage(gridId, false); + RaiseLocalEvent(message); } public override void Update(float frameTime) diff --git a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs index f1c1861175..54bd008b42 100644 --- a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs +++ b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Server.Alert; using Content.Shared.Alert; using Content.Shared.GameTicking; @@ -41,7 +41,7 @@ namespace Content.Server.Gravity.EntitySystems if (_mapManager.TryGetGrid(status.Owner.Transform.GridID, out var grid)) { var gridEntity = EntityManager.GetEntity(grid.GridEntityId); - if (gridEntity.HasComponent()) + if (gridEntity.GetComponent().Enabled) { RemoveWeightless(status); } diff --git a/Content.Shared/Gravity/SharedGravitySystem.cs b/Content.Shared/Gravity/SharedGravitySystem.cs index 61a5d4870e..4601e6bbac 100644 --- a/Content.Shared/Gravity/SharedGravitySystem.cs +++ b/Content.Shared/Gravity/SharedGravitySystem.cs @@ -7,10 +7,10 @@ namespace Content.Shared.Gravity public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(HandleGridInitialize); + SubscribeLocalEvent(HandleGridInitialize); } - private void HandleGridInitialize(GridInitializedEvent ev) + private void HandleGridInitialize(GridInitializeEvent ev) { var gridEnt = EntityManager.GetEntity(ev.EntityUid); gridEnt.EnsureComponent();