Skip to content

Commit

Permalink
Merge pull request #391 from FoxxoTrystan/Floofstation-V7
Browse files Browse the repository at this point in the history
Floofstation Release V7
  • Loading branch information
FoxxoTrystan authored Dec 7, 2024
2 parents 52d5286 + 354cbf7 commit 7dad21a
Show file tree
Hide file tree
Showing 745 changed files with 8,914 additions and 4,082 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/publish-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Publish stable

concurrency:
group: publish

on:
workflow_dispatch:
push:
branches:
- stable # or the branch where merge requests are being merged into (e.g., 'master')


jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ concurrency:
group: publish

on:
workflow_dispatch:
schedule:
- cron: '0 6 * * *'
push:
branches:
- master

jobs:
build:
Expand Down
120 changes: 35 additions & 85 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Client.DisplacementMap;
using Content.Client.Inventory;
using Content.Shared.Clothing;
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.DisplacementMap;
using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
Expand Down Expand Up @@ -49,6 +52,7 @@ public sealed class ClientClothingSystem : ClothingSystem
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly DisplacementMapSystem _displacement = default!;

public override void Initialize()
{
Expand All @@ -63,15 +67,14 @@ public override void Initialize()

private void OnAppearanceUpdate(EntityUid uid, InventoryComponent component, ref AppearanceChangeEvent args)
{
// May need to update jumpsuit stencils if the sex changed. Also required to properly set the stencil on init
// May need to update displacement maps if the sex changed. Also required to properly set the stencil on init
if (args.Sprite == null)
return;

if (_inventorySystem.TryGetSlotEntity(uid, Jumpsuit, out var suit, component)
&& TryComp(suit, out ClothingComponent? clothing))
var enumerator = _inventorySystem.GetSlotEnumerator((uid, component));
while (enumerator.NextItem(out var item, out var slot))
{
SetGenderedMask(uid, args.Sprite, clothing);
return;
RenderEquipment(uid, item, slot.Name, component);
}

// No clothing equipped -> make sure the layer is hidden, though this should already be handled by on-unequip.
Expand Down Expand Up @@ -113,6 +116,7 @@ private void OnGetVisuals(EntityUid uid, ClothingComponent item, GetEquipmentVis
i++;
}

item.MappedLayer = key;
args.Layers.Add((key, layer));
}
}
Expand Down Expand Up @@ -153,13 +157,9 @@ private bool TryGetDefaultVisuals(EntityUid uid, ClothingComponent clothing, str

// species specific
if (speciesId != null && rsi.TryGetState($"{state}-{speciesId}", out _))
{
state = $"{state}-{speciesId}";
}
else if (!rsi.TryGetState(state, out _))
{
return false;
}

var layer = new PrototypeLayerData();
layer.RsiPath = rsi.Path.ToString();
Expand All @@ -181,14 +181,6 @@ private void OnVisualsChanged(EntityUid uid, InventoryComponent component, Visua

private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEvent args)
{
// Hide jumpsuit mask layer.
if (args.Slot == Jumpsuit
&& TryComp(uid, out SpriteComponent? sprite)
&& sprite.LayerMapTryGet(HumanoidVisualLayers.StencilMask, out var maskLayer))
{
sprite.LayerSetVisible(maskLayer, false);
}

if (!TryComp(uid, out InventorySlotsComponent? inventorySlots))
return;

Expand Down Expand Up @@ -233,9 +225,6 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot
return;
}

if (slot == Jumpsuit)
SetGenderedMask(equipee, sprite, clothingComponent);

if (!_inventorySystem.TryGetSlot(equipee, slot, out var slotDef, inventory))
return;

Expand Down Expand Up @@ -267,7 +256,25 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot
// temporary, until layer draw depths get added. Basically: a layer with the key "slot" is being used as a
// bookmark to determine where in the list of layers we should insert the clothing layers.
bool slotLayerExists = sprite.LayerMapTryGet(slot, out var index);
var displacementData = inventory.Displacements.GetValueOrDefault(slot);

// Select displacement maps
var displacementData = inventory.Displacements.GetValueOrDefault(slot); //Default unsexed map

var equipeeSex = CompOrNull<HumanoidAppearanceComponent>(equipee)?.Sex;
if (equipeeSex != null)
{
switch (equipeeSex)
{
case Sex.Male:
if (inventory.MaleDisplacements.Count > 0)
displacementData = inventory.MaleDisplacements.GetValueOrDefault(slot);
break;
case Sex.Female:
if (inventory.FemaleDisplacements.Count > 0)
displacementData = inventory.FemaleDisplacements.GetValueOrDefault(slot);
break;
}
}

// add the new layers
foreach (var (key, layerData) in ev.Layers)
Expand All @@ -287,12 +294,14 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot

if (layerData.Color != null)
sprite.LayerSetColor(key, layerData.Color.Value);
if (layerData.Scale != null)
sprite.LayerSetScale(key, layerData.Scale.Value);
}
else
index = sprite.LayerMapReserveBlank(key);

