From 2978834228469a6e94bac887b6e1751dda5b849f Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:31:21 +0000 Subject: [PATCH] Esword stuff (#329) * - fix: Fix black RGB. * - add: Toy sword update. * - add: FlipOnHitSystem. * - tweak: Price reduction. --- .../Light/RgbLightControllerSystem.cs | 2 + .../_White/Animations/EmoteAnimationSystem.cs | 2 +- .../_White/Animations/FlipOnHitSystem.cs | 91 +++++++++++++++++++ .../_White/Animations/FlippingComponent.cs | 6 ++ .../_White/Animations/FlipOnHitComponent.cs | 8 ++ .../prototypes/entities/objects/fun/toys.ftl | 2 + .../Prototypes/Catalog/uplink_catalog.yml | 2 +- .../Prototypes/Entities/Objects/Fun/toys.yml | 59 +++++++++++- .../Objects/Weapons/Melee/e_sword.yml | 3 +- .../_White/Recipes/hidden_crafts.yml | 12 +++ Resources/Prototypes/_White/tags.yml | 3 + 11 files changed, 181 insertions(+), 9 deletions(-) create mode 100644 Content.Client/_White/Animations/FlipOnHitSystem.cs create mode 100644 Content.Client/_White/Animations/FlippingComponent.cs create mode 100644 Content.Shared/_White/Animations/FlipOnHitComponent.cs diff --git a/Content.Client/Light/RgbLightControllerSystem.cs b/Content.Client/Light/RgbLightControllerSystem.cs index 7d55bcebf1..a1f5554fa7 100644 --- a/Content.Client/Light/RgbLightControllerSystem.cs +++ b/Content.Client/Light/RgbLightControllerSystem.cs @@ -207,6 +207,8 @@ namespace Content.Client.Light public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, Entity rgb) { + offset = TimeSpan.Zero; // WD EDIT, Fix black RGB + return Color.FromHsv(new Vector4( (float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.Comp.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1), 1.0f, diff --git a/Content.Client/_White/Animations/EmoteAnimationSystem.cs b/Content.Client/_White/Animations/EmoteAnimationSystem.cs index 217263e0b0..053b1a8f57 100644 --- a/Content.Client/_White/Animations/EmoteAnimationSystem.cs +++ b/Content.Client/_White/Animations/EmoteAnimationSystem.cs @@ -14,7 +14,7 @@ public sealed class EmoteAnimationSystem : EntitySystem private readonly Dictionary> _emoteList = new(); - private const string AnimationKey = "emoteAnimationKeyId"; + public const string AnimationKey = "emoteAnimationKeyId"; private const string AnimationKeyTurn = "emoteAnimationKeyId_rotate"; //OnVerbsResponse?.Invoke(msg); diff --git a/Content.Client/_White/Animations/FlipOnHitSystem.cs b/Content.Client/_White/Animations/FlipOnHitSystem.cs new file mode 100644 index 0000000000..68af1b8963 --- /dev/null +++ b/Content.Client/_White/Animations/FlipOnHitSystem.cs @@ -0,0 +1,91 @@ +using Content.Shared._White.Animations; +using Content.Shared.Item.ItemToggle.Components; +using Content.Shared.Weapons.Melee.Events; +using Robust.Client.Animations; +using Robust.Client.GameObjects; +using Robust.Shared.Animations; +using Robust.Shared.Timing; + +namespace Content.Client._White.Animations; + +public sealed class FlipOnHitSystem : EntitySystem +{ + [Dependency] private readonly AnimationPlayerSystem _animationSystem = default!; + [Dependency] private readonly IGameTiming _timing = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnHit); + SubscribeLocalEvent(OnAnimationComplete); + } + + private void OnAnimationComplete(Entity ent, ref AnimationCompletedEvent args) + { + if (args.Key != EmoteAnimationSystem.AnimationKey) + return; + + PlayAnimation(ent); + } + + private void OnHit(Entity ent, ref MeleeHitEvent args) + { + if (!_timing.IsFirstTimePredicted) + return; + + if (args.HitEntities.Count == 0) + return; + + if (TryComp(ent, out ItemToggleComponent? itemToggle) && !itemToggle.Activated) + return; + + if (_animationSystem.HasRunningAnimation(args.User, EmoteAnimationSystem.AnimationKey)) + { + EnsureComp(args.User); + return; + } + + PlayAnimation(args.User); + } + + private void PlayAnimation(EntityUid user) + { + RemComp(user); + + var baseAngle = Angle.Zero; + if (EntityManager.TryGetComponent(user, out SpriteComponent? sprite)) + baseAngle = sprite.Rotation; + + var degrees = baseAngle.Degrees; + + var animation = new Animation + { + Length = TimeSpan.FromMilliseconds(1600), + AnimationTracks = + { + new AnimationTrackComponentProperty + { + ComponentType = typeof(SpriteComponent), + Property = nameof(SpriteComponent.Rotation), + InterpolationMode = AnimationInterpolationMode.Linear, + KeyFrames = + { + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees - 10), 0f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 180), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 360), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 540), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 720), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 900), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 1080), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 1260), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees + 1440), 0.2f), + new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(degrees), 0f) + } + } + } + }; + + _animationSystem.Play(user, animation, EmoteAnimationSystem.AnimationKey); + } +} diff --git a/Content.Client/_White/Animations/FlippingComponent.cs b/Content.Client/_White/Animations/FlippingComponent.cs new file mode 100644 index 0000000000..0991724946 --- /dev/null +++ b/Content.Client/_White/Animations/FlippingComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Client._White.Animations; + +[RegisterComponent] +public sealed partial class FlippingComponent : Component +{ +} diff --git a/Content.Shared/_White/Animations/FlipOnHitComponent.cs b/Content.Shared/_White/Animations/FlipOnHitComponent.cs new file mode 100644 index 0000000000..93a71a79f3 --- /dev/null +++ b/Content.Shared/_White/Animations/FlipOnHitComponent.cs @@ -0,0 +1,8 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared._White.Animations; + +[RegisterComponent, NetworkedComponent] +public sealed partial class FlipOnHitComponent : Component +{ +} diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/fun/toys.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/fun/toys.ftl index a5eb9fc1a5..91b4b4f8d4 100644 --- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/fun/toys.ftl +++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/fun/toys.ftl @@ -150,6 +150,8 @@ ent-PonderingOrb = шар размышлений .suffix = { "" } ent-ToySword = игрушечный меч .desc = Новый пластиковый меч от Sandy-Cat! Имеет реалистичный звук и насыщенный цвет! Почти как настоящий! +ent-ToySwordDouble = двойной игрушечный меч + .desc = Новый пластиковый меч от Sandy-Cat! Имеет реалистичный звук и насыщенный цвет! Почти как настоящий! .suffix = { "" } ent-ToyAmongPequeno = маленький амонг .desc = сас! diff --git a/Resources/Prototypes/Catalog/uplink_catalog.yml b/Resources/Prototypes/Catalog/uplink_catalog.yml index 1bc9117ae1..17b530d031 100644 --- a/Resources/Prototypes/Catalog/uplink_catalog.yml +++ b/Resources/Prototypes/Catalog/uplink_catalog.yml @@ -53,7 +53,7 @@ icon: { sprite: /Textures/Objects/Weapons/Melee/e_sword.rsi, state: icon } productEntity: EnergySword cost: - Telecrystal: 8 + Telecrystal: 7 categories: - UplinkWeaponry saleLimit: 2 diff --git a/Resources/Prototypes/Entities/Objects/Fun/toys.yml b/Resources/Prototypes/Entities/Objects/Fun/toys.yml index a46ae22e89..5b61aec5f2 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/toys.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/toys.yml @@ -1173,13 +1173,14 @@ - type: entity parent: BaseItem - id: ToySword + id: ToySwordBase name: toy sword description: New Sandy-Cat plastic sword! Comes with realistic sound and full color! Looks almost like the real thing! + abstract: true components: - type: EnergySword - colorOptions: - - DodgerBlue + #colorOptions: + # - DodgerBlue - type: ItemToggle soundActivate: path: /Audio/Weapons/ebladeon.ogg @@ -1189,7 +1190,8 @@ activeSound: path: /Audio/Weapons/ebladehum.ogg - type: Sprite - sprite: Objects/Fun/toy_sword.rsi + #sprite: Objects/Fun/toy_sword.rsi + sprite: Objects/Weapons/Melee/e_sword.rsi layers: - state: e_sword - state: e_sword_blade @@ -1199,7 +1201,8 @@ map: [ "blade" ] - type: Item size: Small - sprite: Objects/Fun/toy_sword.rsi + #sprite: Objects/Fun/toy_sword.rsi + sprite: Objects/Weapons/Melee/e_sword-inhands.rsi - type: UseDelay delay: 1.0 - type: PointLight @@ -1223,6 +1226,7 @@ - type: StaminaDamageOnHit damage: 8 - type: MeleeWeapon + wideAnimationRotation: -135 damage: types: Blunt: 0 @@ -1235,10 +1239,55 @@ path: /Audio/Weapons/eblade1.ogg params: variation: 0.250 + volume: -10 activatedSoundOnSwing: path: /Audio/Weapons/eblademiss.ogg params: variation: 0.125 + - type: ItemToggleSize + activatedSize: Huge + +- type: entity + name: toy sword + description: New Sandy-Cat plastic sword! Comes with realistic sound and full color! Looks almost like the real thing! + parent: ToySwordBase + id: ToySword + components: + - type: Construction + deconstructionTarget: null + graph: ToyDoubleSwordGraph + node: esword + - type: Tag + tags: + - ToySword + +- type: entity + name: double toy sword + description: New Sandy-Cat plastic sword! Comes with realistic sound and full color! Looks almost like the real thing! + parent: ToySwordBase + id: ToySwordDouble + components: + - type: Sprite + sprite: Objects/Weapons/Melee/double_esword.rsi + layers: + - state: e_sword_double + - state: e_sword_double_blade + color: "#FFFFFF" + visible: false + shader: unshaded + map: [ "blade" ] + - type: Item + size: Small + sprite: Objects/Weapons/Melee/double_esword.rsi + - type: Wieldable + - type: ToggleableWielded + - type: StaminaDamageOnHit + damage: 16 + - type: FlipOnHit + - type: Construction + deconstructionTarget: null + graph: ToyDoubleSwordGraph + node: desword - type: entity parent: BasePlushie diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml index a5f62ab8af..9be60408b7 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml @@ -256,14 +256,13 @@ types: Slash: 15 Heat: 15 - - type: MeleeWeapon - attackRate: 1 - type: Reflect reflectProb: 1 enabled: false reflects: - Energy - type: ToggleableWielded + - type: FlipOnHit - type: Construction deconstructionTarget: null graph: EnergyDoubleSwordGraph diff --git a/Resources/Prototypes/_White/Recipes/hidden_crafts.yml b/Resources/Prototypes/_White/Recipes/hidden_crafts.yml index 86512ef60f..e3677caca6 100644 --- a/Resources/Prototypes/_White/Recipes/hidden_crafts.yml +++ b/Resources/Prototypes/_White/Recipes/hidden_crafts.yml @@ -10,6 +10,18 @@ - node: desword entity: EnergySwordDouble +- type: constructionGraph + id: ToyDoubleSwordGraph + start: esword + graph: + - node: esword + edges: + - to: desword + steps: + - tag: ToySword + - node: desword + entity: ToySwordDouble + - type: constructionGraph id: WeaponFlamethrowerGraph start: welder diff --git a/Resources/Prototypes/_White/tags.yml b/Resources/Prototypes/_White/tags.yml index c1bbf5968d..74ec9443c5 100644 --- a/Resources/Prototypes/_White/tags.yml +++ b/Resources/Prototypes/_White/tags.yml @@ -4,6 +4,9 @@ - type: Tag id: EnergySword +- type: Tag + id: ToySword + - type: Tag id: CrossbowBolt