Skip to content

Commit

Permalink
Merge branch 'master' into Chitinid
Browse files Browse the repository at this point in the history
  • Loading branch information
ElusiveCoin authored Jan 19, 2025
2 parents b610ace + ccb9f39 commit 9950be9
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 14 deletions.
137 changes: 137 additions & 0 deletions Content.Client/_Goobstation/Emoting/AnimatedEmotesSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using Robust.Client.Animations;
using Robust.Shared.Animations;
using Robust.Shared.GameStates;
using Robust.Client.GameObjects;
using Content.Shared.Emoting;
using System.Numerics;
using Robust.Shared.Prototypes;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Rotation;

namespace Content.Client.Emoting;

public sealed partial class AnimatedEmotesSystem : SharedAnimatedEmotesSystem
{
[Dependency] private readonly AnimationPlayerSystem _anim = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly IPrototypeManager _prot = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AnimatedEmotesComponent, ComponentHandleState>(OnHandleState);

SubscribeLocalEvent<AnimatedEmotesComponent, AnimationFlipEmoteEvent>(OnFlip);
SubscribeLocalEvent<AnimatedEmotesComponent, AnimationSpinEmoteEvent>(OnSpin);
SubscribeLocalEvent<AnimatedEmotesComponent, AnimationJumpEmoteEvent>(OnJump);
}

public void PlayEmote(EntityUid uid, Animation anim, string animationKey = "emoteAnimKeyId")
{
if (_anim.HasRunningAnimation(uid, animationKey))
return;

_anim.Play(uid, anim, animationKey);
}

private void OnHandleState(EntityUid uid, AnimatedEmotesComponent component, ref ComponentHandleState args)
{
if (args.Current is not AnimatedEmotesComponentState state
|| !_prot.TryIndex<EmotePrototype>(state.Emote, out var emote))
return;

if (emote.Event != null)
RaiseLocalEvent(uid, emote.Event);
}

private void OnFlip(Entity<AnimatedEmotesComponent> ent, ref AnimationFlipEmoteEvent args)
{
var angle = Angle.Zero;

if (TryComp<RotationVisualsComponent>(ent, out var rotation))
{
_appearance.TryGetData<RotationState>(ent, RotationVisuals.RotationState, out var state);

angle = state switch
{
RotationState.Vertical => rotation.VerticalRotation,
RotationState.Horizontal => rotation.HorizontalRotation,
_ => Angle.Zero
};
}

var a = new Animation
{
Length = TimeSpan.FromMilliseconds(500),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Rotation),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(angle, 0f),
new AnimationTrackProperty.KeyFrame(angle + Angle.FromDegrees(180), 0.25f),
new AnimationTrackProperty.KeyFrame(angle + Angle.FromDegrees(360), 0.25f),
}
}
}
};
PlayEmote(ent, a);
}
private void OnSpin(Entity<AnimatedEmotesComponent> ent, ref AnimationSpinEmoteEvent args)
{
var a = new Animation
{
Length = TimeSpan.FromMilliseconds(600),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(TransformComponent),
Property = nameof(TransformComponent.LocalRotation),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), 0f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(90), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(180), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(270), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.Zero, 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(90), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(180), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(270), 0.075f),
new AnimationTrackProperty.KeyFrame(Angle.Zero, 0.075f),
}
}
}
};
PlayEmote(ent, a, "emoteAnimSpin");
}
private void OnJump(Entity<AnimatedEmotesComponent> ent, ref AnimationJumpEmoteEvent args)
{
var a = new Animation
{
Length = TimeSpan.FromMilliseconds(250),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Offset),
InterpolationMode = AnimationInterpolationMode.Cubic,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Vector2.Zero, 0f),
new AnimationTrackProperty.KeyFrame(new Vector2(0, .35f), 0.125f),
new AnimationTrackProperty.KeyFrame(Vector2.Zero, 0.125f),
}
}
}
};
PlayEmote(ent, a);
}
}
9 changes: 9 additions & 0 deletions Content.Server/GameTicking/Presets/GamePresetPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public sealed partial class GamePresetPrototype : IPrototype
[DataField("maxPlayers")]
public int? MaxPlayers;

