Re-organize all projects (#4166)
This commit is contained in:
53
Content.Client/Buckle/BuckleComponent.cs
Normal file
53
Content.Client/Buckle/BuckleComponent.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBuckleComponent))]
|
||||
public class BuckleComponent : SharedBuckleComponent
|
||||
{
|
||||
private bool _buckled;
|
||||
private int? _originalDrawDepth;
|
||||
|
||||
public override bool Buckled => _buckled;
|
||||
|
||||
public override bool TryBuckle(IEntity? user, IEntity to)
|
||||
{
|
||||
// TODO: Prediction
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not BuckleComponentState buckle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_buckled = buckle.Buckled;
|
||||
LastEntityBuckledTo = buckle.LastEntityBuckledTo;
|
||||
DontCollide = buckle.DontCollide;
|
||||
|
||||
if (!Owner.TryGetComponent(out SpriteComponent? ownerSprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_buckled && buckle.DrawDepth.HasValue)
|
||||
{
|
||||
_originalDrawDepth ??= ownerSprite.DrawDepth;
|
||||
ownerSprite.DrawDepth = buckle.DrawDepth.Value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_originalDrawDepth.HasValue && !buckle.DrawDepth.HasValue)
|
||||
{
|
||||
ownerSprite.DrawDepth = _originalDrawDepth.Value;
|
||||
_originalDrawDepth = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Content.Client/Buckle/BuckleSystem.cs
Normal file
9
Content.Client/Buckle/BuckleSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.Buckle;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
65
Content.Client/Buckle/BuckleVisualizer.cs
Normal file
65
Content.Client/Buckle/BuckleVisualizer.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class BuckleVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
if (!component.TryGetData<bool>(BuckleVisuals.Buckled, out var buckled) ||
|
||||
!buckled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.TryGetData<int>(StrapVisuals.RotationAngle, out var angle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetRotation(component, Angle.FromDegrees(angle));
|
||||
}
|
||||
|
||||
private void SetRotation(AppearanceComponent component, Angle rotation)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
|
||||
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation))
|
||||
{
|
||||
sprite.Rotation = rotation;
|
||||
return;
|
||||
}
|
||||
|
||||
if (animation.HasRunningAnimation("rotate"))
|
||||
{
|
||||
animation.Stop("rotate");
|
||||
}
|
||||
|
||||
animation.Play(new Animation
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(0.125),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackComponentProperty
|
||||
{
|
||||
ComponentType = typeof(ISpriteComponent),
|
||||
Property = nameof(ISpriteComponent.Rotation),
|
||||
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(sprite.Rotation, 0),
|
||||
new AnimationTrackProperty.KeyFrame(rotation, 0.125f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "rotate");
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Content.Client/Buckle/Strap/StrapComponent.cs
Normal file
16
Content.Client/Buckle/Strap/StrapComponent.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.DragDrop;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Buckle.Strap
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedStrapComponent))]
|
||||
public class StrapComponent : SharedStrapComponent
|
||||
{
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user