Fix weightlessness status effect appearing only after something checks if an entity is weightless (#2434)

* Revert "Add weightlessness status effect. (#2384)"

This reverts commit 9b751fc079.

* Bring back the icon and status

* Make weightless status track gravity and parent
This commit is contained in:
DrSmugleaf
2020-10-30 01:07:51 +01:00
committed by GitHub
parent bc4eab53df
commit ac3e9bc566
7 changed files with 168 additions and 69 deletions

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Gravity;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Gravity;
using Content.Shared.GameObjects.EntitySystemMessages.Gravity;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player;
@@ -41,7 +42,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
generator.UpdateState();
}
if (generator.Status == GravityGeneratorStatus.On)
{
gridsWithGravity.Add(generator.Owner.Transform.GridID);
@@ -52,12 +53,11 @@ namespace Content.Server.GameObjects.EntitySystems
{
if (grid.HasGravity && !gridsWithGravity.Contains(grid.Index))
{
grid.HasGravity = false;
ScheduleGridToShake(grid.Index, ShakeTimes);
} else if (!grid.HasGravity && gridsWithGravity.Contains(grid.Index))
DisableGravity(grid);
}
else if (!grid.HasGravity && gridsWithGravity.Contains(grid.Index))
{
grid.HasGravity = true;
ScheduleGridToShake(grid.Index, ShakeTimes);
EnableGravity(grid);
}
}
@@ -68,6 +68,26 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
private void EnableGravity(IMapGrid grid)
{
grid.HasGravity = true;
ScheduleGridToShake(grid.Index, ShakeTimes);
var message = new GravityChangedMessage(grid);
RaiseLocalEvent(message);
}
private void DisableGravity(IMapGrid grid)
{
grid.HasGravity = false;
ScheduleGridToShake(grid.Index, ShakeTimes);
var message = new GravityChangedMessage(grid);
RaiseLocalEvent(message);
}
private void ScheduleGridToShake(GridId gridId, uint shakeTimes)
{
if (!_gridsToShake.Keys.Contains(gridId))