Skip to content

Commit

Permalink
Merge branch 'Rxup:master' into AccessWeaponBlockerComp
Browse files Browse the repository at this point in the history
  • Loading branch information
CatBackGround authored Dec 7, 2024
2 parents 7e8c070 + 189d4a1 commit cd3c7d6
Show file tree
Hide file tree
Showing 67 changed files with 1,274 additions and 675 deletions.
10 changes: 0 additions & 10 deletions Content.Client/Inventory/ClientInventorySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public override void Initialize()

SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InventorySlotsComponent, RefreshInventorySlotsEvent>(OnRefreshInventorySlots);
SubscribeLocalEvent<InventoryComponent, ComponentShutdown>(OnShutdown);

SubscribeLocalEvent<InventorySlotsComponent, DidEquipEvent>((_, comp, args) =>
Expand Down Expand Up @@ -182,15 +181,6 @@ public void UpdateSlot(EntityUid owner, InventorySlotsComponent component, strin
EntitySlotUpdate?.Invoke(newData);
}

public void OnRefreshInventorySlots(EntityUid owner, InventorySlotsComponent component, RefreshInventorySlotsEvent args)
{
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)
{
SlotData newSlotData = newSlotDef; //convert to slotData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public DefaultGameScreen()

Chat.OnResized += ChatOnResized;
Chat.OnChatResizeFinish += ChatOnResizeFinish;

MainViewport.OnResized += ResizeActionContainer;
MainViewport.OnResized += ResizeAlertsContainer;
Inventory.OnResized += ResizeActionContainer;
}

Expand All @@ -37,6 +37,12 @@ private void ResizeActionContainer()
Actions.ActionsContainer.MaxGridHeight = MainViewport.Size.Y - indent;
}

private void ResizeAlertsContainer()
{
float indent = Chat.Size.Y + Targeting.Size.Y + 120;
Alerts.AlertContainer.MaxGridHeight = Math.Max(MainViewport.Size.Y - indent, 1);
}

