Merge remote-tracking branch 'WD-core/master' into upstream-core

This commit is contained in:
BIGZi0348
2025-02-16 11:31:16 +03:00
19 changed files with 496 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Item;
using Robust.Client.GameObjects;
namespace Content.Shared._White.FluffColorForClothing;
public sealed class FluffColorForClothingSystem : SharedFluffColorForClothingSystem
{
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
protected override void UpdateVisuals(EntityUid uid, FluffColorForClothingComponent component)
{
if (!TryComp(uid, out SpriteComponent? sprite))
return;
var state = sprite.LayerGetState(0).Name;
if (state == null)
return;
var prefix = state.Substring(0, state.IndexOf('_'));
sprite.LayerSetState(0, $"{prefix}_{component.CurrentColor}");
if (TryComp<ClothingComponent>(uid, out var clothingComp))
_clothingSystem.SetEquippedPrefix(uid, component.CurrentColor, clothingComp);
if (TryComp<ItemComponent>(uid, out var itemComp))
_itemSystem.SetHeldPrefix(uid, component.CurrentColor, false, itemComp);
}
}

View File

@@ -0,0 +1,57 @@
using System.Linq;
using Content.Shared.Inventory;
using Robust.Shared.Containers;
namespace Content.Shared._White.FluffColorForClothing;
public sealed class FluffColorForClothingSystem : SharedFluffColorForClothingSystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
private string GetNextColor(FluffColorForClothingComponent component)
{
var index = component.Colors.IndexOf(component.CurrentColor);
var count = component.Colors.Count;
if (index < count - 1)
index++;
else
index = 0;
var newColor = component.Colors[index];
return newColor;
}
protected override void ChangeColor(EntityUid uid, FluffColorForClothingComponent component)
{
if (component.User != null && _inventory.TryGetContainerSlotEnumerator((EntityUid) component.User, out var containerSlotEnumerator))
{
while (containerSlotEnumerator.NextItem(out var item, out var _))
{
if (TryComp<FluffColorForClothingComponent>(item, out var comp) && !comp.MainItem)
{
comp.CurrentColor = GetNextColor(comp);
Dirty(item, comp);
}
}
}
ChangeCompInside(component);
component.CurrentColor = GetNextColor(component);
Dirty(uid, component);
}
private void ChangeCompInside(FluffColorForClothingComponent component)
{
if (_container.TryGetContainer(component.Owner, "toggleable-clothing", out var container) && container.ContainedEntities.Any())
{
var content = container.ContainedEntities.First();
if (TryComp<FluffColorForClothingComponent>(content, out var contentComp) && component.Specifier == contentComp.Specifier)
{
contentComp.CurrentColor = GetNextColor(contentComp);
Dirty(contentComp.Owner, contentComp);
}
}
}
}

View File

@@ -0,0 +1,39 @@
using Content.Shared.Inventory;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared._White.FluffColorForClothing;
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState(true)]
public sealed partial class FluffColorForClothingComponent : Component
{
[DataField, AutoNetworkedField]
public EntProtoId Action = "ActionFluffColorForClothing";
[DataField, AutoNetworkedField]
public EntityUid? ActionEntity;
[DataField]
[AutoNetworkedField]
public string CurrentColor = "white";
[DataField]
public List<string> Colors = new() { "white" };
[DataField]
public string VerbText = "Поменять цвет";
[DataField]
public string Specifier = "default";
[DataField]
public bool MainItem = false;
[DataField]
public EntityUid? User;
[DataField("requiredSlot"), AutoNetworkedField]
public SlotFlags RequiredFlags = SlotFlags.NECK;
}

View File

