Add weightlessness status effect. (#2384)

* Add weightlessness status effect.

* remove system, add new action

* Update Content.Shared/GameObjects/Components/Mobs/SharedWeightlessStatusComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Shared/GameObjects/Components/Mobs/SharedWeightlessStatusComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Shared/GameObjects/Components/Movement/MovementIgnoreGravityComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* fix paul's typo. does not run.

* add client side component

* move logic to eventbus

* remove client/server components and clean up code

* remove useless component, revert human.yml changes.

Co-authored-by: scuffedjays <yetanotherscuffed@gmail.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
F77F
2020-10-28 08:52:39 -05:00
committed by GitHub
parent cec3eca896
commit 9b751fc079
5 changed files with 64 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystemMessages;
using Robust.Shared.GameObjects.Systems;
namespace Content.Shared.GameObjects.EntitySystems
{
public sealed class WeightlessStatusSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WeightlessChangeMessage>(HandleWeightlessChanged);
}
private void HandleWeightlessChanged(WeightlessChangeMessage msg)
{
var ent = msg.Entity;
if (!ent.TryGetComponent(out SharedStatusEffectsComponent status))
{
return;
}
if(msg.Weightless)
{
status.ChangeStatusEffect(StatusEffect.Weightless,"/Textures/Interface/StatusEffects/Weightless/weightless.png",null);
}
else
{
status.RemoveStatusEffect(StatusEffect.Weightless);
}
}
}
}

View File

@@ -68,6 +68,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
Buckled, Buckled,
Piloting, Piloting,
Pulling, Pulling,
Pulled Pulled,
Weightless
} }
} }

View File

@@ -1,8 +1,11 @@
#nullable enable #nullable enable
using System;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Content.Shared.GameObjects.EntitySystemMessages;
namespace Content.Shared.GameObjects.Components.Movement namespace Content.Shared.GameObjects.Components.Movement
{ {
@@ -18,8 +21,10 @@ namespace Content.Shared.GameObjects.Components.Movement
{ {
physicsManager ??= IoCManager.Resolve<IPhysicsManager>(); physicsManager ??= IoCManager.Resolve<IPhysicsManager>();
return !entity.HasComponent<MovementIgnoreGravityComponent>() && var isWeightless = !entity.HasComponent<MovementIgnoreGravityComponent>() &&
physicsManager.IsWeightless(entity.Transform.Coordinates); physicsManager.IsWeightless(entity.Transform.Coordinates);
entity.EntityManager.EventBus.RaiseEvent(EventSource.Local, new WeightlessChangeMessage(entity,isWeightless));
return isWeightless;
} }
} }
} }

View File

@@ -0,0 +1,21 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.EntitySystemMessages
{
[Serializable, NetSerializable]
public sealed class WeightlessChangeMessage : EntitySystemMessage
{
public readonly IEntity Entity;
public readonly bool Weightless;
public WeightlessChangeMessage(IEntity ent, bool isNowWeightless)
{
Entity = ent;
Weightless = isNowWeightless;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B