private void ChatOnResizeFinish(Vector2 _)
{
var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MinSize="64 64">
<GridContainer Columns="1" HorizontalAlignment="Right" VerticalAlignment="Top">
<PanelContainer >
<BoxContainer Name="AlertContainer" Access="Public" Orientation="Vertical" />
<GridContainer Name="AlertContainer" Columns="1" HorizontalAlignment="Right" VerticalAlignment="Center" Access="Public" />
</PanelContainer>
<partStatus:PartStatusControl Name="PartStatus" Access="Protected"/>
</GridContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed partial class AlertsUI : UIWidget
public AlertsUI()
{
RobustXamlLoader.Load(this);
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
}

public void SyncControls(AlertsSystem alertsSystem,
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public override void Update(float frameTime)
if (pressure <= Atmospherics.HazardLowPressure)
{
// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true, false, canSever: false); // backmen
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true, false, canSever: false, partMultiplier: 0.5f); // backmen
if (!barotrauma.TakingDamage)
{
barotrauma.TakingDamage = true;
Expand All @@ -252,7 +252,7 @@ public override void Update(float frameTime)
var damageScale = MathF.Min(((pressure / Atmospherics.HazardHighPressure) - 1) * Atmospherics.PressureDamageCoefficient, Atmospherics.MaxHighPressureDamage);

// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true, false, canSever: false); // backmen
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true, false, canSever: false, partMultiplier: 0.5f); // backmen
RaiseLocalEvent(uid, new MoodEffectEvent("MobHighPressure")); // backmen: mood

if (!barotrauma.TakingDamage)
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Backmen/Blob/BlobObserverSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,15 @@ private void OnChemSelected(EntityUid uid, BlobObserverComponent component, Blob
{
if (component.Core == null || !TryComp<BlobCoreComponent>(component.Core.Value, out var blobCoreComponent))
return;

if (component.SelectedChemId == args.SelectedId)
return;

if (!_blobCoreSystem.TryUseAbility(component.Core.Value, blobCoreComponent.SwapChemCost))
return;

if (!ChangeChem(uid, args.SelectedId, component))
return;

_blobCoreSystem.TryUseAbility(component.Core.Value, blobCoreComponent.SwapChemCost);
}

private bool ChangeChem(EntityUid uid, BlobChemType newChem, BlobObserverComponent component)
Expand Down
46 changes: 29 additions & 17 deletions Content.Server/Backmen/Surgery/SurgerySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Content.Shared.Backmen.Surgery.Tools;
using Content.Shared.Bed.Sleep;
using Content.Shared.Medical.Surgery;
using Content.Shared.Verbs;

namespace Content.Server.Backmen.Surgery;

Expand All @@ -42,7 +43,7 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SurgeryToolComponent, AfterInteractEvent>(OnToolAfterInteract);
SubscribeLocalEvent<SurgeryToolComponent, GetVerbsEvent<UtilityVerb>>(OnUtilityVerb);
SubscribeLocalEvent<SurgeryTargetComponent, SurgeryStepDamageEvent>(OnSurgeryStepDamage);
// You might be wondering "why aren't we using StepEvent for these two?" reason being that StepEvent fires off regardless of success on the previous functions
// so this would heal entities even if you had a used or incorrect organ.
Expand Down Expand Up @@ -101,30 +102,41 @@ private void SetDamage(EntityUid body,
targetPart: _body.GetTargetBodyPart(partComp));
}

private void OnToolAfterInteract(Entity<SurgeryToolComponent> ent, ref AfterInteractEvent args)
private void AttemptStartSurgery(Entity<SurgeryToolComponent> ent, EntityUid user, EntityUid target)
{
var user = args.User;
if (args.Handled
|| !args.CanReach
|| args.Target == null
|| !HasComp<SurgeryTargetComponent>(args.Target)
|| !TryComp<SurgeryTargetComponent>(args.User, out var surgery)
|| !surgery.CanOperate
|| !IsLyingDown(args.Target.Value, args.User))
{
if (!IsLyingDown(target, user))
return;
}

if (user == args.Target && !_config.GetCVar(Shared.Backmen.CCVar.CCVars.CanOperateOnSelf))
if (user == target && !_config.GetCVar(Shared.Backmen.CCVar.CCVars.CanOperateOnSelf))
{
_popup.PopupEntity(Loc.GetString("surgery-error-self-surgery"), user, user);
return;
}

args.Handled = true;
_ui.OpenUi(args.Target.Value, SurgeryUIKey.Key, user);
Log.Debug("UI opened");
RefreshUI(args.Target.Value);
_ui.OpenUi(target, SurgeryUIKey.Key, user);
RefreshUI(target);
}

private void OnUtilityVerb(Entity<SurgeryToolComponent> ent, ref GetVerbsEvent<UtilityVerb> args)
{
if (!args.CanInteract
|| !args.CanAccess
|| !HasComp<SurgeryTargetComponent>(args.Target))
return;

var user = args.User;
var target = args.Target;

var verb = new UtilityVerb()
{
Act = () => AttemptStartSurgery(ent, user, target),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Specific/Medical/Surgery/scalpel.rsi/"), "scalpel"),
Text = Loc.GetString("surgery-verb-text"),
Message = Loc.GetString("surgery-verb-message"),
DoContactInteraction = true
};

args.Verbs.Add(verb);
}

private void OnSurgeryStepDamage(Entity<SurgeryTargetComponent> ent, ref SurgeryStepDamageEvent args) =>
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Body/Commands/AddHandCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
if (attachAt == default)
attachAt = bodySystem.GetBodyChildren(entity, body).First();

var slotId = part.GetHashCode().ToString();
// Shitmed Change Start
var slotId = $"{part.Symmetry.ToString().ToLower()} {part.GetHashCode().ToString()}";
part.SlotId = part.GetHashCode().ToString();
// Shitmed Change End

if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, hand, BodyPartType.Hand, attachAt.Component, part))
{
Expand Down
9 changes: 8 additions & 1 deletion Content.Server/Body/Commands/AttachBodyPartCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,15 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var slotId = $"AttachBodyPartVerb-{partUid}";
// Shitmed Change Start
var slotId = "";
if (part.Symmetry != BodyPartSymmetry.None)
slotId = $"{part.Symmetry.ToString().ToLower()} {part.GetHashCode().ToString()}";
else
slotId = $"{part.GetHashCode().ToString()}";

part.SlotId = part.GetHashCode().ToString();
// Shitmed Change End
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (body.RootContainer.ContainedEntity != null)
{
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Medical/DefibrillatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Server.PowerCell;
using Content.Server.Traits.Assorted;
using Content.Shared.Backmen.Chat;
using Content.Shared.Backmen.Targeting;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Interaction;
Expand Down Expand Up @@ -201,7 +202,7 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo
else
{
if (_mobState.IsDead(target, mob))
_damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid);
_damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid, targetPart: TargetBodyPart.Torso); // backmen: surgery

if (_mobThreshold.TryGetThresholdForState(target, MobState.Dead, out var threshold) &&
TryComp<DamageableComponent>(target, out var damageableComponent) &&
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?

var hitName = ToPrettyString(hitEntity);
if (dmg != null)
dmg = Damageable.TryChangeDamage(hitEntity, dmg, origin: user);
dmg = Damageable.TryChangeDamage(hitEntity, dmg, origin: user, canEvade: true); // backmen: surgery

// check null again, as TryChangeDamage returns modified damage values
if (dmg != null)
Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/Backmen/Magic/BkmMagicSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Backmen.Magic.Events;
using Content.Shared.Backmen.Targeting;
using Content.Shared.Body.Components;
using Content.Shared.Damage;

Expand All @@ -22,6 +23,6 @@ private void OnHealSpell(HealSpellEvent ev)
if (!HasComp<BodyComponent>(ev.Target))
return;

DamageableSystem.TryChangeDamage(ev.Target, ev.HealAmount, true, origin: ev.Target);
DamageableSystem.TryChangeDamage(ev.Target, ev.HealAmount, true, origin: ev.Target, targetPart: TargetBodyPart.All); // backmen: surgery
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Backmen/Standing/SharedLayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ standingState.CurrentState is not StandingState.Lying ||
obj.Value,
uid,
PopupType.MediumCaution);
_damageable.TryChangeDamage(uid, new DamageSpecifier(){DamageDict = {{"Blunt", 5}}}, ignoreResistances: true, canEvade: true, targetPart: TargetBodyPart.Head);
_damageable.TryChangeDamage(uid, new DamageSpecifier(){DamageDict = {{"Blunt", 5}}}, ignoreResistances: true, canEvade: false, canSever: false, targetPart: TargetBodyPart.Head);
_stun.TryStun(uid, TimeSpan.FromSeconds(2), true);
_audioSystem.PlayPredicted(_bonkSound, uid, obj.Value);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,4 @@ public sealed partial class BodyPartAppearanceComponent : Component
/// </summary>
[DataField, AutoNetworkedField]
public Color? EyeColor { get; set; }

[DataField, AutoNetworkedField]
public EntityUid? OriginalBody { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ private void OnPartAppearanceStartup(EntityUid uid, BodyPartAppearanceComponent

return;

if (part.OriginalBody == null
|| TerminatingOrDeleted(part.OriginalBody.Value)
|| !TryComp(part.OriginalBody.Value, out HumanoidAppearanceComponent? bodyAppearance))
if (part.BaseLayerId != null)
{
component.ID = part.BaseLayerId;
component.Type = relevantLayer;
return;
}

if (part.Body is not { Valid: true } body
|| !TryComp(body, out HumanoidAppearanceComponent? bodyAppearance))
return;

var customLayers = bodyAppearance.CustomBaseLayers;
var spriteLayers = bodyAppearance.BaseLayers;
component.Type = relevantLayer;
component.OriginalBody = part.OriginalBody.Value;

part.Species = bodyAppearance.Species;

Expand Down
18 changes: 7 additions & 11 deletions Content.Shared/Backmen/Surgery/Body/SharedBodySystem.Targeting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Content.Shared.Backmen.Surgery.Steps.Parts;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;

// ReSharper disable once CheckNamespace
namespace Content.Shared.Body.Systems;
Expand Down Expand Up @@ -140,7 +141,7 @@ private void OnTryChangePartDamage(Entity<BodyComponent> ent, ref TryChangePartD
else if (args.Origin.HasValue && _queryTargeting.TryComp(args.Origin.Value, out var targeter))
{
targetPart = targeter.Target;
// If the target is Torso then have a 33% chance to hit another part
// If the target is Torso then have a 33% chance to also hit another part
if (targetPart.Value == TargetBodyPart.Torso)
{
var additionalPart = GetRandomPartSpread(_random, 10);
Expand Down Expand Up @@ -181,23 +182,20 @@ private void OnBodyDamageModify(Entity<BodyComponent> bodyEnt, ref DamageModifyE
if (args.TargetPart != null)
{
var (targetType, _) = ConvertTargetBodyPart(args.TargetPart.Value);
args.Damage = args.Damage * GetPartDamageModifier(targetType);
args.Damage *= GetPartDamageModifier(targetType);
}
}

private void OnPartDamageModify(Entity<BodyPartComponent> partEnt, ref DamageModifyEvent args)
{
if (partEnt.Comp.Body != null
&& TryComp(partEnt.Comp.Body.Value, out DamageableComponent? damageable)
&& damageable.DamageModifierSetId != null
&& _prototypeManager.TryIndex<DamageModifierSetPrototype>(damageable.DamageModifierSetId, out var modifierSet))
// TODO: We need to add a check to see if the given armor covers this part to cancel or not.
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, modifierSet);
&& TryComp(partEnt.Comp.Body.Value, out InventoryComponent? inventory))
_inventory.RelayEvent((partEnt.Comp.Body.Value, inventory), ref args);

if (_prototypeManager.TryIndex<DamageModifierSetPrototype>("PartDamage", out var partModifierSet))
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, partModifierSet);

args.Damage = args.Damage * GetPartDamageModifier(partEnt.Comp.PartType);
args.Damage *= GetPartDamageModifier(partEnt.Comp.PartType);
}

private bool TryChangePartDamage(EntityUid entity,
Expand Down Expand Up @@ -259,12 +257,10 @@ private void OnDamageChanged(Entity<BodyPartComponent> partEnt, ref DamageChange
/// <summary>
/// Gets the random body part rolling a number between 1 and 9, and returns
/// Torso if the result is 9 or more. The higher torsoWeight is, the higher chance to return it.
/// By default, the chance to return Torso is 50%.
/// </summary>
private static TargetBodyPart GetRandomPartSpread(IRobustRandom random, ushort torsoWeight = 9)
{
const int targetPartsAmount = 9;
// 5 = amount of target parts except Torso
return random.Next(1, targetPartsAmount + torsoWeight) switch
{
1 => TargetBodyPart.Head,
Expand Down Expand Up @@ -300,7 +296,7 @@ private static TargetBodyPart GetRandomPartSpread(IRobustRandom random, ushort t

/// This should be called after body part damage was changed.
/// </summary>
protected void CheckBodyPart(
public void CheckBodyPart(
Entity<BodyPartComponent> partEnt,
TargetBodyPart? targetPart,
bool severed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ private void CreatePart(EntityUid uid, GenerateChildPartComponent component)
component.Active = true;
Dirty(childPart, childPartComp);
}

_bodySystem.ChangeSlotState((uid, partComp), false);
}

// Still unusued, gotta figure out what I want to do with this function outside of fuckery with mantis blades.
Expand All @@ -60,7 +58,7 @@ private void DeletePart(EntityUid uid, GenerateChildPartComponent component)
if (!TryComp(uid, out BodyPartComponent? partComp))
return;

_bodySystem.ChangeSlotState((uid, partComp), true);
_bodySystem.DropSlotContents((uid, partComp));
var ev = new BodyPartDroppedEvent((uid, partComp));
RaiseLocalEvent(uid, ref ev);
QueueDel(uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class SurgeryDamageChangeEffectComponent : Component
public DamageSpecifier Damage = default!;

[DataField]
public float SleepModifier = 0.5f;
public float SleepModifier = 1.5f;

[DataField]
public bool IsConsumable;
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Backmen/Surgery/SanitizedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.Backmen.Surgery;

/// <summary>
/// Prevents the entity from causing toxin damage to entities it does surgery on.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SanitizedComponent : Component { }
Loading

0 comments on commit cd3c7d6

Please sign in to comment.