Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions Content.Client/Backmen/Surgery/Wounds/WoundableVisualsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public sealed partial class WoundableVisualsSystem : VisualizerSystem<WoundableV
[Dependency] private BkmBodySharedSystem _body = default!;
[Dependency] private WoundSystem _wound = default!;

[Dependency] private SpriteSystem _sprite = default!;

[Dependency] private IRobustRandom _random = default!;

private const float AltBleedingSpriteChance = 0.15f;
Expand All @@ -29,8 +31,8 @@ public override void Initialize()
SubscribeLocalEvent<WoundableVisualsComponent, ComponentInit>(InitializeEntity, after: [typeof(WoundSystem)]);
SubscribeLocalEvent<WoundableVisualsComponent, ComponentStartup>(StartupEntity, after: [typeof(WoundSystem)]);

SubscribeLocalEvent<WoundableVisualsComponent, BodyPartRemovedEvent>(WoundableRemoved);
SubscribeLocalEvent<WoundableVisualsComponent, BodyPartAddedEvent>(WoundableConnected);
SubscribeLocalEvent<BodyComponent, BodyPartRemovedEvent>(WoundableRemoved);
SubscribeLocalEvent<BodyComponent, BodyPartAddedEvent>(WoundableConnected);

SubscribeLocalEvent<WoundableVisualsComponent, WoundableIntegrityChangedEvent>(OnWoundableIntegrityChanged);
}
Expand Down Expand Up @@ -73,41 +75,52 @@ private void StartupEntity(EntityUid uid, WoundableVisualsComponent component, r
UpdateWoundableVisuals(uid, component, bodySprite);
}

private void WoundableConnected(EntityUid uid, WoundableVisualsComponent component, ref BodyPartAddedEvent args)
private void WoundableConnected(EntityUid uid, BodyComponent component, ref BodyPartAddedEvent args)
{
if (!TryComp(args.Part.Comp.Body, out SpriteComponent? bodySprite))
//if (!component.ComplexBody)
// return;

if (!TryComp(uid, out SpriteComponent? bodySprite)
|| !TryComp(args.Part, out WoundableVisualsComponent? visuals))
return;

EnsureDamageLayersOnSprite(component, bodySprite);
EnsureDamageLayersOnSprite(visuals, bodySprite);
}

private void WoundableRemoved(EntityUid uid, WoundableVisualsComponent component, ref BodyPartRemovedEvent args)
// TODO: redo this
private void WoundableRemoved(EntityUid uid, BodyComponent component, ref BodyPartRemovedEvent args)
{
var body = args.Part.Comp.Body;
if (!TryComp(body, out SpriteComponent? bodySprite))
// TODO: derive bodies by complexness
//if (!component.ComplexBody)
// return;

if (!TryComp(uid, out SpriteComponent? bodySprite))
return;

foreach (var part in _body.GetBodyPartChildren(uid))
var removedPart = args.Part;

Entity<SpriteComponent?> bodyEnt = (uid, bodySprite);
foreach (var part in _body.GetBodyPartChildren(removedPart))
{
if (!TryComp<WoundableVisualsComponent>(part.Id, out var woundableVisuals))
continue;

foreach (var (group, _) in woundableVisuals.DamageOverlayGroups!)
{
if (!bodySprite.LayerMapTryGet($"{woundableVisuals.OccupiedLayer}{group}", out var layer))
if (!_sprite.LayerMapTryGet(bodyEnt, $"{woundableVisuals.OccupiedLayer}{group}", out var layer, false))
continue;

bodySprite.LayerSetVisible(layer, false);
bodySprite.LayerMapRemove(layer);
_sprite.LayerSetVisible(bodyEnt, layer, false);
_sprite.RemoveLayer(bodyEnt, layer);
}

if (bodySprite.LayerMapTryGet($"{woundableVisuals.OccupiedLayer}Bleeding", out var childBleeds))
if (_sprite.LayerMapTryGet(bodyEnt, $"{woundableVisuals.OccupiedLayer}Bleeding", out var childBleeds, false))
{
bodySprite.LayerSetVisible(childBleeds, false);
bodySprite.LayerMapRemove(childBleeds);
_sprite.LayerSetVisible(bodyEnt, childBleeds, false);
_sprite.RemoveLayer(bodyEnt, childBleeds);
}

if (TryComp(uid, out SpriteComponent? pieceSprite))
if (TryComp(part.Id, out SpriteComponent? pieceSprite))
UpdateWoundableVisuals(part.Id, woundableVisuals, pieceSprite);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public sealed partial class BkmBurnWoundableSystem : EntitySystem
[Dependency] private WoundSystem _wounds = default!;

public bool ShouldBurnToAsh(EntityUid woundable, WoundableComponent? component = null) =>
_wounds.ShouldBurnToAsh(woundable, component);
_wounds.ShouldBurnToAshNullable((woundable, component));
}
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ private void DispatchShuttleAnnouncement(string message, ShipwreckedRuleComponen
false,
true,
Color.SeaGreen);

var announcementEv = new AnnouncementSpokeEvent(filter, _audioSystem.GetSound(ChatSystem.DefaultAnnouncementSound), AudioParams.Default.WithVolume(-2f), message);
RaiseLocalEvent(announcementEv);
//var audioPath = _audioSystem.GetSound(audio);
Expand Down
Loading
Loading