* Init Commit * windows yelling at me to update commit * working commit, need prediciton and more dehardcoding * Project 0 warnings * Working Commit (Near Final) * ryder got confused commit * I love Merge Conflicts :) * Working commit, no prediction * Forgot the yaml changes * Comments and typos * Apparently while the reduced launch mult of lube was initialized it was never used so I revered back to default * Fixed an incorrect divisor * bit of cleanup * Prediciton fixed, and puddles now affect all entities * FORGOT TO RENAME A VERY IMPORTANT VARIABLE OOPS * Really big I forgor moment * Even bigger I forgor moment * four more merge conflicts to fix four more oopsies * fixed actual divide by zero moment and also im very dumb * Even bigger I forgor moment * four more merge conflicts to fix four more oopsies * fixed actual divide by zero moment and also im very dumb * Fix all test fails * code cleanup * Webedit whitespace * Code cleaup * whitespace webedit * whitespace webedit * whitespace webedit * whitespace removal * Comments and cleanup * Re-Added 20 warnings as per Ork's request * Cleanups * Spacing fix * bugfixes and cleanup * Small bugfix * Actually dirty the slipComp for real * Added Friction field to Reagent Prototype per design discussion * Sliding system is kill
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Standing;
|
|
using Content.Shared.Stunnable;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Shared.Slippery;
|
|
|
|
public sealed class SlidingSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SlidingComponent, StoodEvent>(OnStand);
|
|
SubscribeLocalEvent<SlidingComponent, StartCollideEvent>(OnStartCollide);
|
|
SubscribeLocalEvent<SlidingComponent, EndCollideEvent>(OnEndCollide);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove the component when the entity stands up again.
|
|
/// </summary>
|
|
private void OnStand(EntityUid uid, SlidingComponent component, ref StoodEvent args)
|
|
{
|
|
RemComp<SlidingComponent>(uid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets friction to 0 if colliding with a SuperSlippery Entity.
|
|
/// </summary>
|
|
private void OnStartCollide(EntityUid uid, SlidingComponent component, ref StartCollideEvent args)
|
|
{
|
|
if (!TryComp<SlipperyComponent>(args.OtherEntity, out var slippery) || !slippery.SlipData.SuperSlippery)
|
|
return;
|
|
|
|
component.CollidingEntities.Add(args.OtherEntity);
|
|
Dirty(uid, component);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set friction to normal when ending collision with a SuperSlippery entity.
|
|
/// </summary>
|
|
private void OnEndCollide(EntityUid uid, SlidingComponent component, ref EndCollideEvent args)
|
|
{
|
|
if (!component.CollidingEntities.Remove(args.OtherEntity))
|
|
return;
|
|
|
|
if (component.CollidingEntities.Count == 0)
|
|
RemComp<SlidingComponent>(uid);
|
|
|
|
Dirty(uid, component);
|
|
}
|
|
}
|