Esword stuff (#329)

* - fix: Fix black RGB.

* - add: Toy sword update.

* - add: FlipOnHitSystem.

* - tweak: Price reduction.
This commit is contained in:
Aviu00
2024-06-05 14:31:21 +00:00
committed by GitHub
parent 4827bd5701
commit 2978834228
11 changed files with 181 additions and 9 deletions

View File

@@ -207,6 +207,8 @@ namespace Content.Client.Light
public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, Entity<RgbLightControllerComponent> 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,

View File

@@ -14,7 +14,7 @@ public sealed class EmoteAnimationSystem : EntitySystem
private readonly Dictionary<string, Action<EntityUid>> _emoteList = new();
private const string AnimationKey = "emoteAnimationKeyId";
public const string AnimationKey = "emoteAnimationKeyId";
private const string AnimationKeyTurn = "emoteAnimationKeyId_rotate";
//OnVerbsResponse?.Invoke(msg);

View File

@@ -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<FlipOnHitComponent, MeleeHitEvent>(OnHit);
SubscribeLocalEvent<FlippingComponent, AnimationCompletedEvent>(OnAnimationComplete);
}
private void OnAnimationComplete(Entity<FlippingComponent> ent, ref AnimationCompletedEvent args)
{
if (args.Key != EmoteAnimationSystem.AnimationKey)
return;
PlayAnimation(ent);
}
private void OnHit(Entity<FlipOnHitComponent> 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<FlippingComponent>(args.User);
return;
}
PlayAnimation(args.User);
}
private void PlayAnimation(EntityUid user)
{
RemComp<FlippingComponent>(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);
}
}

View File

@@ -0,0 +1,6 @@
namespace Content.Client._White.Animations;
[RegisterComponent]
public sealed partial class FlippingComponent : Component
{
}

View File

@@ -0,0 +1,8 @@
using Robust.Shared.GameStates;
namespace Content.Shared._White.Animations;
[RegisterComponent, NetworkedComponent]
public sealed partial class FlipOnHitComponent : Component
{
}

View File

@@ -150,6 +150,8 @@ ent-PonderingOrb = шар размышлений
.suffix = { "" }
ent-ToySword = игрушечный меч
.desc = Новый пластиковый меч от Sandy-Cat! Имеет реалистичный звук и насыщенный цвет! Почти как настоящий!
ent-ToySwordDouble = двойной игрушечный меч
.desc = Новый пластиковый меч от Sandy-Cat! Имеет реалистичный звук и насыщенный цвет! Почти как настоящий!
.suffix = { "" }
ent-ToyAmongPequeno = маленький амонг
.desc = сас!

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -4,6 +4,9 @@
- type: Tag
id: EnergySword
- type: Tag
id: ToySword
- type: Tag
id: CrossbowBolt