-
Notifications
You must be signed in to change notification settings - Fork 934
Water Overlay Effects - Redux #12918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kugamo
wants to merge
17
commits into
cmss13-devs:master
Choose a base branch
from
kugamo:Soggy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
41f08da
Startium
kugamo 43eb397
Getting Somewhere
kugamo c61663f
3
kugamo c21d00b
moved icon work to subsystem
kugamo d96a955
Finalle's Eve!?
kugamo 559b557
Better Sounds
kugamo d8564d1
wowowowow big refactor
kugamo 184a254
Finished Sprites
kugamo 7485bd4
Merge remote-tracking branch 'upstream/master' into Soggy
kugamo 5d827ab
fix 1
kugamo 2d6e04d
fix 2
kugamo 1eaae10
fix 3: the alphabet
kugamo 144e100
fix 4: this time surely
kugamo 9c26b87
Drulikar review 1
kugamo 9ffc8e7
changes depth values to definitions
kugamo 48abeb9
Drulikar Watermelon914 Boskoramen Fira review
kugamo 486bbf8
Fix 5
kugamo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Wateroverlay global status | ||
| #define WATEROVERLAY_STATUS_STANDBY 0 | ||
| #define WATEROVERLAY_STATUS_RUNNING 1 | ||
| #define WATEROVERLAY_STATUS_DONE 2 | ||
|
|
||
| #define DEPTH_LAND 0 | ||
| #define DEPTH_COAST_SHALLOW -2 | ||
| #define DEPTH_COAST_INTERMEDIATE -4 | ||
| #define DEPTH_SHALLOW -8 | ||
| #define DEPTH_INTERMEDIATE -12 | ||
| #define DEPTH_DEEP -18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /proc/is_full_water(turf/potential_water) | ||
| if(!isturf(potential_water)) | ||
| return FALSE | ||
| if(istype(potential_water, /turf/open)) | ||
| var/turf/open/potential_open_water = potential_water | ||
| if(potential_open_water.covered) | ||
| return FALSE | ||
| return (potential_water.turf_flags & TURF_FULL_WATER) | ||
|
|
||
| /proc/is_coastline(turf/potential_coastline) | ||
| if(!isturf(potential_coastline)) | ||
| return FALSE | ||
| if(istype(potential_coastline, /turf/open)) | ||
| var/turf/open/potential_open_coastline = potential_coastline | ||
| if(potential_open_coastline.covered) | ||
| return FALSE | ||
| return (potential_coastline.turf_flags & TURF_COASTLINE) | ||
|
|
||
| /proc/is_water(turf/T) | ||
| return (is_full_water(T) || is_coastline(T)) | ||
|
|
||
| /proc/handle_get_icon(recieved_icon, toxic) //I love Toxic code!!! | ||
| var/return_icon = recieved_icon | ||
| if(recieved_icon == 'icons/turf/floors/desert_water.dmi') | ||
| if(toxic == 1) | ||
| return_icon ='icons/turf/floors/desert_water_toxic.dmi' | ||
| else if(toxic == -1) | ||
| return_icon = 'icons/turf/floors/desert_water_transition.dmi' | ||
| return return_icon | ||
|
|
||
| /proc/handle_toxic_states(turf/in_turf) //adds duplicate states for toxic water turfs so we can handle toxic states | ||
| var/list/return_list = list(in_turf.type) | ||
| if(ispath(in_turf, /turf/open/gm/river/desert) || ispath(in_turf, /turf/open/desert/desert_shore)) | ||
| return_list += in_turf.type | ||
| return_list += in_turf.type | ||
| return return_list | ||
|
|
||
| /* ////////////////////////// GENERATING ICONS TO BE USED IN WATER OVERLAYS /////////////////////////// generate_water_display_icons() | ||
| water turfs are hardcoded to only have certain depths, but the shorelines take from their fulltile varients ---> turf/open var/water_type | ||
| so for each water turf we generate a water overlay for each size mobs' textures can have: 32, 48, 64, and 88 ---> texture_sizes | ||
| in addition to those for extra deep water turfs we also generate an icon that will cover the mob completely | ||
| some mobs look weird with just the default overlay, so for those we generate additional overlays using unique culling masks ---> water_overlay_special | ||
| and lastly 2 more overlays for resting humans per waterturf. and there, all the overlays we'll every need all in one neat list :0) */ | ||
|
|
||
| //currently it generates icons only for turfs on loaded maps, not counting nightmares | ||
| //which could concievably be lowered by having coasts of the same depth reroute to the same overlay... oh god, just imagining it hurts | ||
|
|
||
| /proc/generate_water_display_icons() | ||
| for(var/starting_type in SSwater_overlays.found_waters) | ||
| var/turf/open/starting_open_turf = starting_type //if theres a water turf thats not an open turf subtype someones messed up | ||
| if(starting_open_turf.depth == DEPTH_LAND) | ||
| continue //some turfs are water turfs, but have no depth... meaning no need for an overlay | ||
| var/toxic = -1 | ||
| for(var/found_type in handle_toxic_states(starting_open_turf)) //if the water turf can be toxic, we need to add overlays for each possiblity | ||
| toxic++ | ||
| var/usable_tox = toxic == 0 ? 0 : (toxic == 1 ? 1 : -1) | ||
| var/working_type = starting_open_turf.water_type ? starting_open_turf.water_type : found_type //handle rerouting | ||
| var/turf/open/working_T = working_type | ||
| for(var/texture_size in SSwater_overlays.texture_sizes) | ||
| // V V V V construct water texture V V V V | ||
| var/icon/sized_water_texture = icon(SSwater_overlays.water_overlay_icon_paths["[texture_size]"],"empty") //this is what will eventually be our water texture | ||
| var/icon/turf_texture = icon(handle_get_icon(working_T.icon, usable_tox), working_T.icon_state) //this is the actual texture we'll use to create the water texture | ||
| var/icon/subtraction_texture = icon(SSwater_overlays.water_overlay_icon_paths["[texture_size]"], "culling_mask") //this is the part of it we'll keep, rest will become "air" | ||
| var/texture_width = sized_water_texture.Width() | ||
| var/pieces = round(texture_width / 32) + (texture_width / 32 > round(texture_width / 32) ? 1 : 0) //since mobs wont always be 32x32 the water texture will need be build out of 32x32 parts | ||
| for(var/i=0, i<pieces, i++) | ||
| for(var/j=0, j<pieces, j++) | ||
| sized_water_texture.Blend(turf_texture, ICON_OVERLAY, (i*32)+1, (j*32)+1) //place our 32x32 textures on our water texture every 32 pixels | ||
| if(starting_open_turf.depth == DEPTH_DEEP) | ||
| SSwater_overlays.water_overlay_icons["[texture_size]_[found_type][usable_tox]_u"] = icon(sized_water_texture) // for the full water overlay | ||
|
|
||
| // V V V V construct depthed overlay for mob texture size V V V V | ||
| var/icon/culled_water = icon(sized_water_texture) | ||
| var/texture_hieght = sized_water_texture.Height() | ||
| subtraction_texture.Shift(SOUTH, (texture_hieght - abs(starting_open_turf.depth)-3), FALSE) //we move it down to "water level" if we're not using a custom mob culling mask | ||
| culled_water.AddAlphaMask(subtraction_texture) | ||
| SSwater_overlays.water_overlay_icons["[texture_size]_[found_type][usable_tox]"] = culled_water //this is the default overlays, made according to depth | ||
|
|
||
| // V V V V specialized water overlays V V V V | ||
| var/list/special_mob_masks = SSwater_overlays.water_overlay_special["[texture_size]"] | ||
| for(var/mob_type in special_mob_masks) | ||
| // * HUMANS RESTING * <-- this could be expanded later if someone wants to sprite 2 culling masks for every mob you want them on... | ||
| if(mob_type == /mob/living/carbon/human) | ||
| var/resting_key = starting_open_turf.depth >= -4 ? "coast" : "float" | ||
| var/icon/resting_east = icon(sized_water_texture) | ||
| var/icon/resting_west = icon(sized_water_texture) | ||
| resting_east.AddAlphaMask(icon(SSwater_overlays.water_overlay_icon_paths["[texture_size]"], "culling_[resting_key]_rest_e")) | ||
| resting_west.AddAlphaMask(icon(SSwater_overlays.water_overlay_icon_paths["[texture_size]"], "culling_[resting_key]_rest_w")) | ||
| SSwater_overlays.water_overlay_icons["32_[found_type][usable_tox]_[mob_type]_e"] = resting_east | ||
| SSwater_overlays.water_overlay_icons["32_[found_type][usable_tox]_[mob_type]_w"] = resting_west | ||
|
|
||
| // * water_overlay_special * these mobs look weird with the default overlays, we use special culling masks for them | ||
| if(special_mob_masks[mob_type]) | ||
| var/icon/special_icon = icon(sized_water_texture) | ||
| var/icon/special_mask = icon(SSwater_overlays.water_overlay_icon_paths["[texture_size]"], special_mob_masks[mob_type]) | ||
| special_icon.AddAlphaMask(special_mask) | ||
| SSwater_overlays.water_overlay_icons["[texture_size]_[found_type][usable_tox]_[mob_type]"] = special_icon | ||
|
|
||
| CHECK_TICK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| SUBSYSTEM_DEF(water_overlays) | ||
| name = "Water Overlays" | ||
| init_order = SS_INIT_WATEROVERLAYS | ||
| flags = SS_NO_FIRE | ||
| var/stat = WATEROVERLAY_STATUS_STANDBY | ||
| var/start_time = 0 | ||
| var/list/turfs_to_process = list() | ||
| var/list/texture_sizes = list(32, 48, 64, 88) | ||
| var/list/found_waters = list() | ||
| var/list/water_overlay_icons = list() | ||
| var/list/water_overlay_special = list( | ||
| "32" = list( | ||
| /mob/living/carbon/human = null, | ||
| /mob/living/carbon/xenomorph/larva = "culling_larva", | ||
| ), | ||
| "48" = list( | ||
| /mob/living/carbon/xenomorph/facehugger = "culling_facehugger", | ||
| ), | ||
| "64" = list(), | ||
| "88" = list() | ||
| ) | ||
| var/list/water_overlay_icon_paths = list( | ||
| "32" = 'icons/effects/water_overlay_effects/_32.dmi', //humans, etc | ||
| "48" = 'icons/effects/water_overlay_effects/_48.dmi', //facehugger, drone | ||
| "64" = 'icons/effects/water_overlay_effects/_64.dmi', //most xenos | ||
| "88" = 'icons/effects/water_overlay_effects/_88.dmi', //queen | ||
| ) | ||
|
|
||
| /datum/controller/subsystem/water_overlays/Initialize() | ||
| return SS_INIT_SUCCESS | ||
|
|
||
| /datum/controller/subsystem/water_overlays/proc/gamestart_process() | ||
| start_time = world.time | ||
| stat = WATEROVERLAY_STATUS_RUNNING | ||
| for(var/turf/T in GLOB.turfs) | ||
| if(is_water(T)) | ||
| found_waters |= T | ||
| for(var/direction in GLOB.alldirs) | ||
| var/turf/found_turf = get_step(T, direction) | ||
| if(found_turf && !is_water(found_turf)) | ||
| turfs_to_process |= found_turf | ||
|
|
||
| generate_water_display_icons() | ||
|
|
||
| var/list/altered_turfs = list() | ||
| for(var/turf/current_turf in turfs_to_process) | ||
| if(current_turf in altered_turfs) | ||
| continue | ||
| altered_turfs |= current_turf.fix_water_clipping_layers(altered_turfs) | ||
| for(var/turf/current_turf in altered_turfs) | ||
| current_turf.fix_water_clipping_layers_final() | ||
| stat = WATEROVERLAY_STATUS_DONE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| ///Footstep component. Plays footsteps at parents location when it is appropriate. | ||
| /datum/component/footstep | ||
| dupe_mode = COMPONENT_DUPE_HIGHLANDER | ||
| dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS | ||
| ///how many steps before the footstep sound is played | ||
| var/steps = 0 | ||
| ///volume of soundfile see playsound() | ||
|
|
@@ -29,6 +29,10 @@ | |
|
|
||
| RegisterSignal(parent, list(COMSIG_MOVABLE_MOVED), PROC_REF(play_simplestep)) | ||
|
|
||
| /datum/component/footstep/InheritComponent(datum/component/C, i_am_originalsteps_ = 2, volume_ = 50, range_ = null, falloff_ = 1, footstep_sounds_ = "alien_footstep_large", drag_sounds_ = 'sound/effects/alien_dragsound_large.ogg', vary_ = rand(20000, 25000)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like a typo here in the arguments
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont see it, sorry. can you tell me where exactly? :O |
||
| . = ..() | ||
| footstep_sounds = footstep_sounds_ | ||
|
kugamo marked this conversation as resolved.
|
||
|
|
||
| /datum/component/footstep/proc/prepare_step() | ||
| var/turf/open/T = get_turf(parent) | ||
| if(!istype(T)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| ///water_overlay_effect component. adds and removes | ||
| /datum/component/water_overlay_effect | ||
| dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS | ||
| var/datum/effects/water_overlay_effect/my_water_overlay_effect | ||
| var/turf_type //! Turf type the effect applies to | ||
|
|
||
|
|
||
| /datum/component/water_overlay_effect/Initialize(turf/input_turf, y_offset) | ||
| if(!istype(parent, /atom/movable)) | ||
| return COMPONENT_INCOMPATIBLE | ||
| turf_type = input_turf.type | ||
| my_water_overlay_effect = new(parent) | ||
| my_water_overlay_effect.pixel_y_offset = y_offset | ||
| my_water_overlay_effect.update(get_turf(parent)) | ||
|
|
||
| /datum/component/water_overlay_effect/Destroy() | ||
| . = ..() | ||
| my_water_overlay_effect.Destroy() | ||
|
|
||
| /datum/component/water_overlay_effect/InheritComponent(datum/component/C, i_am_original, turf/input_turf, y_offset) | ||
| . = ..() | ||
| var/will_update = FALSE | ||
| if(turf_type != input_turf.type) | ||
| turf_type = input_turf.type | ||
| will_update = TRUE | ||
| if(my_water_overlay_effect.pixel_y_offset != y_offset) | ||
| my_water_overlay_effect.pixel_y_offset = y_offset | ||
| will_update = TRUE | ||
| if(will_update) | ||
| my_water_overlay_effect.update(get_turf(parent)) | ||
|
|
||
| /datum/component/water_overlay_effect/proc/handle_affected_mob_move(parent_source, oldloc, direction, forced) | ||
| SIGNAL_HANDLER | ||
| var/turf/open/gm/moved_to_turf = get_turf(parent_source) | ||
| if(moved_to_turf.depth >= DEPTH_LAND || moved_to_turf.covered) | ||
| Destroy() | ||
| return | ||
| var/mob/M = parent_source | ||
| if(M.m_intent == MOVE_INTENT_RUN) //walking doesnt make sounds from moving through water | ||
| var/soundname = moved_to_turf.depth >= DEPTH_COAST_INTERMEDIATE ? "shallowwading" : (moved_to_turf.depth >= DEPTH_SHALLOW ? "wading":"deepwading") | ||
| playsound(moved_to_turf, soundname, 10, 1, 10, falloff=1) | ||
|
|
||
| /datum/component/water_overlay_effect/proc/handle_resting_change() | ||
| var/turf/laid_on_turf = get_turf(parent) | ||
| if(ispath(laid_on_turf.type, /turf/open)) | ||
| var/turf/open/open_laid_on_turf = laid_on_turf | ||
| my_water_overlay_effect.pixel_y_offset = open_laid_on_turf.depth | ||
| my_water_overlay_effect.update(laid_on_turf) | ||
|
|
||
| /datum/component/water_overlay_effect/proc/update_the_effect() | ||
| SIGNAL_HANDLER | ||
| var/turf/unbuckled_turf = get_turf(parent) | ||
| if(ispath(unbuckled_turf.type, /turf/open)) | ||
| var/turf/open/open_buckled_turf = unbuckled_turf | ||
| my_water_overlay_effect.pixel_y_offset = open_buckled_turf.depth | ||
| my_water_overlay_effect.hidden = FALSE | ||
| my_water_overlay_effect.update(get_turf(parent)) | ||
|
|
||
| /datum/component/water_overlay_effect/RegisterWithParent(datum/target) | ||
| . = ..() | ||
| RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(handle_affected_mob_move)) | ||
| RegisterSignal(parent, COMSIG_LIVING_SET_LYING_ANGLE, PROC_REF(handle_resting_change)) | ||
| RegisterSignal(parent, COMSIG_LIVING_SET_BODY_POSITION, PROC_REF(handle_resting_change)) | ||
| RegisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE, PROC_REF(update_the_effect)) | ||
| RegisterSignal(parent, COMSIG_MOB_UNHAULED, PROC_REF(update_the_effect)) | ||
|
|
||
| /datum/component/water_overlay_effect/UnregisterFromParent(datum/source, force) | ||
| . = ..() | ||
| UnregisterSignal(parent, COMSIG_MOVABLE_MOVED) | ||
| UnregisterSignal(parent, COMSIG_LIVING_SET_LYING_ANGLE) | ||
| UnregisterSignal(parent, COMSIG_LIVING_SET_BODY_POSITION) | ||
| UnregisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE) | ||
| UnregisterSignal(parent, COMSIG_MOB_UNHAULED) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally you should just hook this on the nightmare finished signal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the nightmare finished signal" I couldnt find one.. I found COMSIG_NIGHTMARE_APPLYING_NODE but that from a glance seemed to be called everytime an individual nightmare was finished? idk nightmare code is an enigma to me