mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
[READY]Forwarding of New arguments to Initialize (#24298)
* Forwarding of New arguments to Initialize * Updates that line about New/Initialize arguments
This commit is contained in:
@@ -145,7 +145,7 @@ There are two key points here:
|
||||
Remember, this tradeoff makes sense in many cases but not all, you should think carefully about your implementation before deciding if this is an appropriate thing to do
|
||||
|
||||
###Prefer `Initialize` over `New` for atoms
|
||||
Our game controller is pretty good at handling long operations and lag. But, it can't control what happens when the map is loaded, which calls `New` for all atoms on the map. If you're creating a new atom, use the `Initialize` proc to do what you would normally do in `New`, and only use `New` if you need to pass arguments other than `loc` on construction. This cuts down on the number of proc calls needed when the world is loaded. See here for details on `Initialize`: https://github.com/tgstation/tgstation/blob/master/code/game/atoms.dm#L49
|
||||
Our game controller is pretty good at handling long operations and lag. But, it can't control what happens when the map is loaded, which calls `New` for all atoms on the map. If you're creating a new atom, use the `Initialize` proc to do what you would normally do in `New`. This cuts down on the number of proc calls needed when the world is loaded. See here for details on `Initialize`: https://github.com/tgstation/tgstation/blob/master/code/game/atoms.dm#L49
|
||||
|
||||
###No magic numbers or strings
|
||||
Make these #defines with a name that more clearly states what it's for.
|
||||
|
||||
+7
-5
@@ -25,7 +25,7 @@
|
||||
var/list/our_overlays //our local copy of (non-priority) overlays without byond magic. Use procs in SSoverlays to manipulate
|
||||
var/list/priority_overlays //overlays that should remain on top and not normally removed when using cut_overlay functions, like c4.
|
||||
|
||||
/atom/New()
|
||||
/atom/New(loc, ...)
|
||||
//atom creation method that preloads variables at creation
|
||||
if(use_preloader && (src.type == _preloader.target_path))//in case the instanciated atom is creating other atoms in New()
|
||||
_preloader.load(src)
|
||||
@@ -34,15 +34,16 @@
|
||||
add_atom_colour(color, FIXED_COLOUR_PRIORITY)
|
||||
|
||||
//lighting stuff
|
||||
if(opacity && isturf(loc))
|
||||
loc.UpdateAffectingLights()
|
||||
if(opacity && isturf(src.loc))
|
||||
src.loc.UpdateAffectingLights()
|
||||
|
||||
if(luminosity)
|
||||
light = new(src)
|
||||
|
||||
var/do_initialize = SSatoms.initialized
|
||||
if(do_initialize > INITIALIZATION_INSSOBJ)
|
||||
Initialize(do_initialize == INITIALIZATION_INNEW_MAPLOAD)
|
||||
args[1] = do_initialize == INITIALIZATION_INNEW_MAPLOAD
|
||||
Initialize(arglist(args))
|
||||
//. = ..() //uncomment if you are dumb enough to add a /datum/New() proc
|
||||
|
||||
//Called after New if the map is being loaded. mapload = TRUE
|
||||
@@ -51,11 +52,12 @@
|
||||
//Derivatives must not sleep
|
||||
//Returning TRUE while mapload is TRUE will cause the object to be initialized again with mapload = FALSE when everything else is done
|
||||
//(Useful for things that requires turfs to have air). This base may only be called once, however
|
||||
//Other parameters are passed from New (excluding loc), this does not happen if mapload is TRUE
|
||||
|
||||
//Note: the following functions don't call the base for optimization and must copypasta:
|
||||
// /turf/Initialize
|
||||
// /turf/open/space/Initialize
|
||||
/atom/proc/Initialize(mapload)
|
||||
/atom/proc/Initialize(mapload, ...)
|
||||
if(initialized)
|
||||
stack_trace("Warning: [src]([type]) initialized multiple times!")
|
||||
initialized = TRUE
|
||||
|
||||
Reference in New Issue
Block a user