Skip to content

Commit

Permalink
[Port] Surgery fix PartAppearance and other minor fixes (#945)
Browse files Browse the repository at this point in the history
* fix PartAppearance and bone sawing and keybinds camera

* fix usings code review
  • Loading branch information
TokenStyle authored Nov 26, 2024
1 parent 32f98d3 commit 9c26c84
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Robust.Shared.Prototypes;
using Content.Shared.Backmen.Surgery.Body.Events;


// ReSharper disable once CheckNamespace
namespace Content.Shared.Body.Systems;

Expand All @@ -30,13 +29,14 @@ private void OnPartAppearanceStartup(EntityUid uid, BodyPartAppearanceComponent
{
if (!TryComp(uid, out BodyPartComponent? part)
|| part.ToHumanoidLayers() is not { } relevantLayer)

return;

if (part.OriginalBody == null
|| TerminatingOrDeleted(part.OriginalBody.Value)
|| !TryComp(part.OriginalBody.Value, out HumanoidAppearanceComponent? bodyAppearance))
{
//component.ID = part.BaseLayerId;
component.ID = part.BaseLayerId;
component.Type = relevantLayer;
return;
}
Expand Down Expand Up @@ -74,8 +74,7 @@ private void OnPartAppearanceStartup(EntityUid uid, BodyPartAppearanceComponent
{
var category = MarkingCategoriesConversion.FromHumanoidVisualLayers(layer);
if (bodyAppearance.MarkingSet.Markings.TryGetValue(category, out var markingList))
markingsByLayer[layer] =
markingList.Select(m => new Marking(m.MarkingId, m.MarkingColors.ToList())).ToList();
markingsByLayer[layer] = markingList.Select(m => new Marking(m.MarkingId, m.MarkingColors.ToList())).ToList();
}

component.Markings = markingsByLayer;
Expand Down Expand Up @@ -147,10 +146,17 @@ private void OnPartAttachedToBody(EntityUid uid, BodyComponent component, ref Bo
private void OnPartDroppedFromBody(EntityUid uid, BodyComponent component, ref BodyPartRemovedEvent args)
{
if (TerminatingOrDeleted(uid)
|| !TryComp(args.Part, out BodyPartAppearanceComponent? appearance))
|| TerminatingOrDeleted(args.Part)
|| !TryComp(uid, out HumanoidAppearanceComponent? bodyAppearance))
return;

RemoveAppearance(uid, appearance, args.Part);
// We check for this conditional here since some entities may not have a profile... If they dont
// have one, and their part is gibbed, the markings will not be removed or applied properly.
if (!HasComp<BodyPartAppearanceComponent>(args.Part))
EnsureComp<BodyPartAppearanceComponent>(args.Part);

if (TryComp<BodyPartAppearanceComponent>(args.Part, out var partAppearance))
RemoveAppearance(uid, partAppearance, args.Part);
}

protected void UpdateAppearance(EntityUid target,
Expand All @@ -160,10 +166,7 @@ protected void UpdateAppearance(EntityUid target,
return;

if (component.EyeColor != null)
{
bodyAppearance.EyeColor = component.EyeColor.Value;
_humanoid.SetLayerVisibility(target, HumanoidVisualLayers.Eyes, true, true, bodyAppearance);
}

if (component.Color != null)
_humanoid.SetBaseLayerColor(target, component.Type, component.Color, true, bodyAppearance);
Expand All @@ -174,9 +177,7 @@ protected void UpdateAppearance(EntityUid target,
{
_humanoid.SetLayerVisibility(target, visualLayer, true, true, bodyAppearance);
foreach (var marking in markingList)
{
_humanoid.AddMarking(target, marking.MarkingId, marking.MarkingColors, true, true, bodyAppearance);
}
_humanoid.AddMarking(target, marking.MarkingId, marking.MarkingColors, false, true, bodyAppearance);
}

Dirty(target, bodyAppearance);
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Backmen/Surgery/Tools/BoneSawComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public sealed partial class BoneSawComponent : Component, ISurgeryToolComponent
public string ToolName => "a bone saw";
public bool? Used { get; set; } = null;
[DataField]
public float Speed { get; set; }
public float Speed { get; set; } = 1f;
}
9 changes: 3 additions & 6 deletions Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,8 @@ public virtual HashSet<EntityUid> GibPart(
return gibs;

ChangeSlotState((partId, part), true);
RemovePartChildren((partId, part), bodyEnt);

// We have to iterate though every organ to drop it when part is being destroyed
RemovePartChildren((partId, part), bodyEnt);
foreach (var organ in GetPartOrgans(partId, part))
{
_gibbingSystem.TryGibEntityWithRef(bodyEnt, organ.Id, GibType.Drop, GibContentsOption.Skip,
Expand All @@ -410,15 +409,15 @@ public virtual HashSet<EntityUid> GibPart(
playAudio: true, launchGibs: true, launchDirection: splatDirection, launchImpulse: GibletLaunchImpulse * splatModifier,
launchImpulseVariance: GibletLaunchImpulseVariance, launchCone: splatCone);


if (HasComp<InventoryComponent>(partId))
{
foreach (var item in _inventory.GetHandOrInventoryEntities((partId)))
foreach (var item in _inventory.GetHandOrInventoryEntities(partId))
{
SharedTransform.AttachToGridOrMap(item);
gibs.Add(item);
}
}

_audioSystem.PlayPredicted(gibSoundOverride, Transform(partId).Coordinates, null);
return gibs;
}
Expand Down Expand Up @@ -450,8 +449,6 @@ private void OnProfileLoadFinished(EntityUid uid, BodyComponent component, Profi
return;

foreach (var part in GetBodyChildren(uid, component))
{
EnsureComp<BodyPartAppearanceComponent>(part.Id);
}
}
}
5 changes: 5 additions & 0 deletions Resources/keybinds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ binds:
- function: CameraRotateLeft
type: State
key: NumpadNum7
mod1: Control
- function: CameraRotateRight
type: State
key: NumpadNum9
mod1: Control
- function: CameraReset
type: State
key: NumpadNum8
mod1: Control
- function: ZoomOut
type: State
key: NumpadNum4
mod1: Control
- function: ZoomIn
type: State
key: NumpadNum6
mod1: Control
- function: ResetZoom
type: State
key: NumpadNum5
Expand Down

0 comments on commit 9c26c84

Please sign in to comment.