Ports the weather system from Nebula. (#18706)

* part 1

* compiles?

* IT WORKS

* vis contents

* fixes

* umbrelloid

* umbrella 2

* dsasdd

* stuff

* lmao

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
Matt Atlas
2024-03-24 14:05:00 +00:00
committed by GitHub
co-authored by Matt Atlas
parent 82beece3db
commit 57067892d8
73 changed files with 1368 additions and 31 deletions
@@ -1,6 +1,7 @@
//Dionaea regenerate health and nutrition in light.
/mob/living/carbon/alien/diona/handle_environment(datum/gas_mixture/environment)
..()
if(environment && consume_nutrition_from_air)
environment.remove(diona_handle_air(get_dionastats(), pressure))
@@ -143,6 +143,7 @@
return 1
/mob/living/carbon/alien/handle_environment(var/datum/gas_mixture/environment)
..()
// Both alien subtypes survive in vaccum and suffer in high temperatures,
// so I'll just define this once, for both (see radiation comment above)
if(!environment) return
@@ -35,6 +35,7 @@
/mob/living/carbon/brain/handle_environment(datum/gas_mixture/environment)
..()
if(!environment)
return
var/environment_heat_capacity = environment.heat_capacity()
@@ -303,6 +303,8 @@
return breath
/mob/living/carbon/human/handle_environment(datum/gas_mixture/environment)
..()
if(!environment)
return
@@ -16,6 +16,7 @@
handle_speech_and_mood()
/mob/living/carbon/slime/handle_environment(datum/gas_mixture/environment)
..()
if(!environment)
adjustToxLoss(rand(10,20))
return
+57 -6
View File
@@ -10,10 +10,10 @@
if(!loc)
return
var/datum/gas_mixture/environment = loc.return_air()
var/datum/gas_mixture/gas_environment = loc.return_air()
//Handle temperature/pressure differences between body and environment
if(environment)
handle_environment(environment)
if(gas_environment)
handle_environment(gas_environment)
blinded = 0 // Placing this here just show how out of place it is.
@@ -57,9 +57,6 @@
/mob/living/proc/handle_random_events()
return
/mob/living/proc/handle_environment(var/datum/gas_mixture/environment)
return
/mob/living/proc/update_pulling()
if(pulling)
if(incapacitated())
@@ -189,3 +186,57 @@
/mob/living/proc/handle_hud_icons_health()
return
/mob/living
var/datum/weakref/last_weather
/mob/living/proc/is_outside()
var/turf/T = loc
return istype(T) && T.is_outside()
/mob/living/proc/get_affecting_weather()
var/turf/my_turf = get_turf(src)
if(!istype(my_turf))
return
var/turf/actual_loc = loc
// If we're standing in the rain, use the turf weather.
. = istype(actual_loc) && actual_loc.weather
if(!.) // If we're under or inside shelter, use the z-level rain (for ambience)
. = SSweather.weather_by_z["[my_turf.z]"]
/mob/living/proc/handle_environment(var/datum/gas_mixture/environment)
SHOULD_CALL_PARENT(TRUE)
// Handle physical effects of weather.
var/singleton/state/weather/weather_state
var/obj/abstract/weather_system/weather = get_affecting_weather()
if(weather)
weather_state = weather.weather_system.current_state
if(istype(weather_state))
weather_state.handle_exposure(src, get_weather_exposure(weather), weather)
// Refresh weather ambience.
// Show messages and play ambience.
if(client)
// Work out if we need to change or cancel the current ambience sound.
var/send_sound
var/mob_ref = WEAKREF(src)
if(istype(weather_state))
var/ambient_sounds = !is_outside() ? weather_state.ambient_indoors_sounds : weather_state.ambient_sounds
var/ambient_sound = length(ambient_sounds) && pick(ambient_sounds)
if(GLOB.current_mob_ambience[mob_ref] == ambient_sound)
return
send_sound = ambient_sound
GLOB.current_mob_ambience[mob_ref] = send_sound
else if(mob_ref in GLOB.current_mob_ambience)
GLOB.current_mob_ambience -= mob_ref
else
return
// Push sound to client. Pipe dream TODO: crossfade between the new and old weather ambience.
sound_to(src, sound(null, repeat = 0, wait = 0, volume = 0, channel = sound_channels.weather_channel))
if(send_sound)
sound_to(src, sound(send_sound, repeat = TRUE, wait = 0, volume = 30, channel = sound_channels.weather_channel))
+9
View File
@@ -7,4 +7,13 @@
//If they're SSD, remove it so they can wake back up.
update_antag_icons(mind)
reset_death_timers()
// Clear our cosmetic/sound weather cooldowns.
var/obj/abstract/weather_system/weather = get_affecting_weather()
var/mob_ref = WEAKREF(src)
if(istype(weather))
weather.mob_shown_weather -= mob_ref
weather.mob_shown_wind -= mob_ref
GLOB.current_mob_ambience -= mob_ref
return .
+52
View File
@@ -1395,6 +1395,58 @@
var/list/data = list()
return data
/mob/proc/get_weather_protection()
for(var/obj/item/brolly in get_active_hand())
if(brolly.gives_weather_protection())
LAZYADD(., brolly)
if(!LAZYLEN(.))
for(var/turf/T as anything in RANGE_TURFS(1, loc))
for(var/obj/structure/flora/tree in T)
if(tree.protects_against_weather)
LAZYADD(., tree)
/mob/living/carbon/human/get_weather_protection()
. = ..()
if(!LAZYLEN(.))
var/obj/item/clothing/head/check_head = get_equipped_item(slot_head_str)
if(!istype(check_head) || !check_head.protects_against_weather)
return
var/obj/item/clothing/suit/check_body = get_equipped_item(slot_wear_suit_str)
if(!istype(check_body) || !check_body.protects_against_weather)
return
LAZYADD(., check_head)
LAZYADD(., check_body)
/mob/proc/get_weather_exposure()
// We're inside something else.
if(!isturf(loc))
return WEATHER_IGNORE
var/turf/T = loc
// We're under a roof or otherwise shouldn't be being rained on.
if(!T.is_outside())
// For non-multiz we'll give everyone some nice ambience.
if(!HasAbove(T.z))
return WEATHER_ROOFED
// For multi-z, check the actual weather on the turf above.
// TODO: maybe make this a property of the z-level marker.
var/turf/above = GetAbove(T)
if(above.weather)
return WEATHER_ROOFED
// Being more than one level down should exempt us from ambience.
return WEATHER_IGNORE
// Nothing's protecting us from the rain here
var/list/weather_protection = get_weather_protection()
if(LAZYLEN(weather_protection))
return WEATHER_PROTECTED
return WEATHER_EXPOSED
#undef UNBUCKLED
#undef PARTIALLY_BUCKLED
#undef FULLY_BUCKLED