- add: more interaction shit
This commit is contained in:
102
Content.Shared/_Amour/InteractionPanel/Actions/Animations.cs
Normal file
102
Content.Shared/_Amour/InteractionPanel/Actions/Animations.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._Amour.Animation;
|
||||
using Robust.Shared.Animations;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel.Actions;
|
||||
|
||||
[DataDefinition, Serializable]
|
||||
public sealed partial class RequireAnimation : IInteractionAction
|
||||
{
|
||||
[DataField] public float k0 = 0f;
|
||||
[DataField] public float k1 = 0f;
|
||||
[DataField] public float k2 = 0f;
|
||||
[DataField] public float k3 = 0f;
|
||||
[DataField] public float Length;
|
||||
[DataField] public int Repeat = 1;
|
||||
|
||||
private void AnimateSomeShit(EntityUid uid, EntityUid target, IEntityManager entityManager)
|
||||
{
|
||||
var animationSystem = entityManager.System<SharedAnimationSystem>();
|
||||
|
||||
var rotation = (entityManager.GetComponent<TransformComponent>(target).LocalPosition - entityManager.GetComponent<TransformComponent>(uid).LocalPosition)*0.5f;
|
||||
|
||||
if (Length == 0)
|
||||
{
|
||||
Length = k0 + k1 + k2 + k3;
|
||||
}
|
||||
|
||||
var animation = new Shared._Amour.Animation.Animation()
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(Length*Repeat),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackData()
|
||||
{
|
||||
ComponentType = "Sprite",
|
||||
Property = "Offset",
|
||||
InterpolationMode = AnimationInterpolationMode.Cubic,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = 0; i < Repeat; i++)
|
||||
{
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(Vector2.Zero, k0));
|
||||
animation.AnimationTracks[0].KeyFrames.Add( animationSystem.KeyFrame(rotation, k1));
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(rotation, k2));
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(Vector2.Zero, k3));
|
||||
}
|
||||
|
||||
animationSystem.Play(uid,animation);
|
||||
}
|
||||
|
||||
public void Run(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
AnimateSomeShit(user,target,entityManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DataDefinition, Serializable]
|
||||
public sealed partial class RequireHorizontalAnimation : IInteractionAction
|
||||
{
|
||||
[DataField] public int Repeat = 6;
|
||||
[DataField] public Vector2 Shift = new (0, 0.5f);
|
||||
|
||||
public void Run(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var animationSystem = entityManager.System<SharedAnimationSystem>();
|
||||
|
||||
var rotation = (entityManager.GetComponent<TransformComponent>(target).LocalPosition - entityManager.GetComponent<TransformComponent>(user).LocalPosition)*0.5f;
|
||||
|
||||
var animation = new Shared._Amour.Animation.Animation()
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(0.5*Repeat + 0.25),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackData()
|
||||
{
|
||||
ComponentType = "Sprite",
|
||||
Property = "Offset",
|
||||
InterpolationMode = AnimationInterpolationMode.Cubic,
|
||||
KeyFrames =
|
||||
{
|
||||
animationSystem.KeyFrame(Vector2.Zero,0)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = 0; i < Repeat; i++)
|
||||
{
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(rotation-Shift*0.5f,0.25f));
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(rotation-Shift,0.25f));
|
||||
}
|
||||
|
||||
animation.AnimationTracks[0].KeyFrames.Add(animationSystem.KeyFrame(Vector2.Zero,0.25f));
|
||||
animationSystem.Play(user,animation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared._Amour.InteractionPanel.Actions;
|
||||
|
||||
public interface IInteractionAction
|
||||
{
|
||||
public void Run(Entity<InteractionPanelComponent> user,
|
||||
Entity<InteractionPanelComponent> target, IEntityManager entityManager);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared._Amour.InteractionPanel.Checks;
|
||||
|
||||
public interface IInteractionCheck
|
||||
{
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user,
|
||||
Entity<InteractionPanelComponent> target,IEntityManager entityManager);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Content.Shared._Amour.Crawl;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel.Checks;
|
||||
|
||||
public sealed class InteractSelf : IInteractionCheck
|
||||
@@ -15,3 +17,19 @@ public sealed class CantInteractSelf: IInteractionCheck
|
||||
return user != target;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class IsUserCrawl : IInteractionCheck
|
||||
{
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
return entityManager.HasComponent<CrawlComponent>(user);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class IsTargetCrawl : IInteractionCheck
|
||||
{
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
return entityManager.HasComponent<CrawlComponent>(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using Content.Shared._Amour.Hole;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel;
|
||||
|
||||
public interface IInteractionCheck
|
||||
{
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user,
|
||||
Entity<InteractionPanelComponent> target,IEntityManager entityManager);
|
||||
}
|
||||
|
||||
public sealed class BasicCheck : IInteractionCheck
|
||||
{
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
Logger.Debug("MEWO!!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
15
Content.Shared/_Amour/InteractionPanel/InteractionDoAfter.cs
Normal file
15
Content.Shared/_Amour/InteractionPanel/InteractionDoAfter.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class PanelDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
[DataField] public string Prototype;
|
||||
|
||||
public PanelDoAfterEvent(string prototype)
|
||||
{
|
||||
Prototype = prototype;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel;
|
||||
|
||||
[Prototype("interactionGroup")]
|
||||
public sealed class InteractionGroupPrototype : IPrototype
|
||||
{
|
||||
[IdDataField] public string ID { get; private set; } = default!;
|
||||
[DataField] public Color Color;
|
||||
[DataField] public int Priority;
|
||||
}
|
||||
@@ -15,5 +15,6 @@ public sealed partial class InteractionPanelComponent : Component
|
||||
[ViewVariables] public Entity<InteractionPanelComponent>? CurrentPartner;
|
||||
|
||||
[DataField] public List<ProtoId<InteractionPrototype>> ActionPrototypes = new();
|
||||
[DataField] public ProtoId<InteractionListPrototype> ActionListPrototype;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,16 +15,20 @@ public sealed class InteractionSelectedMessage : EuiMessageBase
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable,NetSerializable]
|
||||
public sealed class InteractionUpdateMessage : EuiMessageBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable,NetSerializable]
|
||||
public sealed class InteractionState: EuiStateBase
|
||||
{
|
||||
public NetEntity Performer { get; }
|
||||
public NetEntity Target { get; }
|
||||
public HashSet<string> AvailableInteractions;
|
||||
public HashSet<InteractionEntry> AvailableInteractions;
|
||||
public byte? Arousal;
|
||||
|
||||
public InteractionState(NetEntity performer, NetEntity target, HashSet<string> availableInteractions, byte? arousal)
|
||||
public InteractionState(NetEntity performer, NetEntity target, HashSet<InteractionEntry> availableInteractions, byte? arousal)
|
||||
{
|
||||
Performer = performer;
|
||||
Target = target;
|
||||
@@ -33,3 +37,15 @@ public sealed class InteractionState: EuiStateBase
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class InteractionEntry
|
||||
{
|
||||
public string Prototype;
|
||||
public bool Enabled;
|
||||
|
||||
public InteractionEntry(string prototype, bool enabled)
|
||||
{
|
||||
Prototype = prototype;
|
||||
Enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Content.Shared.Actions;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel;
|
||||
|
||||
public sealed class InteractionPanelSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Content.Shared._Amour.InteractionPanel.Actions;
|
||||
using Content.Shared._Amour.InteractionPanel.Checks;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -13,12 +15,23 @@ public sealed partial class InteractionPrototype : IPrototype
|
||||
[DataField] public SoundSpecifier? BeginningSound;
|
||||
[DataField] public SoundSpecifier? EndingSound;
|
||||
|
||||
[DataField] public List<string> PreBeginMessages = new();
|
||||
[DataField] public List<string> BeginningMessages = new();
|
||||
[DataField] public List<string> EndingMessages = new();
|
||||
|
||||
[DataField] public List<IInteractionCheck> Checks = new();
|
||||
[DataField] public List<IInteractionAction> BeginningActions = new();
|
||||
[DataField] public List<IInteractionAction> EndingActions = new();
|
||||
|
||||
[DataField] public TimeSpan EndTime = TimeSpan.Zero;
|
||||
[DataField] public TimeSpan Timeout = TimeSpan.FromSeconds(3);
|
||||
[DataField] public TimeSpan BeginningTimeout = TimeSpan.Zero;
|
||||
[DataField] public ProtoId<InteractionGroupPrototype> Group = "Safe";
|
||||
}
|
||||
|
||||
[Prototype("interactionList")]
|
||||
public sealed class InteractionListPrototype : IPrototype
|
||||
{
|
||||
[IdDataField] public string ID { get; private set; } = default!;
|
||||
[DataField] public List<ProtoId<InteractionPrototype>> Prototypes = new List<ProtoId<InteractionPrototype>>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user