diff --git a/Content.Client/Body/Components/BrainComponent.cs b/Content.Client/Body/Components/BrainComponent.cs index 826cdbacd42..5ef9cea9901 100644 --- a/Content.Client/Body/Components/BrainComponent.cs +++ b/Content.Client/Body/Components/BrainComponent.cs @@ -1,9 +1,3 @@ -using Robust.Shared.GameStates; - -namespace Content.Client.Body.Components -{ - [RegisterComponent] - public sealed partial class BrainComponent : Component - { - } -} +namespace Content.Client.Body.Components; +[RegisterComponent] +public sealed partial class BrainComponent : Component { } diff --git a/Content.Client/Body/Components/LungComponent.cs b/Content.Client/Body/Components/LungComponent.cs index 0c16b43b63c..71a19323b87 100644 --- a/Content.Client/Body/Components/LungComponent.cs +++ b/Content.Client/Body/Components/LungComponent.cs @@ -1,9 +1,3 @@ -using Robust.Shared.GameStates; - -namespace Content.Client.Body.Components -{ - [RegisterComponent] - public sealed partial class LungComponent : Component - { - } -} +namespace Content.Client.Body.Components; +[RegisterComponent] +public sealed partial class LungComponent : Component { } diff --git a/Content.Client/Body/Components/StomachComponent.cs b/Content.Client/Body/Components/StomachComponent.cs index 3022d4b4aa2..fbc06ac7d75 100644 --- a/Content.Client/Body/Components/StomachComponent.cs +++ b/Content.Client/Body/Components/StomachComponent.cs @@ -1,9 +1,3 @@ -using Robust.Shared.GameStates; - -namespace Content.Client.Body.Components -{ - [RegisterComponent] - public sealed partial class StomachComponent : Component - { - } -} +namespace Content.Client.Body.Components; +[RegisterComponent] +public sealed partial class StomachComponent : Component { } diff --git a/Content.Client/Body/Systems/BodySystem.cs b/Content.Client/Body/Systems/BodySystem.cs index 41117d7fdc2..10dc057a8fd 100644 --- a/Content.Client/Body/Systems/BodySystem.cs +++ b/Content.Client/Body/Systems/BodySystem.cs @@ -22,9 +22,7 @@ private void ApplyMarkingToPart(MarkingPrototype markingPrototype, var markingSprite = markingPrototype.Sprites[j]; if (markingSprite is not SpriteSpecifier.Rsi rsi) - { continue; - } var layerId = $"{markingPrototype.ID}-{rsi.RsiState}"; @@ -38,21 +36,14 @@ private void ApplyMarkingToPart(MarkingPrototype markingPrototype, sprite.LayerSetVisible(layerId, visible); if (!visible) - { continue; - } // Okay so if the marking prototype is modified but we load old marking data this may no longer be valid - // and we need to check the index is correct. - // So if that happens just default to white? + // and we need to check the index is correct. So if that happens just default to white? if (colors != null && j < colors.Count) - { sprite.LayerSetColor(layerId, colors[j]); - } else - { sprite.LayerSetColor(layerId, Color.White); - } } } @@ -65,7 +56,6 @@ protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceCo sprite.Color = component.Color.Value; foreach (var (visualLayer, markingList) in component.Markings) - { foreach (var marking in markingList) { if (!_markingManager.TryGetMarking(marking, out var markingPrototype)) @@ -73,7 +63,6 @@ protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceCo ApplyMarkingToPart(markingPrototype, marking.MarkingColors, marking.Visible, sprite); } - } } protected override void RemoveBodyMarkings(EntityUid target, BodyPartAppearanceComponent partAppearance, HumanoidAppearanceComponent bodyAppearance) diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index 1706e102f2f..7ea3b69de57 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -260,23 +260,15 @@ private void HideLayers(EntityUid uid, HandsComponent component, Entity HideLayers(uid, component, args.Part); - private void HandleBodyPartDisabled(EntityUid uid, HandsComponent component, ref BodyPartDisabledEvent args) - { - HideLayers(uid, component, args.Part); - } + private void HandleBodyPartDisabled(EntityUid uid, HandsComponent component, ref BodyPartDisabledEvent args) => HideLayers(uid, component, args.Part); protected override void HandleEntityInserted(EntityUid uid, HandsComponent hands, EntInsertedIntoContainerMessage args) { diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerBoundUserInterface.cs b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerBoundUserInterface.cs index 0010c281a20..39bb52d72c0 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerBoundUserInterface.cs +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerBoundUserInterface.cs @@ -38,13 +38,7 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message) _window.Populate(cast); } - private void SendBodyPartMessage(TargetBodyPart? part, EntityUid target) - { - if (part == null) - SendMessage(new HealthAnalyzerPartMessage(EntMan.GetNetEntity(target), null)); - else - SendMessage(new HealthAnalyzerPartMessage(EntMan.GetNetEntity(target), part.Value)); - } + private void SendBodyPartMessage(TargetBodyPart? part, EntityUid target) => SendMessage(new HealthAnalyzerPartMessage(EntMan.GetNetEntity(target), part ?? null)); protected override void Dispose(bool disposing) { diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs index a4e26f410af..980cea1be95 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs @@ -2,7 +2,6 @@ using System.Numerics; using Content.Client.Message; using Content.Shared.Atmos; -using Content.Shared.Body.Part; // Shitmed using Content.Client.UserInterface.Controls; using Content.Shared.Alert; using Content.Shared.Damage; @@ -90,10 +89,7 @@ public void SetActiveBodyPart(TargetBodyPart part, TextureButton button) return; // Bit of the ole shitcode until we have Groins in the prototypes. - if (part == TargetBodyPart.Groin) - OnBodyPartSelected?.Invoke(TargetBodyPart.Torso, _target.Value); - else - OnBodyPartSelected?.Invoke(part, _target.Value); + OnBodyPartSelected?.Invoke(part == TargetBodyPart.Groin ? TargetBodyPart.Torso : part, _target.Value); } public void ResetBodyPart() @@ -183,7 +179,6 @@ public void Populate(HealthAnalyzerScannedUserMessage msg) // Total Damage - DamageLabel.Text = damageable.TotalDamage.ToString(); // Alerts diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index edfab2c5ed4..053d1240578 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -184,9 +184,11 @@ public void UpdateSlot(EntityUid owner, InventorySlotsComponent component, strin public void OnRefreshInventorySlots(EntityUid owner, InventorySlotsComponent component, RefreshInventorySlotsEvent args) { - if (component.SlotData.TryGetValue(args.SlotName, out var slotData) - && _playerManager.LocalEntity == owner) - OnSlotRemoved?.Invoke(slotData); + if (!component.SlotData.TryGetValue(args.SlotName, out var slotData) + || _playerManager.LocalEntity != owner) + return; + + OnSlotRemoved?.Invoke(slotData); } public bool TryAddSlotDef(EntityUid owner, InventorySlotsComponent component, SlotDefinition newSlotDef) diff --git a/Content.Client/Medical/Surgery/SurgeryBui.cs b/Content.Client/Medical/Surgery/SurgeryBui.cs index 723cd85cdb5..a49d5ec06b3 100644 --- a/Content.Client/Medical/Surgery/SurgeryBui.cs +++ b/Content.Client/Medical/Surgery/SurgeryBui.cs @@ -3,16 +3,11 @@ using Content.Shared.Medical.Surgery; using Content.Shared.Body.Components; using Content.Shared.Body.Part; -using Content.Client.Hands.Systems; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; -using Robust.Shared.Timing; -using Robust.Client.Timing; -using static Robust.Client.UserInterface.Control; -using OpenToolkit.GraphicsLibraryFramework; namespace Content.Client.Medical.Surgery; @@ -22,35 +17,30 @@ public sealed class SurgeryBui : BoundUserInterface [Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IPlayerManager _player = default!; - [Dependency] private readonly IClientGameTiming _gameTiming = default!; - [Dependency] private readonly IGameTiming _timing = default!; - private readonly SurgerySystem _system; [ViewVariables] private SurgeryWindow? _window; - private EntityUid? _part; - private bool _isBody = false; + private bool _isBody; private (EntityUid Ent, EntProtoId Proto)? _surgery; private readonly List _previousSurgeries = new(); - public SurgeryBui(EntityUid owner, Enum uiKey) : base(owner, uiKey) - { - _system = _entities.System(); - } + public SurgeryBui(EntityUid owner, Enum uiKey) : base(owner, uiKey) => _system = _entities.System(); protected override void ReceiveMessage(BoundUserInterfaceMessage message) { - if (_window == null) + if (_window is null + || message is not SurgeryBuiRefreshMessage) return; - if (message is SurgeryBuiRefreshMessage) - RefreshUI(); + RefreshUI(); } protected override void UpdateState(BoundUserInterfaceState state) { - if (state is SurgeryBuiState s) - Update(s); + if (state is not SurgeryBuiState s) + return; + + Update(s); } protected override void Dispose(bool disposing) @@ -62,7 +52,7 @@ protected override void Dispose(bool disposing) private void Update(SurgeryBuiState state) { - if (!_entities.TryGetComponent(_player.LocalEntity, out var surgeryTargetComp) + if (!_entities.TryGetComponent(_player.LocalEntity, out SurgeryTargetComponent? surgeryTargetComp) || !surgeryTargetComp.CanOperate) return; @@ -86,32 +76,26 @@ private void Update(SurgeryBuiState state) _surgery = null; _previousSurgeries.Clear(); - if (!_entities.TryGetNetEntity(_part, out var netPart) || - State is not SurgeryBuiState s || - !s.Choices.TryGetValue(netPart.Value, out var surgeries)) - { + if (!_entities.TryGetNetEntity(_part, out var netPart) + || State is not SurgeryBuiState s + || !s.Choices.TryGetValue(netPart.Value, out var surgeries)) return; - } OnPartPressed(netPart.Value, surgeries); }; _window.StepsButton.OnPressed += _ => { - if (!_entities.TryGetNetEntity(_part, out var netPart) || - _previousSurgeries.Count == 0) - { + if (!_entities.TryGetNetEntity(_part, out var netPart) + || _previousSurgeries.Count == 0) return; - } var last = _previousSurgeries[^1]; _previousSurgeries.RemoveAt(_previousSurgeries.Count - 1); - if (_system.GetSingleton(last) is not { } previousId || - !_entities.TryGetComponent(previousId, out SurgeryComponent? previous)) - { + if (_system.GetSingleton(last) is not { } previousId + || !_entities.TryGetComponent(previousId, out SurgeryComponent? previous)) return; - } OnSurgeryPressed((previousId, previous), netPart.Value, last); }; @@ -129,7 +113,6 @@ State is not SurgeryBuiState s || var options = new List<(NetEntity netEntity, EntityUid entity, string Name, BodyPartType? PartType)>(); foreach (var choice in state.Choices.Keys) - { if (_entities.TryGetEntity(choice, out var ent)) { if (_entities.TryGetComponent(ent, out BodyPartComponent? part)) @@ -137,7 +120,6 @@ State is not SurgeryBuiState s || else if (_entities.TryGetComponent(ent, out BodyComponent? body)) options.Add((choice, ent.Value, _entities.GetComponent(ent.Value).EntityName, null)); } - } options.Sort((a, b) => { @@ -192,11 +174,10 @@ int GetScore(BodyPartType? partType) private void AddStep(EntProtoId stepId, NetEntity netPart, EntProtoId surgeryId) { - if (_window == null || - _system.GetSingleton(stepId) is not { } step) - { + if (_window == null + || _system.GetSingleton(stepId) is not { } step) return; - } + var stepName = new FormattedMessage(); stepName.AddText(_entities.GetComponent(step).EntityName); var stepButton = new SurgeryStepButton { Step = step }; @@ -237,9 +218,7 @@ private void OnSurgeryPressed(Entity surgery, NetEntity netPar _window.Steps.AddChild(new HSeparator { Margin = new Thickness(0, 0, 0, 1) }); } foreach (var stepId in surgery.Comp.Steps) - { AddStep(stepId, netPart, surgeryId); - } View(ViewType.Steps); RefreshUI(); @@ -295,11 +274,10 @@ private void RefreshUI() || !_window.IsOpen || _part == null || !_entities.HasComponent(_surgery?.Ent) - || !_entities.TryGetComponent(_player.LocalEntity ?? EntityUid.Invalid, out var surgeryComp) + || !_entities.TryGetComponent(_player.LocalEntity ?? EntityUid.Invalid, out SurgeryTargetComponent? surgeryComp) || !surgeryComp.CanOperate) - { return; - } + var next = _system.GetNextStep(Owner, _part.Value, _surgery.Value.Ent); var i = 0; foreach (var child in _window.Steps.Children) @@ -309,21 +287,13 @@ private void RefreshUI() var status = StepStatus.Incomplete; if (next == null) - { status = StepStatus.Complete; - } else if (next.Value.Surgery.Owner != _surgery.Value.Ent) - { status = StepStatus.Incomplete; - } else if (next.Value.Step == i) - { status = StepStatus.Next; - } else if (i < next.Value.Step) - { status = StepStatus.Complete; - } stepButton.Button.Disabled = status != StepStatus.Next; @@ -331,9 +301,7 @@ private void RefreshUI() stepName.AddText(_entities.GetComponent(stepButton.Step).EntityName); if (status == StepStatus.Complete) - { stepButton.Button.Modulate = Color.Green; - } else { stepButton.Button.Modulate = Color.White; @@ -367,17 +335,11 @@ private void View(ViewType type) if (_entities.TryGetComponent(_part, out MetaDataComponent? partMeta) && _entities.TryGetComponent(_surgery?.Ent, out MetaDataComponent? surgeryMeta)) - { _window.Title = $"Surgery - {partMeta.EntityName}, {surgeryMeta.EntityName}"; - } else if (partMeta != null) - { _window.Title = $"Surgery - {partMeta.EntityName}"; - } else - { _window.Title = "Surgery"; - } } private enum ViewType diff --git a/Content.Client/Targeting/TargetingSystem.cs b/Content.Client/Targeting/TargetingSystem.cs index 5f2f733a525..2c92d53ae1f 100644 --- a/Content.Client/Targeting/TargetingSystem.cs +++ b/Content.Client/Targeting/TargetingSystem.cs @@ -63,28 +63,28 @@ private void HandlePlayerDetached(EntityUid uid, TargetingComponent component, L private void OnTargetingStartup(EntityUid uid, TargetingComponent component, ComponentStartup args) { - if (_playerManager.LocalEntity == uid) - { - TargetingStartup?.Invoke(component); - PartStatusStartup?.Invoke(component); - } + if (_playerManager.LocalEntity != uid) + return; + + TargetingStartup?.Invoke(component); + PartStatusStartup?.Invoke(component); } private void OnTargetingShutdown(EntityUid uid, TargetingComponent component, ComponentShutdown args) { - if (_playerManager.LocalEntity == uid) - { - TargetingShutdown?.Invoke(); - PartStatusShutdown?.Invoke(); - } + if (_playerManager.LocalEntity != uid) + return; + + TargetingShutdown?.Invoke(); + PartStatusShutdown?.Invoke(); } private void OnTargetIntegrityChange(TargetIntegrityChangeEvent args) { if (!TryGetEntity(args.Uid, out var uid) - || !_playerManager.LocalEntity.Equals(uid) - || !TryComp(uid, out TargetingComponent? component) - || !args.RefreshUi) + || !_playerManager.LocalEntity.Equals(uid) + || !TryComp(uid, out TargetingComponent? component) + || !args.RefreshUi) return; PartStatusUpdate?.Invoke(component); diff --git a/Content.Client/UserInterface/Systems/PartStatus/Widgets/PartStatusControl.xaml.cs b/Content.Client/UserInterface/Systems/PartStatus/Widgets/PartStatusControl.xaml.cs index 0efee743349..9c13e50ed14 100644 --- a/Content.Client/UserInterface/Systems/PartStatus/Widgets/PartStatusControl.xaml.cs +++ b/Content.Client/UserInterface/Systems/PartStatus/Widgets/PartStatusControl.xaml.cs @@ -45,8 +45,6 @@ public void SetTextures(Dictionary state) } } - public void SetVisible(bool visible) - { - this.Visible = visible; - } + public void SetVisible(bool visible) => this.Visible = visible; + } diff --git a/Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml.cs b/Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml.cs index 0a9b34b0cce..07af0e8092a 100644 --- a/Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml.cs +++ b/Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml.cs @@ -42,26 +42,17 @@ public TargetingControl() TargetDoll.Texture = Theme.ResolveTexture("target_doll"); } } - private void SetActiveBodyPart(TargetBodyPart bodyPart) - { - _controller.CycleTarget(bodyPart); - } + + private void SetActiveBodyPart(TargetBodyPart bodyPart) => _controller.CycleTarget(bodyPart); public void SetBodyPartsVisible(TargetBodyPart bodyPart) { foreach (var bodyPartButton in _bodyPartControls) - { bodyPartButton.Value.Children.First().Visible = bodyPartButton.Key == bodyPart; - } } - protected override void OnThemeUpdated() - { - TargetDoll.Texture = Theme.ResolveTexture("target_doll"); - } + protected override void OnThemeUpdated() => TargetDoll.Texture = Theme.ResolveTexture("target_doll"); + + public void SetTargetDollVisible(bool visible) => Visible = visible; - public void SetTargetDollVisible(bool visible) - { - Visible = visible; - } } diff --git a/Content.Client/Xenonids/UI/XenoChoiceControl.xaml.cs b/Content.Client/Xenonids/UI/XenoChoiceControl.xaml.cs index 7a463ca0f20..ae451fffe01 100644 --- a/Content.Client/Xenonids/UI/XenoChoiceControl.xaml.cs +++ b/Content.Client/Xenonids/UI/XenoChoiceControl.xaml.cs @@ -10,10 +10,7 @@ namespace Content.Client.Xenonids.UI; [Virtual] public partial class XenoChoiceControl : Control { - public XenoChoiceControl() - { - RobustXamlLoader.Load(this); - } + public XenoChoiceControl() => RobustXamlLoader.Load(this); public void Set(string name, Texture? texture) { @@ -26,4 +23,4 @@ public void Set(FormattedMessage msg, Texture? texture) NameLabel.SetMessage(msg); Texture.Texture = texture; } -} \ No newline at end of file +} diff --git a/Content.IntegrationTests/Tests/Shitmed/Body/SpeciesBUiTest.cs b/Content.IntegrationTests/Tests/Shitmed/Body/SpeciesBUiTest.cs index 4e7b0fdac82..f82a22d4471 100644 --- a/Content.IntegrationTests/Tests/Shitmed/Body/SpeciesBUiTest.cs +++ b/Content.IntegrationTests/Tests/Shitmed/Body/SpeciesBUiTest.cs @@ -18,12 +18,10 @@ public sealed class SpeciesBUiTest parent: BaseMobSpecies "; - private Dictionary GetInterfaces(UserInterfaceComponent comp) - { - return (Dictionary) + private Dictionary GetInterfaces(UserInterfaceComponent comp) => + (Dictionary) typeof(UserInterfaceComponent).GetField("Interfaces", BindingFlags.NonPublic | BindingFlags.Instance)! .GetValue(comp); - } [Test] public async Task AllSpeciesHaveBaseBUiTest() diff --git a/Content.Server/Body/Components/BrainComponent.cs b/Content.Server/Body/Components/BrainComponent.cs index d1c10be5f49..004ff24eaff 100644 --- a/Content.Server/Body/Components/BrainComponent.cs +++ b/Content.Server/Body/Components/BrainComponent.cs @@ -1,5 +1,4 @@ using Content.Server.Body.Systems; -using Robust.Shared.GameStates; namespace Content.Server.Body.Components { diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 1c9d9d755ea..eb0c1df6526 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -152,12 +152,9 @@ public override HashSet GibPart( if (!Resolve(partId, ref part, logMissing: false) || TerminatingOrDeleted(partId) || EntityManager.IsQueuedForDeletion(partId)) - { return new HashSet(); - } - var xform = Transform(partId); - if (xform.MapUid is null) + if (Transform(partId).MapUid is null) return new HashSet(); var gibs = base.GibPart(partId, part, launchGibs: launchGibs, @@ -170,6 +167,7 @@ public override HashSet GibPart( return gibs; } + protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceComponent component) { return; @@ -178,12 +176,8 @@ protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceCo protected override void RemoveBodyMarkings(EntityUid target, BodyPartAppearanceComponent partAppearance, HumanoidAppearanceComponent bodyAppearance) { foreach (var (visualLayer, markingList) in partAppearance.Markings) - { foreach (var marking in markingList) - { _humanoidSystem.RemoveMarking(target, marking.MarkingId, sync: false, humanoid: bodyAppearance); - } - } Dirty(target, bodyAppearance); } diff --git a/Content.Server/Chemistry/ReagentEffects/HealthChange.cs b/Content.Server/Chemistry/ReagentEffects/HealthChange.cs index 24880cfd371..53933072b6d 100644 --- a/Content.Server/Chemistry/ReagentEffects/HealthChange.cs +++ b/Content.Server/Chemistry/ReagentEffects/HealthChange.cs @@ -3,6 +3,7 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using Content.Shared.Localizations; +using Content.Shared.Targeting; // Shitmed using JetBrains.Annotations; using Robust.Shared.Prototypes; using System.Linq; @@ -119,7 +120,12 @@ public override void Effect(ReagentEffectArgs args) args.SolutionEntity, Damage * scale, IgnoreResistances, - interruptsDoAfters: false); + interruptsDoAfters: false, + // Shitmed Start + targetPart: TargetBodyPart.All, + partMultiplier: 0.5f, + canSever: false); + // Shitmed End } } } diff --git a/Content.Server/Destructible/Thresholds/Behaviors/GibPartBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/GibPartBehavior.cs index 95f3a319bfe..f9e39ba8847 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/GibPartBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/GibPartBehavior.cs @@ -2,18 +2,18 @@ using Content.Shared.Body.Part; using JetBrains.Annotations; -namespace Content.Server.Destructible.Thresholds.Behaviors +namespace Content.Server.Destructible.Thresholds.Behaviors; + +[UsedImplicitly] +[DataDefinition] +public sealed partial class GibPartBehavior : IThresholdBehavior { - [UsedImplicitly] - [DataDefinition] - public sealed partial class GibPartBehavior : IThresholdBehavior + public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) { - public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) - { - if (system.EntityManager.TryGetComponent(owner, out BodyPartComponent? part)) - { - system.BodySystem.GibPart(owner, part); - } - } + if (!system.EntityManager.TryGetComponent(owner, out BodyPartComponent? part)) + return; + + system.BodySystem.GibPart(owner, part); } } + diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 539a8fee1af..8f0519b24cf 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -137,10 +137,8 @@ private void HandleBodyPartRemoved(EntityUid uid, HandsComponent component, ref RemoveHand(uid, args.Slot); } - private void HandleBodyPartEnabled(EntityUid uid, HandsComponent component, ref BodyPartEnabledEvent args) - { + private void HandleBodyPartEnabled(EntityUid uid, HandsComponent component, ref BodyPartEnabledEvent args) => TryAddHand(uid, component, args.Part, SharedBodySystem.GetPartSlotContainerId(args.Part.Comp.ParentSlot?.Id ?? string.Empty)); - } private void HandleBodyPartDisabled(EntityUid uid, HandsComponent component, ref BodyPartDisabledEvent args) { diff --git a/Content.Server/Medical/HealingSystem.cs b/Content.Server/Medical/HealingSystem.cs index 221deb4c3aa..c64bb2a485d 100644 --- a/Content.Server/Medical/HealingSystem.cs +++ b/Content.Server/Medical/HealingSystem.cs @@ -19,6 +19,7 @@ using Content.Shared.Mobs; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; +using Content.Shared.Targeting; using Content.Shared.Stacks; using Robust.Shared.Audio.Systems; using Robust.Shared.Random; @@ -85,7 +86,7 @@ entity.Comp.DamageContainerID is not null && if (healing.ModifyBloodLevel != 0) _bloodstreamSystem.TryModifyBloodLevel(entity.Owner, healing.ModifyBloodLevel); - var healed = _damageable.TryChangeDamage(entity.Owner, healing.Damage, true, origin: args.Args.User, canSever: false); + var healed = _damageable.TryChangeDamage(entity.Owner, healing.Damage, true, origin: args.User, canSever: false); if (healed == null && healing.BloodlossModifier != 0) return; @@ -120,7 +121,7 @@ entity.Comp.DamageContainerID is not null && _audio.PlayPvs(healing.HealingEndSound, entity.Owner, AudioHelpers.WithVariation(0.125f, _random).WithVolume(-5f)); // Logic to determine whether or not to repeat the healing action - args.Repeat = HasDamage(entity.Comp, healing) && !dontRepeat || ArePartsDamaged(entity); + args.Repeat = HasDamage(entity.Comp, healing) && !dontRepeat || IsPartDamaged(args.User, entity); if (!args.Repeat && !dontRepeat) _popupSystem.PopupEntity(Loc.GetString("medical-item-finished-using", ("item", args.Used)), entity.Owner, args.User); args.Handled = true; @@ -141,17 +142,17 @@ private bool HasDamage(DamageableComponent component, HealingComponent healing) return false; } - private bool ArePartsDamaged(EntityUid target) + private bool IsPartDamaged(EntityUid user, EntityUid target) { - if (!TryComp(target, out var body)) + if (!TryComp(user, out TargetingComponent? targeting)) return false; - foreach (var part in _bodySystem.GetBodyChildren(target, body)) - { + var (targetType, targetSymmetry) = _bodySystem.ConvertTargetBodyPart(targeting.Target); + foreach (var part in _bodySystem.GetBodyChildrenOfType(target, targetType, symmetry: targetSymmetry)) if (TryComp(part.Id, out var damageable) && damageable.TotalDamage > part.Component.MinIntegrity) return true; - } + return false; } @@ -193,7 +194,7 @@ targetDamage.DamageContainerID is not null && var anythingToDo = HasDamage(targetDamage, component) || - ArePartsDamaged(target) || + IsPartDamaged(user, target) || component.ModifyBloodLevel > 0 // Special case if healing item can restore lost blood... && TryComp(target, out var bloodstream) && _solutionContainerSystem.ResolveSolution(target, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution) diff --git a/Content.Server/Medical/Surgery/SurgerySystem.cs b/Content.Server/Medical/Surgery/SurgerySystem.cs index 31e62399516..615166390a3 100644 --- a/Content.Server/Medical/Surgery/SurgerySystem.cs +++ b/Content.Server/Medical/Surgery/SurgerySystem.cs @@ -127,21 +127,17 @@ private void OnToolAfterInteract(Entity ent, ref AfterInte RefreshUI(args.Target.Value); } - private void OnSurgeryStepDamage(Entity ent, ref SurgeryStepDamageEvent args) - { + private void OnSurgeryStepDamage(Entity ent, ref SurgeryStepDamageEvent args) => SetDamage(args.Body, args.Damage, args.PartMultiplier, args.User, args.Part); - } private void OnSurgeryDamageChange(Entity ent, ref SurgeryStepEvent args) { // This unintentionally punishes the user if they have an organ in another hand that is already used. // Imo surgery shouldn't let you automatically pick tools on both hands anyway, it should only use the one you've got in your selected hand. - if (ent.Comp.IsConsumable) - { - if (args.Tools.Where(tool => TryComp(tool, out var organComp) - && !_body.TrySetOrganUsed(tool, true, organComp)).Any()) - return; - } + if (ent.Comp.IsConsumable + && args.Tools.Where(tool => TryComp(tool, out var organComp) + && !_body.TrySetOrganUsed(tool, true, organComp)).Any()) + return; var damageChange = ent.Comp.Damage; if (HasComp(args.Body)) @@ -152,49 +148,42 @@ private void OnSurgeryDamageChange(Entity en private void OnSurgerySpecialDamageChange(Entity ent, ref SurgeryStepEvent args) { - if (ent.Comp.IsConsumable) - { - if (args.Tools.Where(tool => TryComp(tool, out var organComp) - && !_body.TrySetOrganUsed(tool, true, organComp)).Any()) - return; - } + if (ent.Comp.IsConsumable + && args.Tools.Where(tool => TryComp(tool, out var organComp) + && !_body.TrySetOrganUsed(tool, true, organComp)).Any()) + return; if (ent.Comp.DamageType == "Rot") - { - _rot.ReduceAccumulator(args.Body, TimeSpan.FromSeconds(2147483648)); - } - else if (ent.Comp.DamageType == "Eye") - { - if (TryComp(args.Body, out BlindableComponent? blindComp) - && blindComp.EyeDamage > 0) - _blindableSystem.AdjustEyeDamage((args.Body, blindComp), -blindComp!.EyeDamage); - } + _rot.ReduceAccumulator(args.Body, TimeSpan.FromSeconds(2147483648)); // BEHOLD, SHITCODE THAT I JUST COPY PASTED. I'll redo it at some point, pinky swear :) + else if (ent.Comp.DamageType == "Eye" + && TryComp(args.Body, out BlindableComponent? blindComp) + && blindComp.EyeDamage > 0) + _blindableSystem.AdjustEyeDamage((args.Body, blindComp), -blindComp!.EyeDamage); } private void OnStepScreamComplete(Entity ent, ref SurgeryStepEvent args) { - if (!HasComp(args.Body)) - _chat.TryEmoteWithChat(args.Body, ent.Comp.Emote); - } - private void OnStepSpawnComplete(Entity ent, ref SurgeryStepEvent args) - { - if (TryComp(args.Body, out TransformComponent? xform)) - SpawnAtPosition(ent.Comp.Entity, xform.Coordinates); + if (HasComp(args.Body)) + return; + + _chat.TryEmoteWithChat(args.Body, ent.Comp.Emote); } + private void OnStepSpawnComplete(Entity ent, ref SurgeryStepEvent args) => + SpawnAtPosition(ent.Comp.Entity, Transform(args.Body).Coordinates); private void OnPrototypesReloaded(PrototypesReloadedEventArgs args) { - if (args.WasModified()) - LoadPrototypes(); + if (!args.WasModified()) + return; + + LoadPrototypes(); } private void LoadPrototypes() { _surgeries.Clear(); foreach (var entity in _prototypes.EnumeratePrototypes()) - { if (entity.HasComponent()) _surgeries.Add(new EntProtoId(entity.ID)); - } } } diff --git a/Content.Shared/Body/Organ/MarkingContainerComponent.cs b/Content.Shared/Body/Organ/MarkingContainerComponent.cs index 8881b1e77f0..0583258dc20 100644 --- a/Content.Shared/Body/Organ/MarkingContainerComponent.cs +++ b/Content.Shared/Body/Organ/MarkingContainerComponent.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Body.Organ; [RegisterComponent, NetworkedComponent] public sealed partial class MarkingContainerComponent : Component { - [DataField("marking", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] public string Marking = default!; } diff --git a/Content.Shared/Body/Organ/OrganComponent.cs b/Content.Shared/Body/Organ/OrganComponent.cs index 442ac3f42df..c7212cbec31 100644 --- a/Content.Shared/Body/Organ/OrganComponent.cs +++ b/Content.Shared/Body/Organ/OrganComponent.cs @@ -30,5 +30,5 @@ public sealed partial class OrganComponent : Component, ISurgeryToolComponent /// If true, the organ will not heal an entity when transplanted into them. /// [DataField, AutoNetworkedField] - public bool? Used { get; set; } = false; + public bool? Used { get; set; } } diff --git a/Content.Shared/Body/Part/BodyPartComponent.cs b/Content.Shared/Body/Part/BodyPartComponent.cs index e4cf9b8e777..2a93f6aed25 100644 --- a/Content.Shared/Body/Part/BodyPartComponent.cs +++ b/Content.Shared/Body/Part/BodyPartComponent.cs @@ -72,7 +72,7 @@ public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent /// What's the max health this body part can have? /// [DataField] - public float MinIntegrity = 0; + public float MinIntegrity; /// /// Whether this body part is enabled or not. @@ -89,18 +89,18 @@ public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent /// /// How long it takes to run another self heal tick on the body part. /// - [DataField("healingTime")] + [DataField] public float HealingTime = 30; /// /// How long it has been since the last self heal tick on the body part. /// - public float HealingTimer = 0; + public float HealingTimer; /// /// How much health to heal on the body part per tick. /// - [DataField("selfHealingAmount")] + [DataField] public float SelfHealingAmount = 5; /// diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 498f19bcd1f..f309cc238c6 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -388,7 +388,7 @@ public virtual HashSet GibPart( launchImpulseVariance: GibletLaunchImpulseVariance, launchCone: splatCone); - if (TryComp(partId, out var inventory)) + if (HasComp(partId)) { foreach (var item in _inventory.GetHandOrInventoryEntities(partId)) { @@ -402,13 +402,10 @@ public virtual HashSet GibPart( private void OnProfileLoadFinished(EntityUid uid, BodyComponent component, ProfileLoadFinishedEvent args) { - if (!TryComp(uid, out var appearance) + if (!HasComp(uid) || TerminatingOrDeleted(uid)) - return; foreach (var part in GetBodyChildren(uid, component)) - { EnsureComp(part.Id); - } } } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.PartAppearance.cs b/Content.Shared/Body/Systems/SharedBodySystem.PartAppearance.cs index 8cdd881584a..50b9fb8c07e 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.PartAppearance.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.PartAppearance.cs @@ -125,10 +125,9 @@ public void ModifyMarkings(EntityUid uid, //RemovePartMarkings(uid, component, bodyAppearance); } - private void HandleState(EntityUid uid, BodyPartAppearanceComponent component, ref AfterAutoHandleStateEvent args) - { + private void HandleState(EntityUid uid, BodyPartAppearanceComponent component, ref AfterAutoHandleStateEvent args) => ApplyPartMarkings(uid, component); - } + private void OnPartAttachedToBody(EntityUid uid, BodyComponent component, ref BodyPartAttachedEvent args) { if (!TryComp(args.Part, out BodyPartAppearanceComponent? partAppearance) @@ -170,14 +169,14 @@ protected void UpdateAppearance(EntityUid target, _humanoid.SetBaseLayerColor(target, component.Type, component.Color, true, bodyAppearance); _humanoid.SetLayerVisibility(target, component.Type, true, true, bodyAppearance); + foreach (var (visualLayer, markingList) in component.Markings) { _humanoid.SetLayerVisibility(target, visualLayer, true, true, bodyAppearance); foreach (var marking in markingList) - { _humanoid.AddMarking(target, marking.MarkingId, marking.MarkingColors, false, true, bodyAppearance); - } } + Dirty(target, bodyAppearance); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index a51a72ef375..be03fa6f404 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -48,9 +48,7 @@ private void OnMapInit(Entity ent, ref MapInitEvent args) private void OnBodyPartRemove(Entity ent, ref ComponentRemove args) { if (ent.Comp.PartType == BodyPartType.Torso) - { _slots.RemoveItemSlot(ent, ent.Comp.ItemInsertionSlot); - } } private void OnBodyPartInserted(Entity ent, ref EntInsertedIntoContainerMessage args) { @@ -185,10 +183,9 @@ protected virtual void DropPart(Entity partEnt) } - private void OnAmputateAttempt(Entity partEnt, ref AmputateAttemptEvent args) - { + private void OnAmputateAttempt(Entity partEnt, ref AmputateAttemptEvent args) => DropPart(partEnt); - } + private void AddLeg(Entity legEnt, Entity bodyEnt) { if (!Resolve(bodyEnt, ref bodyEnt.Comp, logMissing: false)) @@ -286,9 +283,7 @@ private void EnablePart(Entity partEnt) // I hate having to hardcode these checks so much. if (partEnt.Comp.PartType == BodyPartType.Leg) - { AddLeg(partEnt, (partEnt.Comp.Body.Value, body)); - } if (partEnt.Comp.PartType == BodyPartType.Arm) { @@ -334,9 +329,7 @@ private void DisablePart(Entity partEnt) return; if (partEnt.Comp.PartType == BodyPartType.Leg) - { RemoveLeg(partEnt, (partEnt.Comp.Body.Value, body)); - } if (partEnt.Comp.PartType == BodyPartType.Arm) { diff --git a/Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs b/Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs index fc894854dcf..afe78a15172 100644 --- a/Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs +++ b/Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs @@ -1,9 +1,7 @@ namespace Content.Shared.Humanoid.Events; /// -/// Raised on an entity when their profile has finished being loaded +/// Raised on an entity when their profile has finished being loaded /// -public sealed class ProfileLoadFinishedEvent : EntityEventArgs -{ -} +public sealed class ProfileLoadFinishedEvent : EntityEventArgs { } diff --git a/Content.Shared/Inventory/InventoryTemplatePrototype.cs b/Content.Shared/Inventory/InventoryTemplatePrototype.cs index cc70a842314..0d900688fcc 100644 --- a/Content.Shared/Inventory/InventoryTemplatePrototype.cs +++ b/Content.Shared/Inventory/InventoryTemplatePrototype.cs @@ -59,5 +59,5 @@ public sealed partial class SlotDefinition /// /// Is this slot disabled? Could be due to severing or other reasons. /// - [DataField("disabled")] public bool Disabled = false; + [DataField] public bool Disabled; } diff --git a/Content.Shared/Medical/Surgery/Conditions/SurgeryMarkingConditionComponent.cs b/Content.Shared/Medical/Surgery/Conditions/SurgeryMarkingConditionComponent.cs index b742e6ce064..f22b1f682e2 100644 --- a/Content.Shared/Medical/Surgery/Conditions/SurgeryMarkingConditionComponent.cs +++ b/Content.Shared/Medical/Surgery/Conditions/SurgeryMarkingConditionComponent.cs @@ -10,7 +10,7 @@ public sealed partial class SurgeryMarkingConditionComponent : Component { [DataField] - public bool Inverse = false; + public bool Inverse; /// /// The marking category to check for. diff --git a/Content.Shared/Medical/Surgery/Conditions/SurgeryOrganConditionComponent.cs b/Content.Shared/Medical/Surgery/Conditions/SurgeryOrganConditionComponent.cs index 19c8df14910..c8c475f115a 100644 --- a/Content.Shared/Medical/Surgery/Conditions/SurgeryOrganConditionComponent.cs +++ b/Content.Shared/Medical/Surgery/Conditions/SurgeryOrganConditionComponent.cs @@ -11,8 +11,8 @@ public sealed partial class SurgeryOrganConditionComponent : Component public ComponentRegistry? Organ; [DataField] - public bool Inverse = false; + public bool Inverse; [DataField] - public bool Reattaching = false; + public bool Reattaching; } \ No newline at end of file diff --git a/Content.Shared/Medical/Surgery/Conditions/SurgeryPartConditionComponent.cs b/Content.Shared/Medical/Surgery/Conditions/SurgeryPartConditionComponent.cs index 5941e2fba3a..08a89eb9e1b 100644 --- a/Content.Shared/Medical/Surgery/Conditions/SurgeryPartConditionComponent.cs +++ b/Content.Shared/Medical/Surgery/Conditions/SurgeryPartConditionComponent.cs @@ -13,5 +13,5 @@ public sealed partial class SurgeryPartConditionComponent : Component public BodyPartSymmetry? Symmetry; [DataField] - public bool Inverse = false; + public bool Inverse; } \ No newline at end of file diff --git a/Content.Shared/Medical/Surgery/Effects/Step/SurgeryDamageChangeEffectComponent.cs b/Content.Shared/Medical/Surgery/Effects/Step/SurgeryDamageChangeEffectComponent.cs index 646276bbeb4..0db43011a08 100644 --- a/Content.Shared/Medical/Surgery/Effects/Step/SurgeryDamageChangeEffectComponent.cs +++ b/Content.Shared/Medical/Surgery/Effects/Step/SurgeryDamageChangeEffectComponent.cs @@ -13,5 +13,5 @@ public sealed partial class SurgeryDamageChangeEffectComponent : Component public float SleepModifier = 0.5f; [DataField] - public bool IsConsumable = false; + public bool IsConsumable; } \ No newline at end of file diff --git a/Content.Shared/Medical/Surgery/Effects/Step/SurgerySpecialDamageChangeEffectComponent.cs b/Content.Shared/Medical/Surgery/Effects/Step/SurgerySpecialDamageChangeEffectComponent.cs index 823db704472..e375865277f 100644 --- a/Content.Shared/Medical/Surgery/Effects/Step/SurgerySpecialDamageChangeEffectComponent.cs +++ b/Content.Shared/Medical/Surgery/Effects/Step/SurgerySpecialDamageChangeEffectComponent.cs @@ -10,5 +10,5 @@ public sealed partial class SurgerySpecialDamageChangeEffectComponent : Componen public string DamageType = ""; [DataField] - public bool IsConsumable = false; + public bool IsConsumable; } \ No newline at end of file