add: try add sprite module. attemp 1
This commit is contained in:
42
Content.Client/_White/WeaponsModules/WeaponModulesVisuals.cs
Normal file
42
Content.Client/_White/WeaponsModules/WeaponModulesVisuals.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Content.Client.Weapons.Ranged.Components;
|
||||
using Content.Shared.Rounding;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client._White.WeaponsModules;
|
||||
|
||||
public sealed partial class WeaponModulesVisuals : EntitySystem
|
||||
{
|
||||
private void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<WeaponModulesVisualsComponent, ComponentInit>(ComponentInit);
|
||||
SubscribeLocalEvent<WeaponModulesVisualsComponent, AppearanceChangeEvent>(onModuleVisualChange);
|
||||
}
|
||||
|
||||
private void ComponentInit(EntityUid uid, WeaponModulesVisualsComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(uid, out var sprite)) return;
|
||||
|
||||
if (sprite.LayerMapTryGet(ModuleVisualState.Laser, out _))
|
||||
{
|
||||
sprite.LayerSetState(ModuleVisualState.Laser, $"laser");
|
||||
sprite.LayerSetVisible(ModuleVisualState.Laser, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void onModuleVisualChange(EntityUid uid, WeaponModulesVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
var sprite = args.Sprite;
|
||||
|
||||
if (sprite == null) return;
|
||||
|
||||
if (sprite.LayerMapTryGet(ModuleVisualState.Laser, out _))
|
||||
{
|
||||
sprite.LayerSetVisible(ModuleVisualState.Laser, true);
|
||||
sprite.LayerSetState(ModuleVisualState.Laser, $"laser");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client._White.WeaponsModules;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[RegisterComponent, Access(typeof(WeaponModulesVisuals))]
|
||||
public sealed partial class WeaponModulesVisualsComponent : Component
|
||||
{
|
||||
[DataField()] public string? state;
|
||||
}
|
||||
|
||||
public enum ModuleVisualState : byte
|
||||
{
|
||||
Laser
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Server.Light.Events;
|
||||
using Content.Server.Lightning;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -14,6 +11,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
protected const string ModulesSlot = "gun_modules";
|
||||
[Dependency] private readonly PointLightSystem _lightSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem Appearance = default!;
|
||||
[Dependency] private readonly SharedGunSystem _gunSystem = default!;
|
||||
|
||||
SoundSpecifier? oldSoundGunshot;
|
||||
|
||||
@@ -71,6 +71,8 @@
|
||||
map: [ "enum.GunVisualLayers.Base" ]
|
||||
- state: mag-0
|
||||
map: [ "enum.GunVisualLayers.Mag" ]
|
||||
- state: laser
|
||||
map: [ "enum.ModuleVisualState.Laser" ]
|
||||
- type: Gun
|
||||
fireRate: 5
|
||||
soundGunshot:
|
||||
@@ -111,6 +113,7 @@
|
||||
magState: mag
|
||||
steps: 1
|
||||
zeroVisible: true
|
||||
- type: WeaponModulesVisuals
|
||||
- type: Appearance
|
||||
|
||||
- type: entity
|
||||
|
||||
BIN
Resources/Textures/Objects/Weapons/Guns/Rifles/ak.rsi/laser.png
Normal file
BIN
Resources/Textures/Objects/Weapons/Guns/Rifles/ak.rsi/laser.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 152 B |
@@ -19,6 +19,9 @@
|
||||
{
|
||||
"name": "mag-0"
|
||||
},
|
||||
{
|
||||
"name": "laser"
|
||||
},
|
||||
{
|
||||
"name": "inhand-left",
|
||||
"directions": 4
|
||||
|
||||
Reference in New Issue
Block a user