Files
GS13NG/code/datums/components
r4d6 12a01d1656 update (#9)
* Minor underwear fixes and tweaks.

* Allows ghost mentors to orbit around the target instead of changing their view to the mob's.

* Ports some hud and update_icon code updates.

* contamination nerf

* Fix

* Stops humanoids whose skin_tone variable is set to "albino" from showing up as pale when examined should their species not use skintones anyway.

* Hello darkness my old friend.

* Ports "Refactors can_see_reagents"

* F

* MKUltra made double opt-in

* ROBUST OPTING MECHANICS

* Adds a hacky framework for digitigrade polyclothes

also adds a digitigrade state for polychromic shorts

* also adds aphrodisiacs, slaps, all hypno as prefs

* errors

* Modernizes Polychromic Uniform Code

No more modular_citadel, but the neck polychrome crap needs more work in another PR

* oh god please don't mess up

* git y u do dis

;-;

* Revert "Makes HE pipes realistically radiate away heat"

* more coat stuff yes yes

* woops

* Wew

* Steos are bad

* new wings and fluff

* Forgot a sprite

* another one

* I swear I had this in here orginally.

* Fixes mistake in less commit.

* reattaches missing antenna

* Effectively removes the long unrequired roboticist encryption key.

* updates ratvar coat

* magazine metal cost tweaks, speedloader in AIB

* the very shitty idea: "muh speedloader"

* Updating dynamic config, some balancing

* Automatic changelog generation for PR #10282 [ci skip]

* unfucks short hair 80s so the left facing sprite doesnt make you look like a crackhead

* Automatic changelog generation for PR #10266 [ci skip]

* ah, the wonders of atomization

* [s] fixes a little door assembly glass dupe exploit

* Update BoxStation.dmm

* Update pai_defense.dm

* fixes bad sprite states

* Automatic changelog generation for PR #10242 [ci skip]

* Automatic changelog generation for PR #10237 [ci skip]

* Added a ghost role with its own spawner for the purposes of chillling in the ninja holding facility.

* holy shit i hope this compiles

* e

* yee

* Automatic changelog generation for PR #10128 [ci skip]

* Nope, it didn't compile, Harold.

* Automatic changelog generation for PR #10283 [ci skip]

* Automatic changelog generation for PR #10281 [ci skip]

* Automatic changelog generation for PR #10250 [ci skip]

* Applied suggestions and minor tweaks.

* f

* yeah fair enough

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update engine_goggles.dm

* changes

* Automatic changelog generation for PR #10264 [ci skip]

* Automatic changelog generation for PR #10298 [ci skip]

* Good idea, tbh.

* Small touch-up.

* Nerfs armor and antistun

* Automatic changelog generation for PR #10296 [ci skip]

* let the adminbus commence

* sprites

* clothing add

* fix

* vending

* loadout

* FIXEdD

* Automatic changelog generation for PR #10265 [ci skip]

* Automatic changelog generation for PR #10289 [ci skip]

* Automatic changelog generation for PR #10268 [ci skip]

* Update CentCom.dmm

* ehh fine but why would you use this proc for that

* Update language_holder.dm

* Automatic changelog generation for PR #10315 [ci skip]

* cocooooonuuuuuuts

* excludes certain ghost roles from being affected by health events

* fixes the thing

* probably fixes pandoras attacking their owners

* Update stamina.dm

* Update sprint.dm

* Update food_reagents.dm

* Automatic changelog generation for PR #10322 [ci skip]

* does the fix?

* What about this?

* Wait no its actually the other way around.

* weh

* Automatic changelog generation for PR #10297 [ci skip]

* Automatic changelog generation for PR #10299 [ci skip]

* more weh.

* even more weh.

* all of the weh.

* ah

* Automatic changelog generation for PR #10217 [ci skip]

* maybe fixes?

* Don't use named arguments on new, please.

* Made a line use the dang macro

* Made sure ghost cafe visitors don't get midround antags

* Automatic changelog generation for PR #10328 [ci skip]

* Physiology so species changes dont fuck it up

* Whoops

* Aarggghh small fucking differences

* Makes ass slap attempts fail more loudly on opted-out mobs

* Automatic changelog generation for PR #10318 [ci skip]

* Automatic changelog generation for PR #10091 [ci skip]

* Update borghydro.dm

* Update grass_carpet.dm

* Ports reflector blobs

Ports reflectors from /TG/

* mouth

* Fixes UI for poly collars

AltClick for collars was seemingly forgotten so I've added it back

* auto ooc

* roundend too

* hnnnnnng code improvements

* marshmallow

* telescopic IVs

* tiny fix

* Automatic changelog generation for PR #10324 [ci skip]

* Automatic changelog generation for PR #10323 [ci skip]

* Update code/modules/hydroponics/grown/grass_carpet.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* got it

* Update engine_goggles.dm

* [s] Fixes ghost anti-ghostrole timers a little.

* chestbursters deleting brains fix.

* Wait a minute...

* ...which var are you?

* Update belt.dm

* tiny fixes

* makes it a trait

* few fixes

* wow divide by 0 very cool

* Automatic changelog generation for PR #10095 [ci skip]

* Automatic changelog generation for PR #10312 [ci skip]

* Automatic changelog generation for PR #10243 [ci skip]

* Automatic changelog generation for PR #10336 [ci skip]

* Automatic changelog generation for PR #10335 [ci skip]

* Automatic changelog generation for PR #10334 [ci skip]

* Automatic changelog generation for PR #10239 [ci skip]

* Automatic changelog generation for PR #10168 [ci skip]

* Automatic changelog generation for PR #10331 [ci skip]

* Automatic changelog generation for PR #10320 [ci skip]

* Maybe he means this?

* CE Locker Exodus: The Removaling

Removes junk from the CE locker.
Adds empty engineering lockers.
I don't know how to do this as a child and not have populate contents fill the child.

* ok

* Automatic changelog generation for PR #10348 [ci skip]

* Automatic changelog generation for PR #10333 [ci skip]

* changelog.html

* desc

* hnnnng

* weh

* did this actually change anything

* Automatic changelog generation for PR #10337 [ci skip]

* yee.

* yee2.

* Automatic changelog generation for PR #10339 [ci skip]

* Ghommies fixes

* Automatic changelog generation for PR #10306 [ci skip]

* amazing.

* Automatic changelog generation for PR #10357 [ci skip]

* Automatic changelog generation for PR #10301 [ci skip]

* Update chem_master.dm

* Automatic changelog generation for PR #10123 [ci skip]

* Automatic changelog generation for PR #10165 [ci skip]

* Automatic changelog generation for PR #10338 [ci skip]

* Automatic changelog generation for PR #10344 [ci skip]

* Oh god oh fuck

* Update code/modules/hydroponics/seeds.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update code/modules/hydroponics/seeds.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update code/modules/hydroponics/gene_modder.dm

Co-Authored-By: Ghom <42542238+Ghommie@users.noreply.github.com>

* Update telescopic_iv.dm

* Automatic changelog generation for PR #10364 [ci skip]

* afwafwadjiwao

* Automatic changelog generation for PR #10365 [ci skip]

* Automatic changelog generation for PR #10319 [ci skip]

* Automatic changelog generation for PR #10345 [ci skip]

* Automatic changelog generation for PR #10362 [ci skip]

* Automatic changelog generation for PR #10309 [ci skip]

* Makes lockers into subtypes

Adds new lockers cleanly at the bottom instead and as subtypes.

* dab

* dab 2x

* Automatic changelog generation for PR #10349 [ci skip]

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Putnam3145 <putnam3145@gmail.com>
Co-authored-by: Michiyamenotehifunana <31995558+Michiyamenotehifunana@users.noreply.github.com>
Co-authored-by: Seris02 <49109742+Seris02@users.noreply.github.com>
Co-authored-by: Trilbyspaceclone <30435998+Trilbyspaceclone@users.noreply.github.com>
Co-authored-by: shellspeed1 <46614774+shellspeed1@users.noreply.github.com>
Co-authored-by: Hatterhat <31829017+Hatterhat@users.noreply.github.com>
Co-authored-by: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Co-authored-by: CitadelStationBot <citadelstationcommunity@gmail.com>
Co-authored-by: Detective-Google <48196179+Detective-Google@users.noreply.github.com>
Co-authored-by: LetterJay <9606363+LetterJay@users.noreply.github.com>
Co-authored-by: Lin <linzolle@gmail.com>
Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
Co-authored-by: kappa-sama <44128284+kappa-sama@users.noreply.github.com>
Co-authored-by: Arturlang <arturpaavooskari.lang@gmail.com>
Co-authored-by: loginsandylogout <nintendofan356@gmail.com>
Co-authored-by: BlackMajor <henrydyer6@hotmail.com>
Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
Co-authored-by: KathrinBailey <53862927+KathrinBailey@users.noreply.github.com>
Co-authored-by: nik707 <38332985+nik707@users.noreply.github.com>
2019-12-31 13:12:23 -05:00
..
2019-11-19 19:34:42 +01:00
2019-12-31 13:12:23 -05:00
2019-10-16 15:53:11 -05:00
2019-10-23 20:43:05 +02:00
2019-11-19 19:34:42 +01:00
2019-11-28 02:47:09 +01:00
2019-10-16 15:53:11 -05:00
2019-11-19 19:34:42 +01:00
2019-11-19 19:34:42 +01:00
2019-12-13 16:12:04 +01:00
2019-11-19 19:34:42 +01:00
2019-10-23 21:36:47 -05:00
2019-12-07 01:53:55 -05:00
2019-12-15 20:31:36 +01:00

Datum Component System (DCS)

Concept

Loosely adapted from /vg/. This is an entity component system for adding behaviours to datums when inheritance doesn't quite cut it. By using signals and events instead of direct inheritance, you can inject behaviours without hacky overloads. It requires a different method of thinking, but is not hard to use correctly. If a behaviour can have application across more than one thing. Make it generic, make it a component. Atom/mob/obj event? Give it a signal, and forward it's arguments with a SendSignal() call. Now every component that want's to can also know about this happening.

In the code

Slippery things

At the time of this writing, every object that is slippery overrides atom/Crossed does some checks, then slips the mob. Instead of all those Crossed overrides they could add a slippery component to all these objects. And have the checks in one proc that is run by the Crossed event

Powercells

A lot of objects have powercells. The get_cell() proc was added to give generic access to the cell var if it had one. This is just a specific use case of GetComponent()

Radios

The radio object as it is should not exist, given that more things use the concept of radios rather than the object itself. The actual function of the radio can exist in a component which all the things that use it (Request consoles, actual radios, the SM shard) can add to themselves.

Standos

Stands have a lot of procs which mimic mob procs. Rather than inserting hooks for all these procs in overrides, the same can be accomplished with signals

API

Defines

  1. COMPONENT_INCOMPATIBLE Return this from /datum/component/Initialize or datum/component/OnTransfer to have the component be deleted if it's applied to an incorrect type. parent must not be modified if this is to be returned. This will be noted in the runtime logs

Vars

  1. /datum/var/list/datum_components (private)
    • Lazy associated list of type -> component/list of components.
  2. /datum/var/list/comp_lookup (private)
    • Lazy associated list of signal -> registree/list of registrees
  3. /datum/var/list/signal_procs (private)
    • Associated lazy list of signals -> /datum/callbacks that will be run when the parent datum receives that signal
  4. /datum/var/signal_enabled (protected, boolean)
    • If the datum is signal enabled. If not, it will not react to signals
    • FALSE by default, set to TRUE when a signal is registered
  5. /datum/component/var/dupe_mode (protected, enum)
    • How duplicate component types are handled when added to the datum.
      • COMPONENT_DUPE_HIGHLANDER (default): Old component will be deleted, new component will first have /datum/component/proc/InheritComponent(datum/component/old, FALSE) on it
      • COMPONENT_DUPE_ALLOWED: The components will be treated as separate, GetComponent() will return the first added
      • COMPONENT_DUPE_UNIQUE: New component will be deleted, old component will first have /datum/component/proc/InheritComponent(datum/component/new, TRUE) on it
      • COMPONENT_DUPE_UNIQUE_PASSARGS: New component will never exist and instead its initialization arguments will be passed on to the old component.
  6. /datum/component/var/dupe_type (protected, type)
    • Definition of a duplicate component type
      • null means exact match on type (default)
      • Any other type means that and all subtypes
  7. /datum/component/var/datum/parent (protected, read-only)
    • The datum this component belongs to
    • Never null in child procs
  8. report_signal_origin (protected, boolean)
    • If TRUE, will invoke the callback when signalled with the signal type as the first argument.
    • FALSE by default.

Procs

  1. /datum/proc/GetComponent(component_type(type)) -> datum/component? (public, final)
    • Returns a reference to a component of component_type if it exists in the datum, null otherwise
  2. /datum/proc/GetComponents(component_type(type)) -> list (public, final)
    • Returns a list of references to all components of component_type that exist in the datum
  3. /datum/proc/GetExactComponent(component_type(type)) -> datum/component? (public, final)
    • Returns a reference to a component whose type MATCHES component_type if that component exists in the datum, null otherwise
  4. GET_COMPONENT(varname, component_type) OR GET_COMPONENT_FROM(varname, component_type, src)
    • Shorthand for var/component_type/varname = src.GetComponent(component_type)
  5. SEND_SIGNAL(target, sigtype, ...) (public, final)
    • Use to send signals to target datum
    • Extra arguments are to be specified in the signal definition
    • Returns a bitflag with signal specific information assembled from all activated components
    • Arguments are packaged in a list and handed off to _SendSignal()
  6. /datum/proc/AddComponent(component_type(type), ...) -> datum/component (public, final)
    • Creates an instance of component_type in the datum and passes ... to its Initialize() call
    • Sends the COMSIG_COMPONENT_ADDED signal to the datum
    • All components a datum owns are deleted with the datum
    • Returns the component that was created. Or the old component in a dupe situation where COMPONENT_DUPE_UNIQUE was set
    • If this tries to add an component to an incompatible type, the component will be deleted and the result will be null. This is very unperformant, try not to do it
    • Properly handles duplicate situations based on the dupe_mode var
  7. /datum/proc/LoadComponent(component_type(type), ...) -> datum/component (public, final)
    • Equivalent to calling GetComponent(component_type) where, if the result would be null, returns AddComponent(component_type, ...) instead
  8. /datum/proc/ComponentActivated(datum/component/C) (abstract, async)
    • Called on a component's parent after a signal received causes it to activate. src is the parameter
    • Will only be called if a component's callback returns TRUE
  9. /datum/proc/TakeComponent(datum/component/C) (public, final)
    • Properly transfers ownership of a component from one datum to another
    • Signals COMSIG_COMPONENT_REMOVING on the parent
    • Called on the datum you want to own the component with another datum's component
  10. /datum/proc/_SendSignal(signal, list/arguments) (private, final)
    • Handles most of the actual signaling procedure
    • Will runtime if used on datums with an empty component list
  11. /datum/proc/RegisterSignal(datum/target, signal(string/list of strings), proc_ref(type), override(boolean)) (protected, final)
    • If signal is a list it will be as if RegisterSignal was called for each of the entries with the same following arguments
    • Makes the datum listen for the specified signal on it's parent datum.
    • When that signal is received proc_ref will be called on the component, along with associated arguments
    • Example proc ref: .proc/OnEvent
    • If a previous registration is overwritten by the call, a runtime occurs. Setting override to TRUE prevents this
    • These callbacks run asyncronously
    • Returning TRUE from these callbacks will trigger a TRUE return from the SendSignal() that initiated it
  12. /datum/component/New(datum/parent, ...) (private, final)
    • Runs internal setup for the component
    • Extra arguments are passed to Initialize()
  13. /datum/component/Initialize(...) (abstract, no-sleep)
    • Called by New() with the same argments excluding parent
    • Component does not exist in parent's datum_components list yet, although parent is set and may be used
    • Signals will not be received while this function is running
    • Component may be deleted after this function completes without being attached
    • Do not call qdel(src) from this function
  14. /datum/component/Destroy(force(bool), silent(bool)) (virtual, no-sleep)
    • Sends the COMSIG_COMPONENT_REMOVING signal to the parent datum if the parent isn't being qdeleted
    • Properly removes the component from parent and cleans up references
    • Setting force makes it not check for and remove the component from the parent
    • Setting silent deletes the component without sending a COMSIG_COMPONENT_REMOVING signal
  15. /datum/component/proc/InheritComponent(datum/component/C, i_am_original(boolean)) (abstract, no-sleep)
    • Called on a component when a component of the same type was added to the same parent
    • See /datum/component/var/dupe_mode
    • C's type will always be the same of the called component
  16. /datum/component/proc/AfterComponentActivated() (abstract, async)
    • Called on a component that was activated after it's parent's ComponentActivated() is called
  17. /datum/component/proc/OnTransfer(datum/new_parent) (abstract, no-sleep)
    • Called before new_parent is assigned to parent in TakeComponent()
    • Allows the component to react to ownership transfers
  18. /datum/component/proc/_RemoveFromParent() (private, final)
    • Clears parent and removes the component from it's component list
  19. /datum/component/proc/_JoinParent (private, final)
    • Tries to add the component to it's parents datum_components list
  20. /datum/component/proc/RegisterWithParent (abstract, no-sleep)
    • Used to register the signals that should be on the parent object
    • Use this if you plan on the component transfering between parents
  21. /datum/component/proc/UnregisterFromParent (abstract, no-sleep)
    • Counterpart to RegisterWithParent()
    • Used to unregister the signals that should only be on the parent object

See/Define signals and their arguments in __DEFINES\components.dm