anchor.diff:  	else
   		return 0
   
  -#undef APC_UPDATE_ICON_COOLDOWN+#undef APC_UPDATE_ICON_COOLDOWN
  
positive.code: 	var/beenhit = 0 // used for counting how many times it has been hit, used for Aliens at the moment
  	var/mob/living/silicon/ai/occupier = null
  	var/longtermpower = 10
  	var/updating_icon = 0
  	var/datum/wires/apc/wires = null
  	//var/debug = 0
  	var/auto_name = 0
  
  /obj/machinery/power/apc/updateDialog()
  	if (stat & (BROKEN|MAINT))
  
negative.code: // update the APC icon to show the three base states
  // also add overlays for indicator lights
  /obj/machinery/power/apc/update_icon()
  	if (!status_overlays)
  		status_overlays = 1
  		status_overlays_lock = new
  		status_overlays_charging = new
  		status_overlays_equipment = new
  		status_overlays_lighting = new
  		status_overlays_environ = new
  
  		status_overlays_lock.len = 2
  		status_overlays_charging.len = 3
  		status_overlays_equipment.len = 4
  		status_overlays_lighting.len = 4
  		status_overlays_environ.len = 4
  
  		status_overlays_lock[1] = image(icon, "apcox-0")    // 0=blue 1=red
  		status_overlays_lock[2] = image(icon, "apcox-1")
  
  		status_overlays_charging[1] = image(icon, "apco3-0") 
  		status_overlays_charging[2] = image(icon, "apco3-1")
  		status_overlays_charging[3] = image(icon, "apco3-2")		
  
  		status_overlays_equipment[1] = image(icon, "apco0-0")
  		status_overlays_equipment[2] = image(icon, "apco0-1")
  		status_overlays_equipment[3] = image(icon, "apco0-2")
  		status_overlays_equipment[4] = image(icon, "apco0-3")
  
  		status_overlays_lighting[1] = image(icon, "apco1-0")
  		status_overlays_lighting[2] = image(icon, "apco1-1")
  		status_overlays_lighting[3] = image(icon, "apco1-2")
  		status_overlays_lighting[4] = image(icon, "apco1-3")
  		
  		status_overlays_environ[1] = image(icon, "apco2-0")
  		status_overlays_environ[2] = image(icon, "apco2-1")
  		status_overlays_environ[3] = image(icon, "apco2-2")
  		status_overlays_environ[4] = image(icon, "apco2-3")
  
  	var/update = check_updates() 		//returns 0 if no need to update icons.
  						// 1 if we need to update the icon_state
  						// 2 if we need to update the overlays
  	if(!update)
  		return
  
  	if(update & 1) // Updating the icon state
  		if(update_state & UPSTATE_ALLGOOD)
  			icon_state = "apc0"
  		else if(update_state & (UPSTATE_OPENED1|UPSTATE_OPENED2))
  			var/basestate = "apc[ cell ? "2" : "1" ]"
  			if(update_state & UPSTATE_OPENED1)
  				if(update_state & (UPSTATE_MAINT|UPSTATE_BROKE))
  					icon_state = "apcmaint" //disabled APC cannot hold cell
  				else
  					icon_state = basestate
  			else if(update_state & UPSTATE_OPENED2)
  				if (update_state & UPSTATE_BROKE || malfhack)
  					icon_state = "[basestate]-b-nocover"
  				else
  					icon_state = "[basestate]-nocover"
  		else if(update_state & UPSTATE_BROKE)
  			icon_state = "apc-b"
  		else if(update_state & UPSTATE_BLUESCREEN)
  			icon_state = "apcemag"
  		else if(update_state & UPSTATE_WIREEXP)
  			icon_state = "apcewires"
  
  	if(!(update_state & UPSTATE_ALLGOOD))
  		if(overlays.len)
  			overlays = 0
  
  	if(update & 2)
  		if (overlays.len) overlays.len = 0
  
  		if(overlays.len)
  			overlays.len = 0
  		if(!(stat & (BROKEN|MAINT)) && update_state & UPSTATE_ALLGOOD)
  			overlays += status_overlays_lock[locked+1]
  			overlays += status_overlays_charging[charging+1]
  			if(operating)
  				overlays += status_overlays_equipment[equipment+1]
  				overlays += status_overlays_lighting[lighting+1]
  				overlays += status_overlays_environ[environ+1]
  
  
  /obj/machinery/power/apc/proc/check_updates()
  
  	var/last_update_state = update_state 
  	var/last_update_overlay = update_overlay
  	update_state = 0
  	update_overlay = 0	
  
  	if(cell)
  		update_state |= UPSTATE_CELL_IN
  	if(stat & BROKEN)
  		update_state |= UPSTATE_BROKE
  	if(stat & MAINT)
  		update_state |= UPSTATE_MAINT
  	if(opened)
  		if(opened==1)
  			update_state |= UPSTATE_OPENED1
  		if(opened==2)
  			update_state |= UPSTATE_OPENED2
  	else if(emagged || malfai)
  		update_state |= UPSTATE_BLUESCREEN
  	else if(wiresexposed)
  		update_state |= UPSTATE_WIREEXP
  	if(update_state <= 1)
  		update_state |= UPSTATE_ALLGOOD
  
  	if(update_state & UPSTATE_ALLGOOD)
  		if(locked)
  			update_overlay |= APC_UPOVERLAY_LOCKED
  
  		if(!charging)
  			update_overlay |= APC_UPOVERLAY_CHARGEING0
  		else if(charging == 1)
  			update_overlay |= APC_UPOVERLAY_CHARGEING1
  		else if(charging == 2)
  			update_overlay |= APC_UPOVERLAY_CHARGEING2
  
  		if (!equipment)
  			update_overlay |= APC_UPOVERLAY_EQUIPMENT0
  		else if(equipment == 1)
  			update_overlay |= APC_UPOVERLAY_EQUIPMENT1
  		else if(equipment == 2)
  			update_overlay |= APC_UPOVERLAY_EQUIPMENT2
  		
  		if(!lighting)
  			update_overlay |= APC_UPOVERLAY_LIGHTING0
  		else if(lighting == 1)
  			update_overlay |= APC_UPOVERLAY_LIGHTING1
  		else if(lighting == 2)
  			update_overlay |= APC_UPOVERLAY_LIGHTING2
  
  		if(!environ)
  			update_overlay |= APC_UPOVERLAY_ENVIRON0
  		else if(environ==1)
  			update_overlay |= APC_UPOVERLAY_ENVIRON1
  		else if(environ==2)
  			update_overlay |= APC_UPOVERLAY_ENVIRON2
  
  	var/results = 0
  	if(last_update_state == update_state && last_update_overlay == update_overlay)
  		return 0
  	if(last_update_state != update_state)
  		results += 1
  	if(last_update_overlay != update_overlay)
  		results += 2
  	return results
  
  // Used in process so it doesn't update the icon too much
  /obj/machinery/power/apc/proc/queue_icon_update()
  