@@ -0,0 +1,104 @@
using Content.Shared.Actions;
using Content.Shared.Inventory.Events;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
namespace Content.Shared._White.FluffColorForClothing;
public abstract class SharedFluffColorForClothingSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FluffColorForClothingComponent, GetVerbsEvent<AlternativeVerb>>(OnAddVerb);
SubscribeLocalEvent<FluffColorForClothingComponent, AfterAutoHandleStateEvent>(OnAfterHandleState);
SubscribeLocalEvent<FluffColorForClothingComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<FluffColorForClothingComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<FluffColorForClothingComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<FluffColorForClothingComponent, FluffColorForClothingEvent>(OnEvent);
SubscribeLocalEvent<FluffColorForClothingComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<FluffColorForClothingComponent, GetItemActionsEvent>(OnGetActions);
SubscribeLocalEvent<FluffColorForClothingComponent, ComponentRemove>(OnRemove);
}
private void OnRemove(Entity<FluffColorForClothingComponent> ent, ref ComponentRemove args)
{
_actionsSystem.RemoveAction(ent.Comp.ActionEntity);
}
private void OnGetActions(Entity<FluffColorForClothingComponent> ent, ref GetItemActionsEvent args)
{
if (ent.Comp.ActionEntity != null && args.SlotFlags == ent.Comp.RequiredFlags)
args.AddAction(ent.Comp.ActionEntity.Value);
}
private void OnMapInit(Entity<FluffColorForClothingComponent> ent, ref MapInitEvent args)
{
if (_actionContainer.EnsureAction(ent.Owner, ref ent.Comp.ActionEntity, out var action, ent.Comp.Action))
_actionsSystem.SetEntityIcon(ent.Comp.ActionEntity.Value, ent.Owner, action);
}
private void OnEvent(Entity<FluffColorForClothingComponent> ent, ref FluffColorForClothingEvent args)
{
if (args.Handled)
return;
args.Handled = true;
ChangeColor(ent.Owner, ent.Comp);
}
private void OnUnequipped(EntityUid uid, FluffColorForClothingComponent component, GotUnequippedEvent args)
{
component.User = null;
}
private void OnEquipped(EntityUid uid, FluffColorForClothingComponent component, GotEquippedEvent args)
{
component.User = args.Equipee;
}
private void OnAfterHandleState(EntityUid uid, FluffColorForClothingComponent component, ref AfterAutoHandleStateEvent args)
{
UpdateVisuals(uid, component);
}
private void OnInit(EntityUid uid, FluffColorForClothingComponent component, ComponentInit args)
{
UpdateVisuals(uid, component);
}
private void OnAddVerb(EntityUid uid, FluffColorForClothingComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract || args.Hands == null || component.Colors.Count < 2 || !component.MainItem)
return;
AlternativeVerb verb = new()
{
EventTarget = uid,
ExecutionEventArgs = new FluffColorForClothingEvent() { Performer = args.User },
Text = component.VerbText,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png")),
Priority = 0,
};
args.Verbs.Add(verb);
}
protected virtual void UpdateVisuals(EntityUid uid, FluffColorForClothingComponent component)
{
// See client system
}
protected virtual void ChangeColor(EntityUid uid, FluffColorForClothingComponent component)
{
// See server system
}
}
public sealed partial class FluffColorForClothingEvent : InstantActionEvent
{
}

View File

@@ -0,0 +1,66 @@
- type: entity
parent: ClothingNeckBase
id: ClothingNeckCloakRaincoat
name: прародительский плащ
suffix: fluff
components:
- type: ToggleableClothing
clothingPrototype: ClothingHeadHatHoodRaincoat
requiredSlot: NECK
- type: ContainerContainer
containers:
toggleable-clothing: !type:ContainerSlot {}
storagebase: !type:Container
ents: []
slot: head
- type: Clothing
sprite: White/Fluff/vkuser/raincoat.rsi
- type: Sprite
sprite: White/Fluff/vkuser/raincoat.rsi
state: icon_green
- type: Appearance
- type: FluffColorForClothing
mainItem: true
specifier: Raincoat
currentColor: green
colors:
- green
- red
- type: Tag
tags:
- ClothMade
- type: entity
parent: ClothingHeadBase
id: ClothingHeadHatHoodRaincoat
noSpawn: true
name: прародительский капюшон
suffix: fluff
components:
- type: Sprite
sprite: White/Fluff/vkuser/hoodraincoat.rsi
state: icon_green
- type: Clothing
sprite: White/Fluff/vkuser/hoodraincoat.rsi
- type: Tag
tags: [] # ignore "WhitelistChameleon" tag
- type: HideLayerClothing
slots:
- Hair
- type: FluffColorForClothing
specifier: Raincoat
currentColor: green
colors:
- green
- red
- type: entity
id: ActionFluffColorForClothing
name: Поменять цвет
description: Меняет цвет вашей экипировки.
noSpawn: true
components:
- type: InstantAction
itemIconStyle: BigItem
useDelay: 1
event: !type:FluffColorForClothingEvent

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC-BY-SA-4.0",
"copyright": "Archestratigus АКА Заступник",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon_green"
},
{
"name": "icon_red"
},
{
"name": "green-equipped-HELMET",
"directions": 4
},
{
"name": "red-equipped-HELMET",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

View File

@@ -0,0 +1,173 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Archestratigus АКА Заступник",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "green-inhand-left",
"directions": 4
},
{
"name": "red-inhand-left",
"directions": 4
},
{
"name": "green-inhand-right",
"directions": 4
},
{
"name": "red-inhand-right",
"directions": 4
},
{
"name": "icon_green"
},
{
"name": "icon_red"
},
{
"name": "red-equipped-NECK",
"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,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1
]
]
},
{
"name": "green-equipped-NECK",
"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,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B