// Begin Imp
/// <summary>
/// Ensures that this gamemode does not get selected for a number of rounds
/// by something like Secret. This is not considered when the preset is forced.
/// </summary>
[DataField]
public int Cooldown = 0;
// End Imp

[DataField("rules", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public IReadOnlyList<string> Rules { get; private set; } = Array.Empty<string>();

Expand Down
24 changes: 24 additions & 0 deletions Content.Server/GameTicking/Rules/SecretRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Presets;
using Content.Server.GameTicking.Rules.Components;
using Content.Shared._DV.CCVars; // DeltaV
using Content.Shared.GameTicking.Components;
using Content.Shared.Random;
using Content.Shared.CCVar;
Expand All @@ -22,6 +23,11 @@ public sealed class SecretRuleSystem : GameRuleSystem<SecretRuleComponent>
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IComponentFactory _compFact = default!;
[Dependency] private readonly GameTicker _ticker = default!; // begin Imp

// Dictionary that contains the minimum round number for certain preset
// prototypes to be allowed to roll again
private static Dictionary<ProtoId<GamePresetPrototype>, int> _nextRoundAllowed = new(); // end Imp

private string _ruleCompName = default!;

Expand All @@ -46,6 +52,15 @@ protected override void Added(EntityUid uid, SecretRuleComponent component, Game
Log.Info($"Selected {preset.ID} as the secret preset.");
_adminLogger.Add(LogType.EventStarted, $"Selected {preset.ID} as the secret preset.");

if (_configurationManager.GetCVar(DCCVars.EnableBacktoBack) == true) // DeltaV
{
if (preset.Cooldown > 0) // Begin Imp
{
_nextRoundAllowed[preset.ID] = _ticker.RoundId + preset.Cooldown + 1;
Log.Info($"{preset.ID} is now on cooldown until {_nextRoundAllowed[preset.ID]}");
} // End Imp
} // DeltaV

foreach (var rule in preset.Rules)
{
EntityUid ruleEnt;
Expand Down Expand Up @@ -167,6 +182,15 @@ private bool CanPick([NotNullWhen(true)] GamePresetPrototype? selected, int play
return false;
}

if (_configurationManager.GetCVar(DCCVars.EnableBacktoBack) == true) // DeltaV
{
if (_nextRoundAllowed.ContainsKey(selected.ID) && _nextRoundAllowed[selected.ID] > _ticker.RoundId) // Begin Imp
{
Log.Info($"Skipping preset {selected.ID} (Not available until round {_nextRoundAllowed[selected.ID]}");
return false;
} // End Imp
} // DeltaV

return true;
}
}
28 changes: 28 additions & 0 deletions Content.Server/_Goobstation/Emoting/AnimatedEmotesSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Robust.Shared.GameStates;
using Content.Server.Chat.Systems;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Emoting;
using Robust.Shared.Prototypes;

namespace Content.Server.Emoting;

public sealed partial class AnimatedEmotesSystem : SharedAnimatedEmotesSystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AnimatedEmotesComponent, EmoteEvent>(OnEmote);
}

private void OnEmote(EntityUid uid, AnimatedEmotesComponent component, ref EmoteEvent args)
{
PlayEmoteAnimation(uid, component, args.Emote.ID);
}

public void PlayEmoteAnimation(EntityUid uid, AnimatedEmotesComponent component, ProtoId<EmotePrototype> prot)
{
component.Emote = prot;
Dirty(uid, component);
}
}
4 changes: 4 additions & 0 deletions Content.Shared/Chat/Prototypes/EmotePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public sealed partial class EmotePrototype : IPrototype
/// </summary>
[DataField]
public HashSet<string> ChatTriggers = new();

// goob edit - animations
[DataField]
public object? Event = null;
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/_DV/CCVars/DCCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ public sealed class DCCVars
/// </summary>
public static readonly CVarDef<string> DiscordReplyColor =
CVarDef.Create("admin.discord_reply_color", string.Empty, CVar.SERVERONLY);

/// <summary>
/// Whether or not to disable the preset selecting test rule from running. Should be disabled in production. DeltaV specific, attached to Impstation Secret concurrent feature.
/// </summary>
public static readonly CVarDef<bool> EnableBacktoBack =
CVarDef.Create("game.disable_preset_test", false, CVar.SERVERONLY);
}
28 changes: 28 additions & 0 deletions Content.Shared/_Goobstation/Emoting/AnimatedEmotesComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Shared.Chat.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;