if (sprite[index] is not Layer layer)
return;
continue;

// In case no RSI is given, use the item's base RSI as a default. This cuts down on a lot of unnecessary yaml entries.
if (layerData.RsiPath == null
Expand All @@ -303,78 +312,19 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot
layer.SetRsi(clothingSprite.BaseRSI);
}

// Another "temporary" fix for clothing stencil masks.
// Sprite layer redactor when
// Sprite "redactor" just a week away.
if (slot == Jumpsuit)
layerData.Shader ??= "StencilDraw";

sprite.LayerSetData(index, layerData);
layer.Offset += slotDef.Offset;

if (displacementData != null)
if (displacementData is not null)
{
if (displacementData.ShaderOverride != null)
sprite.LayerSetShader(index, displacementData.ShaderOverride);

var displacementKey = $"{key}-displacement";
if (!revealedLayers.Add(displacementKey))
{
Log.Warning($"Duplicate key for clothing visuals DISPLACEMENT: {displacementKey}.");
//Checking that the state is not tied to the current race. In this case we don't need to use the displacement maps.
if (layerData.State is not null && inventory.SpeciesId is not null && layerData.State.EndsWith(inventory.SpeciesId))
continue;
}

var displacementLayer = _serialization.CreateCopy(displacementData.Layer, notNullableOverride: true);
displacementLayer.CopyToShaderParameters!.LayerKey = key;

// Add before main layer for this item.
sprite.AddLayer(displacementLayer, index);
sprite.LayerMapSet(displacementKey, index);

revealedLayers.Add(displacementKey);
_displacement.TryAddDisplacement(displacementData, sprite, index, key, revealedLayers);
}
}

RaiseLocalEvent(equipment, new EquipmentVisualsUpdatedEvent(equipee, slot, revealedLayers), true);
}


/// <summary>
/// Sets a sprite's gendered mask based on gender (obviously).
/// </summary>
/// <param name="sprite">Sprite to modify</param>
/// <param name="humanoid">Humanoid, to get gender from</param>
/// <param name="clothing">Clothing component, to get mask sprite type</param>
private void SetGenderedMask(EntityUid uid, SpriteComponent sprite, ClothingComponent clothing)
{
if (!sprite.LayerMapTryGet(HumanoidVisualLayers.StencilMask, out var layer))
return;

ClothingMask mask;
string prefix;

switch (CompOrNull<HumanoidAppearanceComponent>(uid)?.Sex)
{
case Sex.Male:
mask = clothing.MaleMask;
prefix = "male_";
break;
case Sex.Female:
mask = clothing.FemaleMask;
prefix = "female_";
break;
default:
mask = clothing.UnisexMask;
prefix = "unisex_";
break;
}

sprite.LayerSetState(layer, mask switch
{
ClothingMask.NoMask => $"{prefix}none",
ClothingMask.UniformTop => $"{prefix}top",
_ => $"{prefix}full",
});
sprite.LayerSetVisible(layer, true);
}
}
12 changes: 10 additions & 2 deletions Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public ConsentWindow()
ConsentFreetext.OnTextChanged += _ => UnsavedChanges();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (disposing)
_consentManager.OnServerDataLoaded -= UpdateUi;
}

