Make energy swords use RgbLightController (#7344)
@@ -1,17 +1,10 @@
|
||||
using Content.Client.Items.Components;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Light.Component;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Collections.Generic;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
using static Robust.Shared.GameObjects.SharedSpriteComponent;
|
||||
|
||||
namespace Content.Client.Light.Components
|
||||
{
|
||||
@@ -32,26 +25,6 @@ namespace Content.Client.Light.Components
|
||||
[DataField("addPrefix")]
|
||||
public bool AddPrefix = false;
|
||||
|
||||
/// <summary>
|
||||
/// Sprite layer that will have it's visibility toggled when this item is toggled.
|
||||
/// </summary>
|
||||
[DataField("layer")]
|
||||
public string Layer = "light";
|
||||
|
||||
/// <summary>
|
||||
/// Layers to add to the sprite of the player that is holding this entity.
|
||||
/// </summary>
|
||||
[DataField("inhandVisuals")]
|
||||
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();
|
||||
|
||||
/// <summary>
|
||||
/// Layers to add to the sprite of the player that is wearing this entity.
|
||||
/// </summary>
|
||||
[DataField("clothingVisuals")]
|
||||
public readonly Dictionary<string, List<PrototypeLayerData>> ClothingVisuals = new();
|
||||
|
||||
public Color Color { get; internal set; }
|
||||
|
||||
public Control MakeControl()
|
||||
{
|
||||
return new StatusControl(this);
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using Content.Client.Clothing;
|
||||
using Content.Client.Items.Systems;
|
||||
using Content.Client.Light.Components;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Light.Component;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Client.Light;
|
||||
|
||||
@@ -19,59 +14,6 @@ public sealed class HandheldLightSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<HandheldLightComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<HandheldLightComponent, GetInhandVisualsEvent>(OnGetHeldVisuals, after: new[] { typeof(ItemSystem) } );
|
||||
SubscribeLocalEvent<HandheldLightComponent, GetEquipmentVisualsEvent>(OnGetEquipmentVisuals, after: new[] { typeof(ClothingSystem)});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the unshaded light overlays to any clothing sprites.
|
||||
/// </summary>
|
||||
private void OnGetEquipmentVisuals(EntityUid uid, HandheldLightComponent component, GetEquipmentVisualsEvent args)
|
||||
{
|
||||
if (!component.Activated)
|
||||
return;
|
||||
|
||||
if (!component.ClothingVisuals.TryGetValue(args.Slot, out var layers))
|
||||
return;
|
||||
|
||||
var i = 0;
|
||||
foreach (var layer in layers)
|
||||
{
|
||||
var key = layer.MapKeys?.FirstOrDefault();
|
||||
if (key == null)
|
||||
{
|
||||
key = i == 0 ? $"{args.Slot}-light" : $"{args.Slot}-light-{i}";
|
||||
i++;
|
||||
}
|
||||
|
||||
args.Layers.Add((key, layer));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the unshaded light overlays to any in-hand sprites.
|
||||
/// </summary>
|
||||
private void OnGetHeldVisuals(EntityUid uid, HandheldLightComponent component, GetInhandVisualsEvent args)
|
||||
{
|
||||
if (!component.Activated)
|
||||
return;
|
||||
|
||||
if (!component.InhandVisuals.TryGetValue(args.Location, out var layers))
|
||||
return;
|
||||
|
||||
var i = 0;
|
||||
var defaultKey = $"inhand-{args.Location.ToString().ToLowerInvariant()}-light";
|
||||
foreach (var layer in layers)
|
||||
{
|
||||
var key = layer.MapKeys?.FirstOrDefault();
|
||||
if (key == null)
|
||||
{
|
||||
key = i == 0 ? defaultKey : $"{defaultKey}-{i}";
|
||||
i++;
|
||||
}
|
||||
|
||||
args.Layers.Add((key, layer));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, HandheldLightComponent component, ref ComponentHandleState args)
|
||||
@@ -85,21 +27,13 @@ public sealed class HandheldLightSystem : EntitySystem
|
||||
return;
|
||||
|
||||
component.Activated = state.Activated;
|
||||
_itemSys.VisualsChanged(uid);
|
||||
|
||||
if (TryComp(component.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.LayerSetVisible(component.Layer, state.Activated);
|
||||
}
|
||||
|
||||
if (TryComp(uid, out PointLightComponent? light))
|
||||
{
|
||||
light.Enabled = state.Activated;
|
||||
}
|
||||
|
||||
// really hand-held lights should be using a separate unshaded layer. (see FlashlightVisualizer)
|
||||
// this prefix stuff is largely for backwards compatibility with RSIs/yamls that have not been updated.
|
||||
if (component.AddPrefix && TryComp(uid, out SharedItemComponent? item))
|
||||
{
|
||||
item.EquippedPrefix = state.Activated ? "on" : "off";
|
||||
_itemSys.VisualsChanged(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
Content.Client/Toggleable/ToggleableLightVisualsComponent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using static Robust.Shared.GameObjects.SharedSpriteComponent;
|
||||
|
||||
namespace Content.Client.Toggleable;
|
||||
|
||||
/// <summary>
|
||||
/// Component that handles the toggling the visuals of some light emitting entity.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This will toggle the visibility of layers on an entity's sprite, the in-hand visuals, and the clothing/equipment
|
||||
/// visuals. This will modify the color of any attached point lights.
|
||||
/// </remarks>
|
||||
[RegisterComponent]
|
||||
public sealed class ToggleableLightVisualsComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Sprite layer that will have it's visibility toggled when this item is toggled.
|
||||
/// </summary>
|
||||
[DataField("spriteLayer")]
|
||||
public string SpriteLayer = "light";
|
||||
|
||||
/// <summary>
|
||||
/// Layers to add to the sprite of the player that is holding this entity (while the component is toggled on).
|
||||
/// </summary>
|
||||
[DataField("inhandVisuals")]
|
||||
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();
|
||||
|
||||
/// <summary>
|
||||
/// Layers to add to the sprite of the player that is wearing this entity (while the component is toggled on).
|
||||
/// </summary>
|
||||
[DataField("clothingVisuals")]
|
||||
public readonly Dictionary<string, List<PrototypeLayerData>> ClothingVisuals = new();
|
||||
}
|
||||
113
Content.Client/Toggleable/ToggleableLightVisualsSystem.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Content.Client.Clothing;
|
||||
using Content.Client.Items.Systems;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Client.Toggleable;
|
||||
|
||||
public sealed class ToggleableLightVisualsSystem : VisualizerSystem<ToggleableLightVisualsComponent>
|
||||
{
|
||||
[Dependency] private readonly SharedItemSystem _itemSys = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ToggleableLightVisualsComponent, GetInhandVisualsEvent>(OnGetHeldVisuals, after: new[] { typeof(ItemSystem) });
|
||||
SubscribeLocalEvent<ToggleableLightVisualsComponent, GetEquipmentVisualsEvent>(OnGetEquipmentVisuals, after: new[] { typeof(ClothingSystem) });
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, ToggleableLightVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (!args.Component.TryGetData(ToggleableLightVisuals.Enabled, out bool enabled))
|
||||
return;
|
||||
|
||||
var modulate = args.Component.TryGetData(ToggleableLightVisuals.Color, out Color color);
|
||||
|
||||
// Update the item's sprite
|
||||
if (TryComp(uid, out SpriteComponent? sprite) && sprite.LayerMapTryGet(component.SpriteLayer, out var layer))
|
||||
{
|
||||
sprite.LayerSetVisible(layer, enabled);
|
||||
if (modulate)
|
||||
sprite.LayerSetColor(layer, color);
|
||||
}
|
||||
|
||||
// Update any point-lights
|
||||
if (TryComp(uid, out PointLightComponent? light))
|
||||
{
|
||||
DebugTools.Assert(!light.NetSyncEnabled, "light visualizers require point lights without net-sync");
|
||||
light.Enabled = enabled;
|
||||
if (enabled && modulate)
|
||||
light.Color = color;
|
||||
}
|
||||
|
||||
// update clothing & in-hand visuals.
|
||||
_itemSys.VisualsChanged(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the unshaded light overlays to any clothing sprites.
|
||||
/// </summary>
|
||||
private void OnGetEquipmentVisuals(EntityUid uid, ToggleableLightVisualsComponent component, GetEquipmentVisualsEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out AppearanceComponent? appearance)
|
||||
|| !appearance.TryGetData(ToggleableLightVisuals.Enabled, out bool enabled)
|
||||
|| !enabled)
|
||||
return;
|
||||
|
||||
if (!component.ClothingVisuals.TryGetValue(args.Slot, out var layers))
|
||||
return;
|
||||
|
||||
var modulate = appearance.TryGetData(ToggleableLightVisuals.Color, out Color color);
|
||||
|
||||
var i = 0;
|
||||
foreach (var layer in layers)
|
||||
{
|
||||
var key = layer.MapKeys?.FirstOrDefault();
|
||||
if (key == null)
|
||||
{
|
||||
key = i == 0 ? $"{args.Slot}-toggle" : $"{args.Slot}-toggle-{i}";
|
||||
i++;
|
||||
}
|
||||
|
||||
if (modulate)
|
||||
layer.Color = color;
|
||||
|
||||
args.Layers.Add((key, layer));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetHeldVisuals(EntityUid uid, ToggleableLightVisualsComponent component, GetInhandVisualsEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out AppearanceComponent? appearance)
|
||||
|| !appearance.TryGetData(ToggleableLightVisuals.Enabled, out bool enabled)
|
||||
|| !enabled)
|
||||
return;
|
||||
|
||||
if (!component.InhandVisuals.TryGetValue(args.Location, out var layers))
|
||||
return;
|
||||
|
||||
var modulate = appearance.TryGetData(ToggleableLightVisuals.Color, out Color color);
|
||||
|
||||
var i = 0;
|
||||
var defaultKey = $"inhand-{args.Location.ToString().ToLowerInvariant()}-toggle";
|
||||
foreach (var layer in layers)
|
||||
{
|
||||
var key = layer.MapKeys?.FirstOrDefault();
|
||||
if (key == null)
|
||||
{
|
||||
key = i == 0 ? defaultKey : $"{defaultKey}-{i}";
|
||||
i++;
|
||||
}
|
||||
|
||||
if (modulate)
|
||||
layer.Color = color;
|
||||
|
||||
args.Layers.Add((key, layer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Weapons.Melee;
|
||||
|
||||
public sealed class EnergySwordVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
component.TryGetData(EnergySwordVisuals.State, out EnergySwordStatus? status);
|
||||
status ??= EnergySwordStatus.Off;
|
||||
component.TryGetData(EnergySwordVisuals.Color, out Color? color);
|
||||
color ??= Color.DodgerBlue;
|
||||
entManager.TryGetComponent(component.Owner, out SpriteComponent? spriteComponent);
|
||||
|
||||
if ((status & EnergySwordStatus.On) != 0x0)
|
||||
{
|
||||
TurnOn(component, status.Value, color.Value, entManager, spriteComponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
TurnOff(component, status.Value, entManager, spriteComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private void TurnOn(
|
||||
AppearanceComponent component,
|
||||
EnergySwordStatus status,
|
||||
Color color,
|
||||
IEntityManager entManager,
|
||||
SpriteComponent? spriteComponent = null)
|
||||
{
|
||||
if ((status & EnergySwordStatus.Hacked) != 0x0)
|
||||
{
|
||||
if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
|
||||
{
|
||||
itemComponent.EquippedPrefix = "on-rainbow";
|
||||
}
|
||||
|
||||
//todo: figure out how to use the RGBLightControllerSystem to phase out the rainbow sprite AND add lights.
|
||||
spriteComponent?.LayerSetColor(1, Color.White);
|
||||
spriteComponent?.LayerSetVisible(1, false);
|
||||
spriteComponent?.LayerSetState(0, "e_sword_rainbow_on");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
|
||||
{
|
||||
itemComponent.EquippedPrefix = "on";
|
||||
itemComponent.Color = color;
|
||||
}
|
||||
|
||||
spriteComponent?.LayerSetColor(1, color);
|
||||
spriteComponent?.LayerSetVisible(1, true);
|
||||
|
||||
if (entManager.TryGetComponent(component.Owner, out PointLightComponent? pointLightComponent))
|
||||
{
|
||||
pointLightComponent.Color = color;
|
||||
pointLightComponent.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TurnOff(
|
||||
AppearanceComponent component,
|
||||
EnergySwordStatus status,
|
||||
IEntityManager entManager,
|
||||
SpriteComponent? spriteComponent = null)
|
||||
{
|
||||
if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
|
||||
{
|
||||
itemComponent.EquippedPrefix = "off";
|
||||
}
|
||||
|
||||
if ((status & EnergySwordStatus.Hacked) != 0x0)
|
||||
{
|
||||
spriteComponent?.LayerSetState(0, "e_sword");
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteComponent?.LayerSetVisible(1, false);
|
||||
}
|
||||
|
||||
if (entManager.TryGetComponent(component.Owner, out PointLightComponent? pointLightComponent))
|
||||
{
|
||||
pointLightComponent.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace Content.Server.Entry
|
||||
"ItemCabinetVisuals",
|
||||
"DiseaseMachineVisuals",
|
||||
"HandheldGPS",
|
||||
"ToggleableLightVisuals",
|
||||
"PotencyVisuals",
|
||||
"PaperVisuals"
|
||||
};
|
||||
|
||||
@@ -183,10 +183,13 @@ namespace Content.Server.Light.EntitySystems
|
||||
_actionSystem.SetToggled(component.ToggleAction, false);
|
||||
_activeLights.Remove(component);
|
||||
component.LastLevel = null;
|
||||
component.Dirty(EntityManager);
|
||||
Dirty(component);
|
||||
|
||||
if (TryComp(component.Owner, out AppearanceComponent? appearance))
|
||||
appearance.SetData(ToggleableLightVisuals.Enabled, false);
|
||||
|
||||
if (makeNoise)
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.TurnOffSound.GetSound(), component.Owner);
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.TurnOffSound.GetSound(), component.Owner);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -197,7 +200,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
if (!_powerCell.TryGetBatteryFromSlot(component.Owner, out var battery))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.TurnOnFailSound.GetSound(), component.Owner);
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.TurnOnFailSound.GetSound(), component.Owner);
|
||||
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-missing-message"), component.Owner, Filter.Entities(user));
|
||||
return false;
|
||||
}
|
||||
@@ -207,7 +210,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
// Simple enough.
|
||||
if (component.Wattage > battery.CurrentCharge)
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.TurnOnFailSound.GetSound(), component.Owner);
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.TurnOnFailSound.GetSound(), component.Owner);
|
||||
_popup.PopupEntity(Loc.GetString("handheld-light-component-cell-dead-message"), component.Owner, Filter.Entities(user));
|
||||
return false;
|
||||
}
|
||||
@@ -219,7 +222,10 @@ namespace Content.Server.Light.EntitySystems
|
||||
component.LastLevel = GetLevel(component);
|
||||
Dirty(component);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.TurnOnSound.GetSound(), component.Owner);
|
||||
if (TryComp(component.Owner, out AppearanceComponent? appearance))
|
||||
appearance.SetData(ToggleableLightVisuals.Enabled, true);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.TurnOnSound.GetSound(), component.Owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Weapon.Melee.EnergySword
|
||||
{
|
||||
@@ -15,6 +11,13 @@ namespace Content.Server.Weapon.Melee.EnergySword
|
||||
public bool Hacked = false;
|
||||
|
||||
public bool Activated = false;
|
||||
|
||||
/// <summary>
|
||||
/// RGB cycle rate for hacked e-swords.
|
||||
/// </summary>
|
||||
[DataField("cycleRate")]
|
||||
public float CycleRate = 1f;
|
||||
|
||||
[DataField("hitSound")]
|
||||
public SoundSpecifier HitSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/eblade1.ogg");
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -15,6 +14,7 @@ namespace Content.Server.Weapon.Melee.EnergySword
|
||||
public sealed class EnergySwordSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedRgbLightControllerSystem _rgbSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -55,6 +55,8 @@ namespace Content.Server.Weapon.Melee.EnergySword
|
||||
{
|
||||
TurnOn(comp);
|
||||
}
|
||||
|
||||
UpdateAppearance(comp);
|
||||
}
|
||||
|
||||
private void TurnOff(EnergySwordComponent comp)
|
||||
@@ -67,10 +69,9 @@ namespace Content.Server.Weapon.Melee.EnergySword
|
||||
item.Size = 5;
|
||||
}
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DeActivateSound.GetSound(), comp.Owner);
|
||||
SoundSystem.Play(Filter.Pvs(comp.Owner, entityManager: EntityManager), comp.DeActivateSound.GetSound(), comp.Owner);
|
||||
|
||||
comp.Activated = false;
|
||||
UpdateAppearance(comp, item);
|
||||
}
|
||||
|
||||
private void TurnOn(EnergySwordComponent comp)
|
||||
@@ -83,43 +84,36 @@ namespace Content.Server.Weapon.Melee.EnergySword
|
||||
item.Size = 9999;
|
||||
}
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(comp.Owner), comp.ActivateSound.GetSound(), comp.Owner);
|
||||
SoundSystem.Play(Filter.Pvs(comp.Owner, entityManager: EntityManager), comp.ActivateSound.GetSound(), comp.Owner);
|
||||
|
||||
comp.Activated = true;
|
||||
UpdateAppearance(comp, item);
|
||||
}
|
||||
|
||||
private void UpdateAppearance(EnergySwordComponent component, SharedItemComponent? itemComponent = null)
|
||||
private void UpdateAppearance(EnergySwordComponent component)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent)) return;
|
||||
if (!TryComp(component.Owner, out AppearanceComponent? appearanceComponent))
|
||||
return;
|
||||
|
||||
appearanceComponent.SetData(EnergySwordVisuals.Color, component.BladeColor);
|
||||
|
||||
var status = component.Activated ? EnergySwordStatus.On : EnergySwordStatus.Off;
|
||||
if (component.Hacked)
|
||||
status |= EnergySwordStatus.Hacked;
|
||||
|
||||
appearanceComponent.SetData(EnergySwordVisuals.State, status);
|
||||
// wew itemcomp
|
||||
if (Resolve(component.Owner, ref itemComponent, false))
|
||||
{
|
||||
itemComponent.EquippedPrefix = component.Activated ? "on" : "off";
|
||||
itemComponent.Color = component.BladeColor;
|
||||
}
|
||||
appearanceComponent.SetData(ToggleableLightVisuals.Enabled, component.Activated);
|
||||
appearanceComponent.SetData(ToggleableLightVisuals.Color, component.BladeColor);
|
||||
}
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, EnergySwordComponent comp, InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled) return;
|
||||
|
||||
if (comp.Hacked)
|
||||
return;
|
||||
|
||||
if (!TryComp(args.Used, out ToolComponent? tool) || !tool.Qualities.ContainsAny("Pulsing")) return;
|
||||
|
||||
args.Handled = true;
|
||||
comp.Hacked = true;
|
||||
UpdateAppearance(comp);
|
||||
comp.Hacked = !comp.Hacked;
|
||||
|
||||
if (comp.Hacked)
|
||||
{
|
||||
var rgb = EnsureComp<RgbLightControllerComponent>(uid);
|
||||
_rgbSystem.SetCycleRate(uid, comp.CycleRate, rgb);
|
||||
}
|
||||
else
|
||||
RemComp<RgbLightControllerComponent>(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,23 +64,6 @@ namespace Content.Shared.Item
|
||||
[DataField("EquipSound")]
|
||||
public SoundSpecifier? EquipSound { get; set; } = default!;
|
||||
|
||||
// TODO REMOVE. Currently nonfunctional and only used by RGB system. #6253 Fixes this but requires #6252
|
||||
/// <summary>
|
||||
/// Color of the sprite shown on the player when this item is in their hands.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Color Color
|
||||
{
|
||||
get => _color;
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
[DataField("color")]
|
||||
private Color _color = Color.White;
|
||||
|
||||
/// <summary>
|
||||
/// Rsi of the sprite shown on the player when this item is in their hands. Used to generate a default entry for <see cref="InhandVisuals"/>
|
||||
/// </summary>
|
||||
|
||||
11
Content.Shared/Toggleable/ToggleableLightVisuals.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Toggleable;
|
||||
|
||||
// Appearance Data key
|
||||
[Serializable, NetSerializable]
|
||||
public enum ToggleableLightVisuals
|
||||
{
|
||||
Enabled,
|
||||
Color
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Weapons.Melee;
|
||||
|
||||
|
||||
[Serializable, NetSerializable, Flags]
|
||||
public enum EnergySwordStatus : byte
|
||||
{
|
||||
Off = 0,
|
||||
On = 1 << 0,
|
||||
Hacked = 1 << 1,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum EnergySwordVisuals : byte
|
||||
{
|
||||
State,
|
||||
Color,
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
map: [ "light" ]
|
||||
- type: HandheldLight
|
||||
addPrefix: false
|
||||
- type: ToggleableLightVisuals
|
||||
spriteLayer: light
|
||||
inhandVisuals:
|
||||
left:
|
||||
- state: inhand-left-light
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
- DroneUsable
|
||||
- type: HandheldLight
|
||||
addPrefix: false
|
||||
toggleAction:
|
||||
name: action-name-toggle-light
|
||||
description: action-description-toggle-light
|
||||
icon: Objects/Tools/flashlight.rsi/flashlight.png
|
||||
iconOn: Objects/Tools/flashlight.rsi/flashlight-on.png
|
||||
event: !type:ToggleActionEvent
|
||||
- type: ToggleableLightVisuals
|
||||
spriteLayer: light
|
||||
inhandVisuals:
|
||||
left:
|
||||
- state: inhand-left-light
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
color: "#FFFFFF"
|
||||
visible: false
|
||||
shader: unshaded
|
||||
map: [ "blade" ]
|
||||
- type: MeleeWeapon
|
||||
damage:
|
||||
types:
|
||||
@@ -35,8 +36,15 @@
|
||||
energy: 2
|
||||
color: white
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: EnergySwordVisualizer
|
||||
- type: ToggleableLightVisuals
|
||||
spriteLayer: blade
|
||||
inhandVisuals:
|
||||
left:
|
||||
- state: inhand-left-blade
|
||||
shader: unshaded
|
||||
right:
|
||||
- state: inhand-right-blade
|
||||
shader: unshaded
|
||||
|
||||
- type: entity
|
||||
name: pen
|
||||
@@ -59,6 +67,7 @@
|
||||
color: "#FFFFFF"
|
||||
visible: false
|
||||
shader: unshaded
|
||||
map: [ "blade" ]
|
||||
- type: MeleeWeapon
|
||||
damage:
|
||||
types:
|
||||
@@ -75,8 +84,15 @@
|
||||
energy: 1.5
|
||||
color: white
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: EnergySwordVisualizer
|
||||
- type: ToggleableLightVisuals
|
||||
spriteLayer: blade
|
||||
inhandVisuals:
|
||||
left:
|
||||
- state: inhand-left-blade
|
||||
shader: unshaded
|
||||
right:
|
||||
- state: inhand-right-blade
|
||||
shader: unshaded
|
||||
- type: Tag
|
||||
tags:
|
||||
- Write
|
||||
|
||||
|
Before Width: | Height: | Size: 554 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 166 B |
@@ -11,40 +11,12 @@
|
||||
"name": "e_sword"
|
||||
},
|
||||
{
|
||||
"name": "off-inhand-left",
|
||||
"name": "inhand-left",
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "off-inhand-right",
|
||||
"name": "inhand-right",
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "e_sword_rainbow_on",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "e_sword_on",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "e_sword_blade",
|
||||
@@ -56,7 +28,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-inhand-left",
|
||||
"name": "inhand-left-blade",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
@@ -78,7 +50,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-inhand-right",
|
||||
"name": "inhand-right-blade",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
@@ -98,130 +70,6 @@
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-rainbow-inhand-left",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-rainbow-inhand-right",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 460 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 314 B After Width: | Height: | Size: 314 B |
|
After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
@@ -11,40 +11,12 @@
|
||||
"name": "e_sword"
|
||||
},
|
||||
{
|
||||
"name": "off-inhand-left",
|
||||
"name": "inhand-left",
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "off-inhand-right",
|
||||
"name": "inhand-right",
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "e_sword_rainbow_on",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "e_sword_on",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "e_sword_blade",
|
||||
@@ -56,7 +28,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-inhand-left",
|
||||
"name": "inhand-left-blade",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
@@ -78,7 +50,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-inhand-right",
|
||||
"name": "inhand-right-blade",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
@@ -98,130 +70,6 @@
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-rainbow-inhand-left",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "on-rainbow-inhand-right",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1009 B |
|
Before Width: | Height: | Size: 984 B |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |