mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Salvage / Borg Tweaks (#2145)
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Originally started because I wanted to add some stuff to salvage, but ended up with me porting over whitelisted borg hands, the PKA module, and some other stuff. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Engi borgs can now carry electronics, and medical borgs can carry organs - add: Salvage borgs now get a PKA module - tweak: All mining drills have had their damage turned to piercing and have received a moderate damage buff - tweak: Exosuit drills now swing at the same speed as normal drills (why were they worse???) - tweak: The RPD and RCD modules for borg have been merged into one - tweak: Salvage can now purchase drills from their vendor - tweak: Salvage borgs mining module no longer contains a shovel --------- Co-authored-by: Your Name <EctoplasmIsGood@users.noreply.github.com> Co-authored-by: Whatstone <whatston3@gmail.com> Co-authored-by: RatherUncreative <RatherUncreativeName@proton.me> Co-authored-by: Aidenkrz <aiden@djkraz.com> (cherry picked from commit ed8850e551bd9c0d533d69cad262a8743442a62a)
This commit is contained in:
committed by
Spatison
parent
1ae1e9f913
commit
9a65bedfc4
@@ -59,23 +59,27 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
// Machine parts cannot currently satisfy stack/component/tag restrictions. Similarly stacks cannot satisfy
|
||||
// component/tag restrictions. However, there is no reason this cannot be supported in the future. If this
|
||||
// changes, then RegenerateProgress() also needs to be updated.
|
||||
//
|
||||
// If this changes in the future, then RegenerateProgress() also needs to be updated.
|
||||
// Note that one entity is ALLOWED to satisfy more than one kind of component or tag requirements. This is
|
||||
// necessary in order to avoid weird entity-ordering shenanigans in RegenerateProgress().
|
||||
var stack = CompOrNull<StackComponent>(args.Used);
|
||||
var machinePart = CompOrNull<MachinePartComponent>(args.Used);
|
||||
if (stack != null && machinePart != null)
|
||||
{
|
||||
if (TryInsertPartStack(uid, args.Used, component, machinePart, stack))
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle parts
|
||||
if (TryComp<MachinePartComponent>(args.Used, out var machinePart))
|
||||
if (machinePart != null)
|
||||
{
|
||||
if (TryInsertPart(uid, args.Used, component, machinePart))
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle stacks
|
||||
if (TryComp<StackComponent>(args.Used, out var stack))
|
||||
if (stack != null)
|
||||
{
|
||||
if (TryInsertStack(uid, args.Used, component, stack))
|
||||
args.Handled = true;
|
||||
@@ -191,6 +195,44 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <returns>Whether or not the function had any effect. Does not indicate success.</returns>
|
||||
private bool TryInsertPartStack(EntityUid uid, EntityUid used, MachineFrameComponent component, MachinePartComponent machinePart, StackComponent stack)
|
||||
{
|
||||
if (!component.Requirements.ContainsKey(machinePart.PartType))
|
||||
return false;
|
||||
|
||||
var progress = component.Progress[machinePart.PartType];
|
||||
var requirement = component.Requirements[machinePart.PartType];
|
||||
|
||||
var needed = requirement - progress;
|
||||
if (needed <= 0)
|
||||
return false;
|
||||
|
||||
var count = stack.Count;
|
||||
if (count < needed)
|
||||
{
|
||||
if (!_container.Insert(used, component.PartContainer))
|
||||
return true;
|
||||
|
||||
component.Progress[machinePart.PartType] += count;
|
||||
return true;
|
||||
}
|
||||
|
||||
var splitStack = _stack.Split(used, needed, Transform(uid).Coordinates, stack);
|
||||
|
||||
if (splitStack == null)
|
||||
return false;
|
||||
|
||||
if (!_container.Insert(splitStack.Value, component.PartContainer))
|
||||
return true;
|
||||
|
||||
component.Progress[machinePart.PartType] += needed;
|
||||
if (IsComplete(component))
|
||||
_popupSystem.PopupEntity(Loc.GetString("machine-frame-component-on-complete"), uid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <returns>Whether or not the function had any effect. Does not indicate success.</returns>
|
||||
private bool TryInsertStack(EntityUid uid, EntityUid used, MachineFrameComponent component, StackComponent stack)
|
||||
{
|
||||
@@ -328,8 +370,6 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
{
|
||||
if (TryComp<MachinePartComponent>(part, out var machinePart))
|
||||
{
|
||||
DebugTools.Assert(!HasComp<StackComponent>(part));
|
||||
|
||||
// Check this is part of the requirements...
|
||||
if (!component.Requirements.ContainsKey(machinePart.PartType))
|
||||
continue;
|
||||
@@ -338,7 +378,6 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
component.Progress[machinePart.PartType] = 1;
|
||||
else
|
||||
component.Progress[machinePart.PartType]++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user