Merge pull request #9549 from atlantiscze/bright-solution

Refactor floodlights
This commit is contained in:
Zuhayr
2015-05-30 02:11:10 +09:30
11 changed files with 103 additions and 68 deletions
+27 -27
View File
@@ -5,56 +5,56 @@
icon = 'icons/obj/device.dmi'
icon_state = "suitcooler0"
slot_flags = SLOT_BACK //you can carry it on your back if you want, but it won't do anything unless attached to suit storage
//copied from tank.dm
flags = CONDUCT
force = 5.0
throwforce = 10.0
throw_speed = 1
throw_range = 4
origin_tech = "magnets=2;materials=2"
var/on = 0 //is it turned on?
var/cover_open = 0 //is the cover open?
var/obj/item/weapon/cell/cell
var/max_cooling = 12 //in degrees per second - probably don't need to mess with heat capacity here
var/charge_consumption = 16.6 //charge per second at max_cooling
var/thermostat = T20C
//TODO: make it heat up the surroundings when not in space
/obj/item/device/suit_cooling_unit/New()
processing_objects |= src
cell = new/obj/item/weapon/cell() //comes with the crappy default power cell - high-capacity ones shouldn't be hard to find
cell.loc = src
/obj/item/device/suit_cooling_unit/process()
if (!on || !cell)
if (!on || !cell)
return
if (!ismob(loc))
return
if (!attached_to_suit(loc)) //make sure they have a suit and we are attached to it
return
var/mob/living/carbon/human/H = loc
var/efficiency = 1 - H.get_pressure_weakness() //you need to have a good seal for effective cooling
var/env_temp = get_environment_temperature() //wont save you from a fire
var/temp_adj = min(H.bodytemperature - max(thermostat, env_temp), max_cooling)
if (temp_adj < 0.5) //only cools, doesn't heat, also we don't need extreme precision
return
var/charge_usage = (temp_adj/max_cooling)*charge_consumption
H.bodytemperature -= temp_adj*efficiency
cell.use(charge_usage)
if(cell.charge <= 0)
turn_off()
@@ -70,22 +70,22 @@
var/turf/T = get_turf(src)
if(istype(T, /turf/space))
return 0 //space has no temperature, this just makes sure the cooling unit works in space
var/datum/gas_mixture/environment = T.return_air()
if (!environment)
return 0
return environment.temperature
/obj/item/device/suit_cooling_unit/proc/attached_to_suit(mob/M)
if (!ishuman(M))
if (!ishuman(M))
return 0
var/mob/living/carbon/human/H = M
if (!H.wear_suit || H.s_store != src)
return 0
return 1
/obj/item/device/suit_cooling_unit/proc/turn_on()
@@ -93,7 +93,7 @@
return
if(cell.charge <= 0)
return
on = 1
updateicon()
@@ -112,7 +112,7 @@
cell.loc = get_turf(loc)
cell.add_fingerprint(user)
cell.updateicon()
cell.update_icon()
user << "You remove the [src.cell]."
src.cell = null
@@ -149,7 +149,7 @@
user << "You insert the [cell]."
updateicon()
return
return ..()
/obj/item/device/suit_cooling_unit/proc/updateicon()
@@ -164,7 +164,7 @@
/obj/item/device/suit_cooling_unit/examine(mob/user)
if(!..(user, 1))
return
if (on)
if (attached_to_suit(src.loc))
user << "It's switched on and running."
@@ -172,13 +172,13 @@
user << "It's switched on, but not attached to anything."
else
user << "It is switched off."
if (cover_open)
if(cell)
user << "The panel is open, exposing the [cell]."
else
user << "The panel is open."
if (cell)
user << "The charge meter reads [round(cell.percent())]%."
else
+1 -1
View File
@@ -73,7 +73,7 @@
else if(istype(W, /obj/item/weapon/screwdriver))
if(bcell)
bcell.updateicon()
bcell.update_icon()
bcell.loc = get_turf(src.loc)
bcell = null
user << "<span class='notice'>You remove the cell from the [src].</span>"