Merge branch 'master' into replace-sounds-with-sound-specifier
# Conflicts: # Content.Server/Actions/Actions/DisarmAction.cs # Content.Server/Actions/Actions/ScreamAction.cs # Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs # Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs # Content.Server/Explosion/Components/FlashExplosiveComponent.cs # Content.Server/Physics/Controllers/MoverController.cs # Content.Server/Portal/Components/PortalComponent.cs # Content.Server/Portal/Components/TeleporterComponent.cs # Content.Server/Projectiles/Components/ProjectileComponent.cs # Content.Server/Singularity/Components/EmitterComponent.cs # Content.Server/Sound/EmitSoundSystem.cs # Content.Server/Stunnable/Components/StunbatonComponent.cs # Content.Server/Tools/Components/MultitoolComponent.cs # Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs # Content.Shared/Gravity/GravityComponent.cs # Content.Shared/Light/Component/SharedExpendableLightComponent.cs # Content.Shared/Maps/ContentTileDefinition.cs # Content.Shared/Slippery/SlipperyComponent.cs # Content.Shared/Standing/StandingStateComponent.cs # Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
This commit is contained in:
@@ -1,22 +1,10 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.EffectBlocker;
|
||||
using Content.Shared.Module;
|
||||
using Content.Shared.NetIDs;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Stunnable;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -25,12 +13,10 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Shared.Slippery
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class SlipperyComponent : Component, IStartCollide
|
||||
[NetworkedComponent()]
|
||||
public sealed class SlipperyComponent : Component
|
||||
{
|
||||
[Dependency] private IModuleManager _moduleManager = default!;
|
||||
|
||||
public sealed override string Name => "Slippery";
|
||||
public override uint? NetID => ContentNetIDs.SLIP;
|
||||
public override string Name => "Slippery";
|
||||
|
||||
private float _paralyzeTime = 3f;
|
||||
private float _intersectPercentage = 0.3f;
|
||||
@@ -42,12 +28,12 @@ namespace Content.Shared.Slippery
|
||||
/// <summary>
|
||||
/// List of entities that are currently colliding with the entity.
|
||||
/// </summary>
|
||||
private readonly HashSet<EntityUid> _colliding = new();
|
||||
public readonly HashSet<EntityUid> Colliding = new();
|
||||
|
||||
/// <summary>
|
||||
/// The list of entities that have been slipped by this component, which shouldn't be slipped again.
|
||||
/// </summary>
|
||||
private readonly HashSet<EntityUid> _slipped = new();
|
||||
public readonly HashSet<EntityUid> Slipped = new();
|
||||
|
||||
/// <summary>
|
||||
/// Path to the sound to be played when a mob slips.
|
||||
@@ -152,88 +138,9 @@ namespace Content.Shared.Slippery
|
||||
}
|
||||
}
|
||||
|
||||
private bool TrySlip(IPhysBody ourBody, IPhysBody otherBody)
|
||||
{
|
||||
if (!Slippery
|
||||
|| Owner.IsInContainer()
|
||||
|| _slipped.Contains(otherBody.Owner.Uid)
|
||||
|| !otherBody.Owner.TryGetComponent(out SharedStunnableComponent? stun))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (otherBody.LinearVelocity.Length < RequiredSlipSpeed || stun.KnockedDown)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var percentage = otherBody.GetWorldAABB().IntersectPercentage(ourBody.GetWorldAABB());
|
||||
|
||||
if (percentage < IntersectPercentage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EffectBlockerSystem.CanSlip(otherBody.Owner))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
otherBody.LinearVelocity *= LaunchForwardsMultiplier;
|
||||
|
||||
stun.Paralyze(5);
|
||||
_slipped.Add(otherBody.Owner.Uid);
|
||||
Dirty();
|
||||
|
||||
if (SlipSound.TryGetSound(out var slipSound) && _moduleManager.IsServerModule)
|
||||
{
|
||||
SoundSystem.Play(Filter.Broadcast(), slipSound, Owner, AudioHelpers.WithVariation(0.2f));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IStartCollide.CollideWith(Fixture _, Fixture otherFixture, in Manifold manifold)
|
||||
{
|
||||
_colliding.Add(otherFixture.Body.Owner.Uid);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!Slippery)
|
||||
return;
|
||||
|
||||
var physics = Owner.GetComponent<IPhysBody>();
|
||||
|
||||
foreach (var uid in _colliding.ToArray())
|
||||
{
|
||||
if (!uid.IsValid() || !Owner.EntityManager.EntityExists(uid))
|
||||
{
|
||||
_colliding.Remove(uid);
|
||||
_slipped.Remove(uid);
|
||||
Dirty();
|
||||
continue;
|
||||
}
|
||||
|
||||
var entity = Owner.EntityManager.GetEntity(uid);
|
||||
var otherPhysics = entity.GetComponent<IPhysBody>();
|
||||
|
||||
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
|
||||
{
|
||||
_colliding.Remove(uid);
|
||||
_slipped.Remove(uid);
|
||||
Dirty();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_slipped.Contains(uid))
|
||||
TrySlip(physics, otherPhysics);
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new SlipperyComponentState(ParalyzeTime, IntersectPercentage, RequiredSlipSpeed, LaunchForwardsMultiplier, Slippery, SlipSound.GetSound(), _slipped.ToArray());
|
||||
return new SlipperyComponentState(ParalyzeTime, IntersectPercentage, RequiredSlipSpeed, LaunchForwardsMultiplier, Slippery, SlipSound.GetSound(), Slipped.ToArray());
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
@@ -246,11 +153,11 @@ namespace Content.Shared.Slippery
|
||||
_requiredSlipSpeed = state.RequiredSlipSpeed;
|
||||
_launchForwardsMultiplier = state.LaunchForwardsMultiplier;
|
||||
_slipSound = new SoundPathSpecifier(state.SlipSound);
|
||||
_slipped.Clear();
|
||||
Slipped.Clear();
|
||||
|
||||
foreach (var slipped in state.Slipped)
|
||||
{
|
||||
_slipped.Add(slipped);
|
||||
Slipped.Add(slipped);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +173,7 @@ namespace Content.Shared.Slippery
|
||||
public string SlipSound { get; }
|
||||
public readonly EntityUid[] Slipped;
|
||||
|
||||
public SlipperyComponentState(float paralyzeTime, float intersectPercentage, float requiredSlipSpeed, float launchForwardsMultiplier, bool slippery, string slipSound, EntityUid[] slipped) : base(ContentNetIDs.SLIP)
|
||||
public SlipperyComponentState(float paralyzeTime, float intersectPercentage, float requiredSlipSpeed, float launchForwardsMultiplier, bool slippery, string slipSound, EntityUid[] slipped)
|
||||
{
|
||||
ParalyzeTime = paralyzeTime;
|
||||
IntersectPercentage = intersectPercentage;
|
||||
|
||||
Reference in New Issue
Block a user