The real movement refactor (#9645)

* The real movement refactor

* ref events

* Jetpack cleanup

* a

* Vehicles partially working

* Balance tweaks

* Restore some shitcode

* AAAAAAAA

* Even more prediction

* ECS compstate trying to fix this

* yml

* vehicles kill me

* Don't lock keys

* a

* Fix problem

* Fix sounds

* shuttle inputs

* Shuttle controls

* space brakes

* Keybinds

* Fix merge

* Handle shutdown

* Fix keys

* Bump friction

* fix buckle offset

* Fix relay and friction

* Fix jetpack turning

* contexts amirite
This commit is contained in:
metalgearsloth
2022-07-16 13:51:52 +10:00
committed by GitHub
parent e0b7b48cae
commit b9e876ca92
109 changed files with 1752 additions and 1584 deletions

View File

@@ -10,12 +10,10 @@ namespace Content.Server.Buckle.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedStrapComponent))]
public sealed class StrapComponent : SharedStrapComponent, ISerializationHooks
public sealed class StrapComponent : SharedStrapComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly HashSet<EntityUid> _buckledEntities = new();
/// <summary>
/// The angle in degrees to rotate the player by when they get strapped
/// </summary>
@@ -28,13 +26,6 @@ namespace Content.Server.Buckle.Components
[ViewVariables] [DataField("size")] private int _size = 100;
private int _occupiedSize;
/// <summary>
/// The buckled entity will be offset by this amount from the center of the strap object.
/// If this offset it too big, it will be clamped to <see cref="MaxBuckleDistance"/>
/// </summary>
[DataField("buckleOffset", required: false)]
public Vector2 BuckleOffsetUnclamped = Vector2.Zero;
private bool _enabled = true;
/// <summary>
@@ -51,38 +42,11 @@ namespace Content.Server.Buckle.Components
}
}
/// <summary>
/// The distance above which a buckled entity will be automatically unbuckled.
/// Don't change it unless you really have to
/// </summary>
[DataField("maxBuckleDistance", required: false)]
public float MaxBuckleDistance = 0.1f;
/// <summary>
/// You can specify the offset the entity will have after unbuckling.
/// </summary>
[DataField("unbuckleOffset", required: false)]
public Vector2 UnbuckleOffset = Vector2.Zero;
/// <summary>
/// Gets and clamps the buckle offset to MaxBuckleDistance
/// </summary>
public Vector2 BuckleOffset => Vector2.Clamp(
BuckleOffsetUnclamped,
Vector2.One * -MaxBuckleDistance,
Vector2.One * MaxBuckleDistance);
/// <summary>
/// The entity that is currently buckled here, synced from <see cref="BuckleComponent.BuckledTo"/>
/// </summary>
public IReadOnlyCollection<EntityUid> BuckledEntities => _buckledEntities;
/// <summary>
/// The change in position to the strapped mob
/// </summary>
[DataField("position")]
public StrapPosition Position { get; } = StrapPosition.None;
/// <summary>
/// The sound to be played when a mob is buckled
/// </summary>
@@ -138,7 +102,7 @@ namespace Content.Server.Buckle.Components
return false;
}
if (!_buckledEntities.Add(buckle.Owner))
if (!BuckledEntities.Add(buckle.Owner))
{
return false;
}
@@ -154,6 +118,7 @@ namespace Content.Server.Buckle.Components
appearance.SetData("StrapState", true);
}
Dirty();
return true;
}
@@ -164,7 +129,7 @@ namespace Content.Server.Buckle.Components
/// <param name="buckle">The component to remove</param>
public void Remove(BuckleComponent buckle)
{
if (_buckledEntities.Remove(buckle.Owner))
if (BuckledEntities.Remove(buckle.Owner))
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent>(Owner, out var appearance))
{
@@ -172,6 +137,7 @@ namespace Content.Server.Buckle.Components
}
_occupiedSize -= buckle.Size;
Dirty();
}
}
@@ -186,7 +152,7 @@ namespace Content.Server.Buckle.Components
{
var entManager = IoCManager.Resolve<IEntityManager>();
foreach (var entity in _buckledEntities.ToArray())
foreach (var entity in BuckledEntities.ToArray())
{
if (entManager.TryGetComponent<BuckleComponent>(entity, out var buckle))
{
@@ -194,13 +160,9 @@ namespace Content.Server.Buckle.Components
}
}
_buckledEntities.Clear();
BuckledEntities.Clear();
_occupiedSize = 0;
}
public override ComponentState GetComponentState()
{
return new StrapComponentState(Position);
Dirty();
}
public override bool DragDropOn(DragDropEvent eventArgs)