* First pass * Fix access and rename banananium to bananium * Fix captialization of CookTimeInfoLabel * Fix InteractUsing calls * Remove unused [Dependency] * Replace obsolete references to Anchored with BodyType * Assign default value to shoving someone in disposals * Fix naming * Replace Initialize TryGetComponents with EnsureComponent * Rework AnchorableComponent * Fix singularity component * Replace obsolete usages of Angle.South * Fix efcore warning * Fix container tests * Fix DebugPressurePump invalid PressurePump yaml * Fix getting pathfinding region of grid 0 * Fix atmos plaque missing layer and add info message when it happens * Fix AiSteeringSystem steering in an invalid grid in entity test * Make content able to choose which log level leads to test failures * Revert container test fix for Acruid * Fix sprite, pipe and saving errors Make EntityTest print all errors instead of stopping on the first * Reorder singularity visualizer * Disable pvs for container occlusion adn simple predict reconcile, they use entities other than map ones Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
126 lines
4.0 KiB
C#
126 lines
4.0 KiB
C#
#nullable enable
|
|
using System;
|
|
using Content.Shared.GameObjects.Components.Body;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Players;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Shared.GameObjects.Components.Movement
|
|
{
|
|
/// <summary>
|
|
/// The basic player mover with footsteps and grabbing
|
|
/// </summary>
|
|
[RegisterComponent]
|
|
[ComponentReference(typeof(IMobMoverComponent))]
|
|
public class SharedPlayerMobMoverComponent : Component, IMobMoverComponent
|
|
{
|
|
public override string Name => "PlayerMobMover";
|
|
public override uint? NetID => ContentNetIDs.PLAYER_MOB_MOVER;
|
|
|
|
private float _stepSoundDistance;
|
|
[DataField("grabRange")]
|
|
private float _grabRange = IMobMoverComponent.GrabRangeDefault;
|
|
[DataField("pushStrength")]
|
|
private float _pushStrength = IMobMoverComponent.PushStrengthDefault;
|
|
|
|
[DataField("weightlessStrength")]
|
|
private float _weightlessStrength = IMobMoverComponent.WeightlessStrengthDefault;
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public EntityCoordinates LastPosition { get; set; }
|
|
|
|
/// <summary>
|
|
/// Used to keep track of how far we have moved before playing a step sound
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float StepSoundDistance
|
|
{
|
|
get => _stepSoundDistance;
|
|
set
|
|
{
|
|
if (MathHelper.CloseTo(_stepSoundDistance, value)) return;
|
|
_stepSoundDistance = value;
|
|
}
|
|
}
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float GrabRange
|
|
{
|
|
get => _grabRange;
|
|
set
|
|
{
|
|
if (MathHelper.CloseTo(_grabRange, value)) return;
|
|
_grabRange = value;
|
|
Dirty();
|
|
}
|
|
}
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float PushStrength
|
|
{
|
|
get => _pushStrength;
|
|
set
|
|
{
|
|
if (MathHelper.CloseTo(_pushStrength, value)) return;
|
|
_pushStrength = value;
|
|
Dirty();
|
|
}
|
|
}
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float WeightlessStrength
|
|
{
|
|
get => _weightlessStrength;
|
|
set
|
|
{
|
|
if (MathHelper.CloseTo(_weightlessStrength, value)) return;
|
|
_weightlessStrength = value;
|
|
Dirty();
|
|
}
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
if (!Owner.HasComponent<IMoverComponent>())
|
|
{
|
|
Owner.EnsureComponentWarn<SharedPlayerInputMoverComponent>();
|
|
}
|
|
}
|
|
|
|
public override ComponentState GetComponentState(ICommonSession session)
|
|
{
|
|
return new PlayerMobMoverComponentState(_grabRange, _pushStrength, _weightlessStrength);
|
|
}
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
{
|
|
base.HandleComponentState(curState, nextState);
|
|
if (curState is not PlayerMobMoverComponentState playerMoverState) return;
|
|
GrabRange = playerMoverState.GrabRange;
|
|
PushStrength = playerMoverState.PushStrength;
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
private sealed class PlayerMobMoverComponentState : ComponentState
|
|
{
|
|
public float GrabRange;
|
|
public float PushStrength;
|
|
public float WeightlessStrength;
|
|
|
|
public PlayerMobMoverComponentState(float grabRange, float pushStrength, float weightlessStrength) : base(ContentNetIDs.PLAYER_MOB_MOVER)
|
|
{
|
|
GrabRange = grabRange;
|
|
PushStrength = pushStrength;
|
|
WeightlessStrength = weightlessStrength;
|
|
}
|
|
}
|
|
}
|
|
}
|