Commit Graph

39 Commits

Author SHA1 Message Date
SmArtKar
3d1a54e129 Moves material item insertion to right click for material containers (#90188)
## About The Pull Request

Inserting material (i.e. made from a material, but not a material
sheet/stack) items into material containers/remotes (ore silos,
autolathes, protolathes, etc) now uses right click instead of left
click. You still insert sheets using left click.

## Why It's Good For The Game

Its super easy to end up having your guns (which are made out of iron)
or armor (also made out of armor) or disks (also made out of iron) eaten
by an autolathe as you try to click a table next to it. This should
resolve players' frustrations while keeping material item insertion an
option via right clicking.

## Changelog
🆑
qol: Moved material item insertion to right click for material
containers
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2025-03-24 14:01:43 +00:00
Ghom
7a2927b288 Autolathes now accept alloys without disassembling them into their components (#90086)
## About The Pull Request
Custom material designs cannot be printed with plasteel and other alloys
because of this small issue. This should fix it.

## Why It's Good For The Game
See above.

## Changelog

🆑
fix: Custom material toolboxes and fishing rods can now be printed with
alloys such a plasteel and plasmaglass.
/🆑
2025-03-21 14:02:38 +01:00
SmArtKar
336d978d4a Autholathes and some misc material containers no longer gluttonously consume players' tools (#89900)
## About The Pull Request
Converted autolathes, drone dispensers, sheetifiers and recyclers to
tool_acts, and autolathes now use base_item_interaction similarly to
flatpackers to avoid the ire of material containers. Material containers
also now refuse to accept materials if the owner is a machine which is
broken or has an open panel.

## Why It's Good For The Game

Autolathe ate my multitool one too many times, can't have shit in space
detroit.

There's been a ton of feedback on autolathes having bad UX and #89859
kinda pushed me over the edge, its just far too confusing to deal with -
now they should be up to parity with protolathes (tools don't get eaten
on left click anymore)

## Changelog
🆑
fix: You no longer can insert sheets into unpowered, broken or opened
autolathes.
qol: Screwdriver/crowbar/multitool interactions on autolathes now work
with left click instead of right click.
/🆑
2025-03-16 18:28:21 +00:00
Penelope Haze
4c2a76ede3 Fix a large number of typos (#89254)
Fixes a very large number of typos. A few of these fixes also extend to
variable names, but only the really egregious ones like "concious".
2025-01-28 22:16:16 +01:00
SyncIt21
2f8acae66b Improves code for remote materials (#87870)
## About The Pull Request
- Moves remote materials attack chain to item interaction level. Another
step in moving away from `attackby()`
- Fixes #40070. Though the timer subsystem maybe affected by FPS, round
start trigger is always done after everything is set up which is now
used by remote materials

## Changelog
🆑
fix: silo connection on some machines won't time out when changing FPS
settings
code: improved attack chain code for silo connection
/🆑
2024-11-14 01:25:53 +01:00
SyncIt21
26343e0e24 Improves code for recycling circuits in component printer (#87787) 2024-11-10 15:06:40 +01:00
SyncIt21
94ff0ada00 Moves material container attack to item interaction level (#87676)
## About The Pull Request
- Fixes #87664

storage hooks onto pre attack whereas the material container uses
attackby so the storage component was intercepting the bananium before
the material container could consume it.

This also ends the attack chain early so optimization

## Changelog
🆑
fix: MK honk shoes now consume bananium & can clown again
code: material container objects end their attack chain early
/🆑
2024-11-08 03:22:48 +01:00
Ghom
cdebe98a17 refactoring how materials effects are added to atoms (#86901)
## About The Pull Request
I'm "cooking" the materials system a bit, specifically the code
responsible for applying and removing effects. My goal is to move most
of the code to the objects-side, split it in smaller procs that can be
more easily overriden or called for object-specific modifiers and
effects, while also revamping things all around to better support items
made from multiple materials (the cleric mace will most likely be one in
this PR, with the handle and tip made of different materials).

PR NO LONGER WIP, TESTED AND ALL, CLERIC MACES CAN NOW BE MADE OF TWO
MATERIALS.

## Why It's Good For The Game
One of the nastiest flaws with the materials system is that it's just
unfeasable to have items made of multiple mats (with effects enabled)
right now, as they easily tend to override each other, where some of the
modifiers and effects should only be applied the main material.

Beside, the system's starting to show signs of its time, from the
several type checks used to apply different effects, the one letter
variables to the the material flags that are still being passed down as
arguments when you can access them from the atom/source arg anyway. It
would be disonhest of me if I went ahead and coded material fishing rods
or whatever fish fuckery with materials without ensuring it won't
further the technical debt the feature currently has.

## Changelog
🆑
refactor: Refactored materials code. report any issue.
add: Cleric maces (The autolathe-printable weapon design from outer
space) can now be made of two different materials.
balance: Buffed cleric maces a little.
fix: toolboxes' stats are now affected by materials again.
/🆑

---------

Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
2024-10-06 21:56:20 +02:00
klorpa
e1bf793264 Spelling and Grammar Fixes (#86022)
## About The Pull Request
Fixes several errors to spelling, grammar, and punctuation.
## Why It's Good For The Game
## Changelog
🆑
spellcheck: fixed a few typos
/🆑
2024-08-23 21:49:46 +02:00
SmArtKar
f985856a09 Circuit components can now be recycles in circuit printers, and automatically do so upon being removed if a circuit has a linked printer (#85648)
## About The Pull Request

Added support for remote material insertion type whitelists and utilized
it to allow circuit printers to recycle components. Removing a component
from UI while the circuit has a linked printer will automatically
recycle it.

Also fixed a rogue space appearing when recycling a single item

## Why It's Good For The Game

You literally cannot do anything with components you remove/do not need
anymore so usually they end up littering circuit lab's floors. This
should make developing circuits slightly less annoying.

## Changelog
🆑
qol: Circuit components can now be recycles in circuit printers, and
automatically do so upon being removed if a circuit has a linked printer
spellcheck: Recycling a single item no longer outputs a line with a
rogue space infront of it
/🆑
2024-08-14 13:12:57 +02:00
SyncIt21
e4015a6f7f Remote materials don't block multitool on failure (#84797)
## About The Pull Request
- Fixes #84794

`/datum/component/remote_materials` blocks the tool act from continuing
when linking with ore silo fails. We don't want that for stacking
machines

## Changelog
🆑
fix: stacking machines can be linked with its console via multitool
/🆑
2024-07-09 16:03:41 -06:00
SyncIt21
a71ecee6f9 Makes the omnitool lathe proof (#84643)
## About The Pull Request
- Fixes #84600

As mentioned in
https://github.com/tgstation/tgstation/issues/84600#issuecomment-2204975628
there is no problem with omnitool & airlock interactions, but just with
the lathe consuming the omnitool.


## Changelog
🆑
fix: Autolathe won't eat the borg omni tool
/🆑
2024-07-05 20:00:25 +02:00
SyncIt21
e4c5c2fc2a Allows for proxy atoms in object melee attack chain (#83860)
## About The Pull Request
1. Objects now have an `get_proxy_for()` proc. This returns an atom that
will participate in the object melee attack chain on behalf of your
atom. Allows for general purpose polymorphism per object interaction
2. Cleaned up some multitool acts to accommodate proxy behaviour
3. You can pry tiles as an Engiborg with crowbar in hand & do other
similar behaviour with crowbar
5. Improves & Depends on #83880. We don't need a hidden omni toolbox &
can create the tools directly in the omnitool and pass them in the
attack chain as a proxy rather than calling the attack chain manually.
All tools are on the borg directly
   - Fixes #84355
   - Fixes #84359
   - Fixes #84393

## Changelog 
SyncIt21,zxaber
🆑
fix: omni crowbar tool interaction for replacing tiles has been fixed 
fix: techfab screentip does not runtime when you hover over it with an
omnitool multitool
fix: medi borgs can do brain surgery again
code: improved multitool & general tool code for some machines
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2024-07-03 15:47:18 -07:00
SyncIt21
0a5f2c9a69 Some material container patches (#84553)
## About The Pull Request
- Fixes #84517. material container won't consume the contents of an item
if that item itself is rejected for any reason(lack of mats, not
suitable for redemption etc)
- You can use any storage medium (not just bags, boxes but anything that
has `atom_storage`) to dump stuff into an material container

## Changelog
🆑
fix: material container won't consume the contents of an item if that
item itself is rejected for any reason
qol: you can use any storage medium & not just bags/boxes to dump stuff
into material containers
/🆑
2024-07-03 11:41:50 -04:00
Mothblocks
bc4e7d3b4e Remove data systems in favor of global datums (#82943) 2024-04-29 22:47:36 -07:00
Jeremiah
c1a775efe1 Implements data systems (#82816)
## About The Pull Request
Subsystems currently come in two different flavors:
1. Systems that process at intervals with the master controller
2. Global data containers that do not fire

And I think they should be split up...


This moves 4 non firing, non init subsytems -> datasystem

## Why It's Good For The Game
Clarity in code
2024-04-22 21:27:15 -06:00
Jacquerel
6596d75edc Gulag Adjustments Two (#82561)
## About The Pull Request

I have received feedback that after the prior changes in #81971, the
gulag is still a little bit too subject to RNG.
The main culprit (as in my previous PR) is Iron being kind of cheap and
the fact that unlike the old Gulag you no longer have any way of
headhunting more valuable materials (everything appears as boulders on
your ore scanner).

My solution to this is wider than the last one of tweaking point values,
but also much simpler:
Just make every boulder you mine be worth the same amount of points
regardless of what is inside of it.

On the average test I made I could comfortably mine about 40-45 boulders
in ten minutes.
We'll make some adjustments to that rather than leaving 40 as the target
number;
Most players upon being teleported to the gulag are going to spend a few
minutes whining and bemoaning their fate instead of getting straight to
work. I had the benefit of being able to make sure my run started as
soon as a storm ended so I wouldn't need any kind of midpoint break. I
was also always the only person playing on my local instance, there
hadn't been any other pesky prisoners before me who had already mined
out all the nearest available deposits. And of course, let us not
forget, I am an MLG master league ss13 player who was surely performing
well above average.

So we'll round that down to: Each boulder is worth 33 points, meaning
you need to collect 31 boulders to complete a 1000 point (roughly ten
minute) sentence.

How do I ensure that every boulder is worth the same amount of points?
Well it's pretty easy.
One boulder = one material sheet. One material sheet = 33 points.
Simple.

"Now Jacquerel", I hear you not saying because you don't want me to know
about this thing you would prefer to do instead of hitting rocks
outside; "if I simply smash all of the tables and microwaves and botany
trays and bed in the gulag I can easily get like 65 sheets of Iron,
which is almost enough to buy the freedom for two entire people!"
Unfortunately I knew you were going to try and do that and the prisoner
point machine will only give you points for material sheets which have
been printed from the material smelter (well, any material smelter
actually but you should probably use the one in the gulag). You'll be
able to tell because if you examine a valid material sheet it will
mention a little maker's mark on it, which is absent in the beat-up iron
that you get from smashing furniture to bits.

Also glass is worth 0 points. Don't waste time digging up that shit. 

As glass has had all of its point value removed, I have added a "work
pit" to the gulag to compensate. You can pull boulders out of this
indefinitely via effort, however it also stamcrits you every time.
It's not very fun to do this, but that's because I would prefer you to
go find the rocks out in the field instead. This is a last resort.
You can do this if there's no boulders left to mine or if you really
really really hate mining and would rather very slowly click on one tile
repeatedly to get your boulders instead.
As a tiny bonus doing this gives workout experience.

This isn't a totally ideal solution but I think it'll do for now.

## Why It's Good For The Game

What we want out of the gulag is:
- Something where officers can vaguely approximate an expected sentence
duration.
- A task that requires players to actually be spending that time doing
something to get out of here.
- Produces at least some amount of useful materials.

In I think roughly that order.
I hope this change accomplishes all three of these in a way that is
somewhat predictable rather than throwing darts at a board.

## Changelog

🆑
balance: Gulag mining has been rebalanced so that every boulder is worth
the same amount of points to mine for a prisoner regardless of what it
contains, and should be more consistent.
add: A vent which boulders can be hauled out of by hand has been added
to the gulag which you can use if there's nothing left to mine. It is
very slow, but at least it gives you a workout...
/🆑
2024-04-18 17:05:06 +02:00
san7890
c403a6eccc Wraps lowertext() to ensure proper stringification. (#82442)
## About The Pull Request

Fixes #82440

This PR just creates a new macro, `LOWER_TEXT()` (yes the irony is not
lost on me) to wrap around all calls of `lowertext()` and ensure that
whatever we input into that proc will be stringified using the `"[]"`
(or `tostring()` for the nerds) operator. very simple.

I also added a linter to enforce this (and prevent all forms of
regression) because I think that machines should do the menial work and
we shouldn't expect maintainers to remember this, let me know if you
disagree. if there is a time when it should be opted out for some
reason, the linter does respect it if you wrap your input with the
`UNLINT()` function.
2024-04-10 12:19:43 -07:00
SyncIt21
55ef6a6219 Use a common list for acceptable silo materials (#81790)
## About The Pull Request
This list containing the same material values was copy pasted all over.
It's already cached in the subsystem so let's just use that.

Renamed ore category into silo category.

## Changelog
🆑
code: Use a common list for acceptable silo materials for some stuff.
Renamed ore category into silo category.
/🆑
2024-03-09 05:24:33 +01:00
SyncIt21
600b856323 Indestructible items are properly rejected by material containers (#81487)
## About The Pull Request
- Fixes #81486

Happens only with items that are Indestructible like the pai card, It's
a 2 part fix
- First display error message saying the item was rejected
- If the item is indestructible but was put inside another object like
an bag or anything else, then move the object to turf where this object
was inserted(`context`) & not the ore silo(`parent`) thus fixing the
teleportation bug

## Changelog
🆑
fix: Indestructible items like the pai card don't teleport to the ore
silo when you insert them into silo linked machine & also displays a
message saying it was rejected.
/🆑
2024-02-16 19:59:28 +01:00
SyncIt21
e4b23f2b4b General maintenance for Lathes (#81244)
## About The Pull Request
1. **Qol Stuff**
- Screentips & examines for screwdriver, crowbar acts, multiool &
wirecutter Also for Alt click
- Techfabs can now also use the Mouse drag functionality to set drop
target for items
- Lathe printing animation now plays on loop instead of just flicking
once till printing is finished for more visual feedback

2. **Code Improvements**
- Merged `start_making()` with `do_make_item()`. That proc was like only
3 lines long and used only in 1 place so let's just move that code to
`ui_act()`
- Merged `user_print_item_id()` with `ui_act()`. Again was used only in
1 place so let's just move that code in to save some proc overhead
- Sets `processing_flags` for autolathe to `NONE` cause we don't use
`process()`
    - Autodocs vars such as `hacked` , `shocked` etc & procs
- `maxmult` is now computed client side saving backend bandwidth,
`construction_time` is removed from lathes which did not use it
- Removed all usages of lathe taxes and their related vars, removed
engineering lathe no tax from ice moon, replaced with normal engineering
lathe

3. **Fixes**
- Lathe sheet insertion animations are now linked & work again for all
material types inserted via remote silo/local storage,
silver/titanium/plastic all play the same animation(that is
`protolathe_shiny` overlay). Other materials have their own respective
overlays
- Fixes #81243. Calling `update_static_data_for_all_viewers()` is too
expensive for the UI. We should instead use `SStgui.update_uis(src)`
which will report the `busy` status to the UI more immediatly
- Fixes #81236. Some problems with the params passed to the timer
callback. It should now print the correct number of requested items
- Fixes #81192. `design.materials` would runtime for custom material
items as they were list of texts not materials. We have to pass our
manually parsed list of materials for an specific item to ensure they
are set & used correctly. Same fixes apply for techfabs as well


## Changelog
🆑
qol: adds screentips & examines for screwdriver & crowbar acts & alt
click.
qol: techfabs can now use the mouse drop functionality to set drop
target.
qol: lathe printing animation plays on loop while printing rather than
flicking once for more visual feedback
fix: lathe sheet insertion animations are now linked & work again for
all material types inserted via remote silo/local storage
fix: printing custom materials items from autolathe works again.
fix: printing multiple items from lathes will actually print that
correct quantity of items requested.
fix: printing items the 2nd time around from lathes won't cause the UI
to reload each time.
code: autodoc for some vars & procs, merges procs.
refactor: Optimized code for autolathe & techfabs in general. Report
bugs on github
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2024-02-08 13:34:03 +01:00
SyncIt21
baad899062 Material container drops sheets only on object deconstruct & not destroy. (#81290)
## About The Pull Request
- Fixes #81289

It has nothing to do with `dump_contents()` but with the material
container that drops its materials on `Destroy()` causing side effects.
Now it only drops sheets when an object is deconstructed but not
destroyed.

For this to work properly on all instances we have to ensure
`deconstruct()` is not overridden at least on machines for now, so they
can send `COMSIG_OBJ_DECONSTRUCT` signal. That comes in the next PR

## Changelog
🆑
fix: deleting objects with local material storage(autolathe, drone
dispenser etc) no longer drops sheets, they only drop materials when
deconstructed
/🆑
2024-02-06 22:44:36 +01:00
SyncIt21
9141bfb95b General maintainence for Ore Silo (#81016)
## About The Pull Request
1. **Qol**(Hopefully not an issue for feature freeze)
- Adds Screen tips & examines for screwdriver, crowbar & multitool acts
   - Examining ore silo will now display its stored materials
- Location name is attached to the machine name and it greys out when
pausing the machine to make it more noticable that it is paused
   - Made window wider

2. **Code Improvements**
   - Auto docs procs & vars for ore silo log entry
- Fixed return values of all tool acts i.e. no more returning
`TRUE/FALSE` but the actual item interaction flags
- UI no longer computes `REF` for each machine which is expensive but
instead uses the index value in the list
   - Moved global variables to their corresponding files
- Ore silo no longer starts processing round start. That proc just ended
itself anyway so why even bother registering

3. **Fixes**
- If a machine was disconnected via the ore silo UI, attempting to
reconnect that machine would cause a runtime at `RegisterSignal` in
`multitool_act` because it was already registered in `Initialize`. It
now unregisters the signal when disconnecting so that's fixed
- Each machine element in the UI does not have a unique key because it
used `key={machine.name}`. This meant after disconnecting a machine the
UI buttons would get grouped together and the pause & disconnect buttons
would not function properly. Now it uses `index` which is unique thus
fixing that problem

## Changelog
🆑
qol: added more screen tips & examines for ore silo, made UI wider,
attach location name to each machine & grey out paused machines to make
it more noticeable.
code: auto docs proc & vars for silo log entry. Fixed return values of
all tool acts
fix: ore silo UI now functions correctly after removing an entry from
the UI
fix: no runtimes when connecting a machine to silo that was previously
disconnected via the ore silo UI
/🆑
2024-01-25 09:08:27 -05:00
scriptis
004c4f0b2b spellcheck: iron sheets's what? (#81045)
## About The Pull Request


![image](https://github.com/tgstation/tgstation/assets/12202230/237ce3f1-4c00-4e00-aabc-0b477b0be293)

literally unplayable

replaced with


![image](https://github.com/tgstation/tgstation/assets/12202230/521ddcf2-e512-4141-a4b1-92b833c76d88)


and with an active tone
## Why It's Good For The Game

spelling
## Changelog
🆑
spellcheck: iron sheets's what?
/🆑
2024-01-22 13:10:53 -08:00
Interception&?
9c2df71dc2 New Ore Silo UI (#80975)
![UI](https://github.com/tgstation/tgstation/assets/137328283/8a6f3645-32db-4700-8884-985cf7b3dd40)

## About The Pull Request

Made a new UI for Ore Silo, tweaked `MaterialAccessBar` component a bit
to properly display pop-ups over “wrapped” elements and actually wrap.

## Why It's Good For The Game

Ore Silo is one of the last machines that use browser on TG, we're
almost there!

Also, it helps @JohnFulpWillard to bring
https://hackmd.io/XLt5MoRvRxuhFbwtk4VAUA HackMD document to a closure.

## Changelog
🆑
refactor: Refactored Ore Silo Ui.
/🆑
2024-01-17 04:42:24 -05:00
Zephyr
13d2dceb31 Minor Autolathe Refactor | Material Dupe-B-Gone (#80839)
## About The Pull Request

Refactors underlying autolathe code, mostly about how it prints items
Items are now printed sequentially
Items now have their custom materials set to the the materials actually
used to create them
Items are now printed based on their design construction time instead of
a default 3.2 seconds per item always
Closes https://github.com/tgstation/tgstation/issues/80755

## Changelog
🆑
fix: Autolathes no longer allow you to duplicate materials at higher
levels of stock parts
qol: Autolathes now show name instead of typepath when selecting a
custom material
qol: Autolathe now print out items one by one instead of waiting for all
of them to print at once
/🆑
2024-01-15 13:35:02 -05:00
Mothblocks
c1d68698fb Micro-optimize qdel by only permitting one parameter (#80628)
Productionizes #80615.

The core optimization is this:

```patch
-	var/hint = to_delete.Destroy(arglist(args.Copy(2))) // Let our friend know they're about to get fucked up.
+	var/hint = to_delete.Destroy(force) // Let our friend know they're about to get fucked up.
```

We avoid a heap allocation in the form of copying the args over to a new
list. A/B testing shows this results in 33% better overtime, and in a
real round shaving off a full second of self time and 0.4 seconds of
overtime--both of these would be doubled in the event this is merged as
the new proc was only being run 50% of the time.
2023-12-28 13:52:44 -08:00
SyncIt21
527ebc3451 Fixes for mat container & ORM (#80573)
## About The Pull Request
- Fixes #80559

1) The ORM now hooks onto the local container only if off station. The
ui act if statement was also messed up but that's fixed now too.

2) Creates a dedicated signal for items inserted into the silo for
clarity & uses the helper proc defined inside remote materials for
inserting items so we don't have to specify the `context` manually.

3) Properly updates the auto Doc for the container signal defines

## Changelog
🆑
fix: Off station ORM's can redeem points again.
/🆑
2023-12-28 14:58:22 +01:00
SyncIt21
d36a5af64f Removes material breakdown flags, traits & miscellaneous fixes. (#80389)
## About The Pull Request
1. Removes material breakdown flags i.e. all flags with the format
`BREAKDOWN_XXX`. These flags do nothing, there are no special checks to
transform materials based on these flags, they are passed around just
because certain procs require them for syntax purposes only.

Apparently there were plans to make these flags do something special
from the comment

302247c0d1/code/__DEFINES/construction/material.dm (L43)
But nobody got any ideas for years now. The only special thing we can do
with them now is remove them and reduce code clutter, so let's do that
    
The only flag that ever did something was the
`BREAKDOWN_INCLUDE_ALCHEMY` flag. This only worked when coupled together
with `TRAIT_MAT_TRANSMUTED` trait(which is only used by the reagent
metalgen) and when both this trait & flag are combined together... they
still do nothing

302247c0d1/code/game/atom/atom_materials.dm (L41-L42)
Yup they cancel out each other to prevent returning an empty list, the
traits only job was to prevent materials from being recycled (like why?
what's the benefit of that? nothing) and the flag was meant to bypass
this restriction so both the trait & the flag cancel out each other
therefore doing nothing meaningful. Best remove them both and call it a
day.

2. Fixes an error in displaying number of sheets inserted into a mat
container when that sheet is made up of alloy materials. it would count
as 2 or more because it would take the sum of total material amount
inserted and not the actual sheets. That's fixed now.

3. Remote materials now properly respect the `MATCONTAINER_NO_INSERT`
flag

4. Adds helper proc to insert materials via the remote material
component with proper context

## Changelog
🆑
fix: mat container displays correct number of sheets inserted for alloy
materials.
fix: remote materials now properly respect the `MATCONTAINER_NO_INSERT`
flag.
code: removes material breakdown flags and related traits.
code: adds helper proc to insert materials via the remote material
component with proper context.
/🆑
2023-12-25 02:29:26 +01:00
SyncIt21
8ff1143972 [NO GBP] Fixes runtime in mat container chat display (#80321)
## About The Pull Request
Forgot to format the chat in the right format when items are rejected by
the mat container. Rather than displaying the item is rejected it would
simply runtime & not display anything. That's fixed now

## Changelog
🆑
fix: items that are rejected by the mat container will display the chat
message saying that.
/🆑
2023-12-14 17:08:47 +00:00
SyncIt21
27635e7640 Mat container related refactors & patches (#80164)
## About The Pull Request
**1. Mat container `user_insert()` tweaks**
- Mat container will now skip over an item & its contents if that item
cannot be processed (not suitable for redemption or not an allowed type)
this is not only realistic(if an item has an tough outer shell you can't
crush it to access its contents) but also saves us computation time as
we can skip over contents quickly
- Mat container now properly respects the `MATCONTAINER_SILENT` flag
- You can now hit machines like autolathe, protolathe etc with iron
sheets (or any other material item type those machines accept) when in
combat mode rather than inserting them because it makes sense
- Mat container now has much reduced chat spam as it will sum up all the
items inserted, and the material collected rather than displaying them
individually.
![Screenshot
(365)](https://github.com/tgstation/tgstation/assets/110812394/1ff444c6-cb0d-4a15-bfd6-71b9e8dcce5a)
Much improved readability and overall faster as we do much less
`to_chat()` calls

**2. ORM Tweaks** 
- Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/25329 .

ORM now generates points correctly always, regardless of how the ore is
inserted be it
  
  - Via hand
  - Thrown at the ORM
  - Ore Box
  - Some other bag containing ore

Points will always be generated at a common proc so no more checking
every inlet on how the ore enters the machine. Once the silo receives
the material it will inform the ORM about it, so it does not have to
check itself therefore reducing code bloat.

## Changelog
🆑
fix: ORM will generate points regardless of how the ore enters it.
fix: Machines like autolathe, techfab etc can now be hit with iron
sheets (or any other material item type those machines accept) when in
combat mode rather than inserting them because it makes sense.
fix: Mat container won't display chats fully if the
`MATCONTAINER_SILENT` flag is passed.
refactor: Machines like autolathe, techfab etc now display summed up
material inserts to chats rather than each item individually. Also, will
skip items & its contents if it cannot be processed thus saving time
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2023-12-14 15:12:04 +01:00
MrMelbert
1e76fd70b4 Attack chain refactoring: Broadening tool_act into item_interact, moving some item interactions to... atom/item_interact / item/interact_with_atom (#79968)
## About The Pull Request

Implements half of this (with some minor changes): 


![image](https://github.com/tgstation/tgstation/assets/51863163/bf5cc4bb-5a1f-42e3-921d-9a57bc6096cc)

The ultimate goal of this is to split our attack chain in two: 
- One for non-combat item interactions
  - Health analyzer scanning
  - using tools on stuff
  - surgery
  - Niche other interactions
- One for combat attacking
  - Item hit thing, item deal damage. 
  - Special effects on attack would go here.  

This PR begins this by broadining tool act into item interact. 

Item interact is a catch-all proc ran at the beginning of attack chain,
before `pre_attack` and such, that handles the first part of the chain.

This allows us to easily catch item interaction and cancel the attack
part of the chain by using deliberate bitflag return values, rather than
`TRUE` / `FALSE`*.

*Because right now, `TRUE` = `cancel attack`, no matter what, which is
unclear to people.

Instead of moving as much as possible to the new proc in this PR, I
started by doing some easy, obvious things. More things can be moved in
the future, or technically they don't even need to move in a lot of
cases.

## Changelog

🆑 Melbert
refactor: Refactored some methods of items interacting with other
objects or mobs, such as surgery and health analzyers. Report if
anything seems wrong
/🆑
2023-12-08 23:50:19 -07:00
SyncIt21
9ec508bd4f Machines now transfer their local materials to silo during linking (#78263)
## About The Pull Request
- Closes #78029
Rather than dumping their local materials as sheets on the turf,
machines (protolathe, exosuit fab, component printer and others that can
link to silo) now transfers their materials from local storage to silo
during linking with multitool

This way you don't have to pick up the sheets and manually put them in
the silo yourself & this can also save you from a lot of manual labour
of picking up sheets when you have a large amount of local materials
stored inside.

## Changelog
🆑
qol: Machines now transfer their local materials to silo during linking
with multitool
/🆑
2023-09-16 19:33:02 -07:00
Bloop
19233741c4 [NO GBP] Fixes more retrieve typos (#78069)
## About The Pull Request

Continuation of https://github.com/tgstation/tgstation/pull/77946, I
missed quite a few of these it seems.

## Why It's Good For The Game

Stop the spread of these typos!!

## Changelog

Nothing player facing
2023-09-02 16:14:56 +01:00
SyncIt21
c27a90da71 [NO GBP]Refactors how sheets are ejected from mat container (#77945)
## About The Pull Request
As #77936 pointed out an infinite while loop occurs in the recycler.
This was caused due to my recent mat changes as follows.

When the recycler eats up an item. If it found any material inside, it
would attempt to eject any sheets formed from it over here

ed71735fb3/code/game/machinery/recycler.dm (L199)

Inside this proc i first create the sheets in `null space` why is
explained in the comment

ed71735fb3/code/datums/components/material/material_container.dm (L599-L600)

After doing logging & stuff i then would move the sheets back into its
target turf so it could get merged again

ed71735fb3/code/datums/components/material/material_container.dm (L607-L608)

Unfortunately this would trigger `COMSIG_ATOM_ENTERED` signal which the
recycler is hooked onto. The recycler would then eat the newly ejected
sheets again, which would cause more sheets to be ejected, which would
again trigger the signal `COMSIG_ATOM_ENTERED` and you have your
infinite loop.

I did this because i had no clue how to stop the stack from merging when
it got spawned and this was a poor solution, so upon examining the code
i found there is a var to specifically stops stacks from merging

ed71735fb3/code/game/objects/items/stacks/stack.dm (L81)

Yup there is specific param called `merge=TRUE` which allows you to
explicitly stop stacks from merging. I now use this var and manually
merge stacks afterwards without calling `forceMove()` so it doesn't
trigger the recycler anymore which caused the infinite loops.

## Why It's good for the game
Writing checks to see if an object came from null space is weird. It
makes the code difficult to reason with as such situations never happen.
Now it makes sense for an atom to be moved "into" null space for e.g.
when it gets deleted but for an atom to "return back from it" never
happens and you shouldn't be bothered with figuring out how that
happened.

## Changelog
🆑
refactor: sheets are merged in a better way when ejected from machines &
material related stuff
/🆑
2023-08-29 12:46:45 -04:00
Bloop
86f71eb6b7 Fixes a typo (#77946) 2023-08-27 11:23:57 -04:00
SyncIt21
9aed3b6a8f General code maintenance for Mat container related stuff (#77671)
1. Removes `/obj/machinery/ore_silo/proc/remote_attackby()`. This proc
calls `datum/component/material_container/user_insert()` anyway which
performs all the checks necessary for inserting stuff into the ore silo
and `/obj/machinery/ore_silo/proc/remote_attackby()` was just repeating
its code & checks. So now inserting into the ore silo is directly
handled by the mat container without this proxy proc making the
operation slightly faster
2. Removed silo `attackby` code. Same operations can be done via
`screwdriver_act` & `crowbar_act` procs much cleaner
3. The ore silo now hooks onto signals
`COMSIG_MATCONTAINER_ITEM_CONSUMED` and
`COMSIG_MATCONTAINER_SHEETS_RETRIVED` and logs into silo when they are
triggered. This means when you insert/eject sheets from the silo the
connected machine performing the operation no longer has to do the
logging manually thus the proc `silo_log` has been removed from a lot of
places ,reducing overall code size
4. A lot of stuff that use materials from the ore silo follow this
pattern.

i.e. They first use the materials from the silo and then log it via
`silo_log` proc. This code pattern is repeated in a lot of places so
let's just merge these 2 lines with some extra sanity checks into a
single proc inside `remote_materials` itself. That's what was done and
the number of places where you log manually into the silo has been
removed further reducing code size everywhere.
5. Added auto doc & cleaned up some procs

Since logging is now done by the ore silo directly, we need a way to
pass the machine that is inserting items into the silo to the signal
handlers of the ore silo [via the `context` var]. So other code changes
elsewhere is because of this var
2023-08-21 22:23:01 +00:00
SyncIt21
920551d603 [NO GBP]Mat container Final clean-up & patches (#77092)
## About The Pull Request
1. Fixes #77177 
Some things were not connecting to the ore silo round start because the
silo was not initialized yet so it went to local storage. Now it
connects with the ore silo again
3. Removed some unused code in remote materials
4. Protolathe uses `eject_sheets()` defined in remote materials and not
it's own version because that's redundant
5. Don't put the item back in the players hand when inserting it in the
material container cause we haven't even removed it yet
6. `fast_split()` is now even faster & robust and is a global proc
7. Some code cleanup for RHD silo link

## Changelog
🆑
fix: some things not connecting to the ore silo round start
/🆑
2023-07-29 15:36:46 +02:00
SyncIt21
e92ae5b75b Material container & related stuff ui refactors & clean-up (#76220)
## About The Pull Request

**1. Material container clean-up & refactor**
- Replaced `total_amount` var with `total_amount()` proc, this var can
be easily computed by summing up all material amounts rather than
storing it as a var which is tedious to update & keep track of when
materials are added/removed
- Removed unused procs `transer_amt_to()`, `can_insert_amount_mat()`,
and `get_categories()`. These procs are not used anywhere in the
codebase so let's remove them & make some space.
- Callbacks are replaced with signals, the callbacks don't need to be
explicitly garbage collected & having macros & procs marked with
`SIGNAL_HANDLER` makes your intentions more readable & explicit.
- Fixes #76151 
All material adding, removal, checking operations are "Integer"
operations, i.e. the final value is rounded & them made 1 if the final
value is 0 using the macro `OPTIMIZE_COST`[coudn't come up with a better
name]. No more dealing with decimal value materials
The problem was after the protolathe was upgraded with better parts all
the design costs were multiplied with a decimal `efficiency_coeff`
value, this means even though in the UI the cost was displayed as 60
bluespace crystals its actual cost was `60.0001` something in the
backend causing this check for materials to fail & print the error
message.
- Replaced `GetComponent(/datum/component_material_container)` with just
a simple ref to the material container when adding the component, so we
can save some overhead from calling this proc
- Gave all procs a ton of documentation with documentation having
documentation
- Fixes #76506 RCD and other devices that uses the silo link upgrade now
have the correct material usages
- Fixes #72096. It wasn't just a problem with ancient protolathe but
with all machines that used `datum/component/remote_materials` the
problem was remote materials would add an instance of
`datum/remote/material_container` if it wanted to use local storage but
this component would get added before `datum/component/remote_materials`
could be registered i.e. it comes before remote_materials in the
component list. So when the machine is destroyed it will first destroy
`material_container` & then `remote_materials` therefore destroying the
materials before they could get ejected
- Silo link is established when parent is registered with remote
materials raher than adding an external timer which is faster
- Everything that uses a material container will auto eject their sheets
when destroyed
- Moved this & remote materials into its own folder for better
organization


**2. Material UI Changes**
- Removed the x25 & x50 print buttons from the autolathe, now they just
have x5 & x10 buttons like the protolathe, These buttons were of no use
since you could just type the exact amount you want to print in the
`[Max: <some amount>]` side bar. The code to compute these buttons was
just plain right nasty & some of it unused in the UI.
- The material eject button in the material bar does not gray out when
you can eject exactly one sheet
- All material cost are integer values rounded
- Fixes #76253 Exosuit Fabricator sends the material container static
data to the UI so its material bar is not greyed out when there are
sufficient materials to eject
- Component printer material bar sends the material container static
data to the UI so its material bar is not greyed out when there are
sufficient materials to eject
- Autolathe Material bars now display number of sheets available
- Max printable amount of items are now computed & updated correctly in
the UI. They were displaying wrong values & now get updated when items
are printed, materials are removed
- Silo hold actually works now. When a machine is put on hold it calls
this proc

e929cf39cd/code/datums/components/remote_materials.dm (L78-L87)
Notice how the key is `src` so we should be consistent during checking
if a machine is on hold using the same `src` var. But for some reason we
did dumb shit like this

e929cf39cd/code/datums/components/remote_materials.dm (L150-L153)
What is category? Why do we care for the area the machine is in? None of
it made sense so i removed all that junk and just made it check for
`src` like it should
- Removed redundant `removable` & `sheets` var from the material
container ui_data. These vars are unused in the UI
- If an item does not have the required materials then upon clicking
that item you will not get any error message but instead nothing happens

## Changelog
🆑
fix: items can be printed from autolathe & protolathe when the exact
material amounts are present in them after upgrading
fix: max printable amount now shows the correct value & updates when
items are printed, materials are removed in the autolathe & protolathe
fix: component printer material bar is not greyed out when there are
sufficient materials to eject
fix: rcd and other devices that uses the silo link upgrade now have the
correct material usages
fix: silo hold actually works
fix: machines using local storage to hold materials will eject it's
materials as sheets when deconstructed/destroyed
refactor: Autolathe Material bars now display number of sheets available
refactor: printing an item that does not have enough materials will fail
silently with no error messages
refactor: Drone dispenser will eject sheets upon deconstruction
refactor: all things that store materials will auto ejects its sheets(if
there is sufficient material) when destroyed
refactor: inserting an item into the material container will display the
units consumed as sheets not absolute units
refactor: removed x25 & x50 print buttons from the autolathe
2023-07-24 19:47:14 -04:00