Slipify.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.EntityEffects;
  2. using Content.Shared.Physics;
  3. using Content.Shared.Slippery;
  4. using Content.Shared.StepTrigger.Components;
  5. using Robust.Shared.Physics;
  6. using Robust.Shared.Physics.Components;
  7. using Robust.Shared.Physics.Systems;
  8. using Robust.Shared.Prototypes;
  9. namespace Content.Server.EntityEffects.Effects;
  10. /// <summary>
  11. /// Makes a mob slippery.
  12. /// </summary>
  13. public sealed partial class Slipify : EntityEffect
  14. {
  15. public override void Effect(EntityEffectBaseArgs args)
  16. {
  17. var fixtureSystem = args.EntityManager.System<FixtureSystem>();
  18. var colWakeSystem = args.EntityManager.System<CollisionWakeSystem>();
  19. var slippery = args.EntityManager.EnsureComponent<SlipperyComponent>(args.TargetEntity);
  20. args.EntityManager.Dirty(args.TargetEntity, slippery);
  21. args.EntityManager.EnsureComponent<StepTriggerComponent>(args.TargetEntity);
  22. // Need a fixture with a slip layer in order to actually do the slipping
  23. var fixtures = args.EntityManager.EnsureComponent<FixturesComponent>(args.TargetEntity);
  24. var body = args.EntityManager.EnsureComponent<PhysicsComponent>(args.TargetEntity);
  25. var shape = fixtures.Fixtures["fix1"].Shape;
  26. fixtureSystem.TryCreateFixture(args.TargetEntity, shape, "slips", 1, false, (int)CollisionGroup.SlipLayer, manager: fixtures, body: body);
  27. // Need to disable collision wake so that mobs can collide with and slip on it
  28. var collisionWake = args.EntityManager.EnsureComponent<CollisionWakeComponent>(args.TargetEntity);
  29. colWakeSystem.SetEnabled(args.TargetEntity, false, collisionWake);
  30. }
  31. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  32. {
  33. throw new NotImplementedException();
  34. }
  35. }