Files
Aurora.3/code/modules/overmap/ships/engines/engine.dm
skull132 0fc67f2cb9 Remove a whole bunch of in world loops and rework machinery global lists (#3053)
Removes a whole bunch of in world loops.
Reworks SSmachinery to hold two lists: all_machines and processing_machines. all_machines contains all machines 5ever. All of them. Literally. Forever. And ever. processing_machines only contains machines that process with the SSmachinery controller.

I checked most types at runtime on the live server to see whether they're in processing_machines or in all_machines, and did debug to ensure that most machinery ends up and stays in all_machines.

Includes a basic UT to make sure all mapped in machinery types remain within the all_machines list post-init.
2017-07-16 20:32:33 +03:00

61 lines
1.2 KiB
Plaintext

//Engine component object
var/list/ship_engines = list()
/datum/ship_engine
var/name = "ship engine"
var/obj/machinery/engine //actual engine object
var/zlevel = 0
/datum/ship_engine/New(var/obj/machinery/holder)
engine = holder
zlevel = holder.z
for(var/obj/machinery/computer/engines/E in SSmachinery.processing_machines)
if (E.z == zlevel && !(src in E.engines))
E.engines += src
break
//Tries to fire the engine. If successfull, returns 1
/datum/ship_engine/proc/burn()
if(!engine)
die()
return 1
//Returns status string for this engine
/datum/ship_engine/proc/get_status()
if(!engine)
die()
return "All systems nominal"
/datum/ship_engine/proc/get_thrust()
if(!engine)
die()
return 100
//Sets thrust limiter, a number between 0 and 1
/datum/ship_engine/proc/set_thrust_limit(var/new_limit)
if(!engine)
die()
return 1
/datum/ship_engine/proc/get_thrust_limit()
if(!engine)
die()
return 1
/datum/ship_engine/proc/is_on()
if(!engine)
die()
return 1
/datum/ship_engine/proc/toggle()
if(!engine)
die()
return 1
/datum/ship_engine/proc/die()
for(var/obj/machinery/computer/engines/E in SSmachinery.processing_machines)
if (E.z == zlevel)
E.engines -= src
break
qdel(src)