* Fixed Rack/Shelf * Fixes bookshelf, bed * Placeable for beds for bedsheets * Bunch of Physics changes, ask metalgearsloth about em' * More modifications * More * Other stuff * Organizes entities yaml a little bit * Something new * Fixed, happy with the state of this rn * A * A * Ye * E * Done for now... * Applied Reviws * Changes * Fix the robust commit * Fixes tests? * E Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
112 lines
3.2 KiB
C#
112 lines
3.2 KiB
C#
#nullable enable
|
|
using System;
|
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
|
using Content.Shared.Physics;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Shared.GameObjects.Components.Movement
|
|
{
|
|
public abstract class SharedClimbingComponent : Component, IActionBlocker
|
|
{
|
|
public sealed override string Name => "Climbing";
|
|
public sealed override uint? NetID => ContentNetIDs.CLIMBING;
|
|
|
|
protected bool IsOnClimbableThisFrame
|
|
{
|
|
get
|
|
{
|
|
if (Body == null) return false;
|
|
|
|
foreach (var entity in Body.GetBodiesIntersecting())
|
|
{
|
|
if ((entity.CollisionLayer & (int) CollisionGroup.SmallImpassable) != 0) return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
|
|
|
|
[ViewVariables]
|
|
protected virtual bool OwnerIsTransitioning
|
|
{
|
|
get => _ownerIsTransitioning;
|
|
set
|
|
{
|
|
if (_ownerIsTransitioning == value) return;
|
|
_ownerIsTransitioning = value;
|
|
if (Body == null) return;
|
|
if (value)
|
|
{
|
|
Body.BodyType = BodyType.Dynamic;
|
|
}
|
|
else
|
|
{
|
|
Body.BodyType = BodyType.KinematicController;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _ownerIsTransitioning = false;
|
|
|
|
[ComponentDependency] protected PhysicsComponent? Body;
|
|
|
|
protected TimeSpan StartClimbTime = TimeSpan.Zero;
|
|
|
|
/// <summary>
|
|
/// We'll launch the mob onto the table and give them at least this amount of time to be on it.
|
|
/// </summary>
|
|
protected const float BufferTime = 0.3f;
|
|
|
|
public virtual bool IsClimbing
|
|
{
|
|
get => _isClimbing;
|
|
set
|
|
{
|
|
if (_isClimbing == value) return;
|
|
_isClimbing = value;
|
|
|
|
ToggleSmallPassable(value);
|
|
}
|
|
}
|
|
|
|
protected bool _isClimbing;
|
|
|
|
// TODO: Layers need a re-work
|
|
private void ToggleSmallPassable(bool value)
|
|
{
|
|
// Hope the mob has one fixture
|
|
if (Body == null || Body.Deleted) return;
|
|
|
|
foreach (var fixture in Body.Fixtures)
|
|
{
|
|
if (value)
|
|
{
|
|
fixture.CollisionMask &= ~(int) CollisionGroup.SmallImpassable;
|
|
}
|
|
else
|
|
{
|
|
fixture.CollisionMask |= (int) CollisionGroup.SmallImpassable;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
protected sealed class ClimbModeComponentState : ComponentState
|
|
{
|
|
public ClimbModeComponentState(bool climbing, bool isTransitioning) : base(ContentNetIDs.CLIMBING)
|
|
{
|
|
Climbing = climbing;
|
|
IsTransitioning = isTransitioning;
|
|
}
|
|
|
|
public bool Climbing { get; }
|
|
public bool IsTransitioning { get; }
|
|
}
|
|
}
|
|
}
|