private PlayerConsentSettings GetSettings()
{
var text = Rope.Collapse(ConsentFreetext.TextRope);
Expand Down Expand Up @@ -145,8 +153,8 @@ public void UpdateUi()

ConsentFreetext.TextRope = new Rope.Leaf(consent.Freetext);

if (ConsentList.ChildCount > 0)
ConsentList.RemoveAllChildren();
ConsentList.RemoveAllChildren();

_entries.Clear();

var consentprototypelist = _protoManager.EnumeratePrototypes<ConsentTogglePrototype>();
Expand Down
65 changes: 65 additions & 0 deletions Content.Client/DisplacementMap/DisplacementMapSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Content.Shared.DisplacementMap;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Serialization.Manager;

namespace Content.Client.DisplacementMap;

public sealed class DisplacementMapSystem : EntitySystem
{
[Dependency] private readonly ISerializationManager _serialization = default!;

public bool TryAddDisplacement(DisplacementData data, SpriteComponent sprite, int index, string key, HashSet<string> revealedLayers)
{
if (data.ShaderOverride != null)
sprite.LayerSetShader(index, data.ShaderOverride);

var displacementKey = $"{key}-displacement";
if (!revealedLayers.Add(displacementKey))
{
Log.Warning($"Duplicate key for DISPLACEMENT: {displacementKey}.");
return false;
}

//allows you not to write it every time in the YML
foreach (var pair in data.SizeMaps)
{
pair.Value.CopyToShaderParameters??= new()
{
LayerKey = "dummy",
ParameterTexture = "displacementMap",
ParameterUV = "displacementUV",
};
}

if (!data.SizeMaps.ContainsKey(32))
{
Log.Error($"DISPLACEMENT: {displacementKey} don't have 32x32 default displacement map");
return false;
}

// We choose a displacement map from the possible ones, matching the size with the original layer size.
// If there is no such a map, we use a standard 32 by 32 one
var displacementDataLayer = data.SizeMaps[EyeManager.PixelsPerMeter];
var actualRSI = sprite.LayerGetActualRSI(index);
if (actualRSI is not null)
{
if (actualRSI.Size.X != actualRSI.Size.Y)
Log.Warning($"DISPLACEMENT: {displacementKey} has a resolution that is not 1:1, things can look crooked");

var layerSize = actualRSI.Size.X;
if (data.SizeMaps.ContainsKey(layerSize))
displacementDataLayer = data.SizeMaps[layerSize];
}

var displacementLayer = _serialization.CreateCopy(displacementDataLayer, notNullableOverride: true);
displacementLayer.CopyToShaderParameters!.LayerKey = key;

sprite.AddLayer(displacementLayer, index);
sprite.LayerMapSet(displacementKey, index);

revealedLayers.Add(displacementKey);

return true;
}
}
47 changes: 47 additions & 0 deletions Content.Client/Floofstation/VoredSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Shared.FloofStation;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;

namespace Content.Client.Floofstation;

public sealed partial class VoredSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<VoredComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<VoredComponent, ComponentShutdown>(Onhutdown);
SubscribeLocalEvent<VoredComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<VoredComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
}

private void OnInit(EntityUid uid, VoredComponent component, ComponentInit args)
{
if (uid != _playerMan.LocalEntity)
return;

component.Stream = _audio.PlayGlobal(component.SoundBelly, Filter.Local(), false)?.Entity;
}

private void Onhutdown(EntityUid uid, VoredComponent component, ComponentShutdown args)
{
if (uid != _playerMan.LocalEntity)
return;

QueueDel(component.Stream);
}

private void OnPlayerAttached(EntityUid uid, VoredComponent component, LocalPlayerAttachedEvent args)
{
component.Stream = _audio.PlayGlobal(component.SoundBelly, Filter.Local(), false)?.Entity;
}

private void OnPlayerDetached(EntityUid uid, VoredComponent component, LocalPlayerDetachedEvent args)
{
QueueDel(component.Stream);
}
}
Loading

0 comments on commit 7dad21a

Please sign in to comment.