namespace Content.Shared.Emoting;

// use as a template
//[Serializable, NetSerializable, DataDefinition] public sealed partial class AnimationNameEmoteEvent : EntityEventArgs { }

[Serializable, NetSerializable, DataDefinition] public sealed partial class AnimationFlipEmoteEvent : EntityEventArgs { }
[Serializable, NetSerializable, DataDefinition] public sealed partial class AnimationSpinEmoteEvent : EntityEventArgs { }
[Serializable, NetSerializable, DataDefinition] public sealed partial class AnimationJumpEmoteEvent : EntityEventArgs { }

[RegisterComponent, NetworkedComponent] public sealed partial class AnimatedEmotesComponent : Component
{
[DataField] public ProtoId<EmotePrototype>? Emote;
}

[Serializable, NetSerializable] public sealed partial class AnimatedEmotesComponentState : ComponentState
{
public ProtoId<EmotePrototype>? Emote;

public AnimatedEmotesComponentState(ProtoId<EmotePrototype>? emote)
{
Emote = emote;
}
}
18 changes: 18 additions & 0 deletions Content.Shared/_Goobstation/Emoting/SharedAnimatedEmotesSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Emoting;

public abstract class SharedAnimatedEmotesSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AnimatedEmotesComponent, ComponentGetState>(OnGetState);
}

private void OnGetState(Entity<AnimatedEmotesComponent> ent, ref ComponentGetState args)
{
args.State = new AnimatedEmotesComponentState(ent.Comp.Emote);
}
}
29 changes: 15 additions & 14 deletions Resources/Changelog/DeltaVChangelog.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
Entries:
- author: Colin-Tel
changes:
- message: Playtime requirements across "newbie jobs" have been adjusted.
type: Tweak
id: 438
time: '2024-07-21T16:39:02.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/1500
- author: Colin-Tel
changes:
- message: Service Workers can now choose green clothes in their loadouts!
type: Add
id: 439
time: '2024-07-21T16:44:24.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/1499
- author: jimmy12or
changes:
- message: Adds Crystalthistle! A plant that produces Quartzite!
Expand Down Expand Up @@ -3858,3 +3844,18 @@
id: 937
time: '2025-01-18T11:56:47.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2762
- author: whateverusername0, AirFryerBuyOneGetOneFree, Darkmajia, hivehum, crocodilecarousel
changes:
- message: 'Added two new animated emotes from Impstation: jump and spin.'
type: Add
id: 938
time: '2025-01-18T23:50:21.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2746
- author: TGRCDev, Lyndomen
changes:
- message: Gamemodes now have cooldowns to prevent back-to-back modes. Modes that
have been voted on are exempt from this.
type: Add
id: 939
time: '2025-01-19T00:33:45.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2744
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/_Goobstation/emotes.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

chat-emote-name-spin = Spin
chat-emote-name-jump = Jump
chat-emote-msg-spin = spins!
chat-emote-msg-jump = jumps!
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Player/guardian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
- type: Tag
tags:
- CannotSuicide
- type: AnimatedEmotes # goob edit - animated emotes

# From the uplink injector
- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- type: MovementSpeedModifier
- type: RequireProjectileTarget
active: False
- type: AnimatedEmotes # goob edit - animated emotes

- type: entity
save: false
Expand Down
27 changes: 27 additions & 0 deletions Resources/Prototypes/_Goobstation/Actions/emotes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- type: emote
id: Spin
name: chat-emote-name-spin
chatMessages: ["chat-emote-msg-spin"]
icon: _Impstation/Interface/Emotes/spin.png #imp
chatTriggers:
- spin
- spins
- spins.
- spins!
event: !type:AnimationSpinEmoteEvent

- type: emote
id: Jump
name: chat-emote-name-jump
chatMessages: ["chat-emote-msg-jump"]
icon: _Impstation/Interface/Emotes/jump.png #imp
chatTriggers:
- jump
- jumps
- jumps.
- jumps!
- bounce
- bounces
- bounces.
- bounces!
event: !type:AnimationJumpEmoteEvent
Loading

0 comments on commit 9950be9

Please sign in to comment.