Files
Bubberstation/code/controllers/subsystem/movement/cliff_falling.dm
Time-Green ec9434ea6b Adds cliffs to icebox (#77062)
## About The Pull Request

Adds cliffs to the game! They're tiles usable for mapping to make
mountainy area's and cliffs! I don't have any sprites for them yet, so
just imagine it's a cliff really hard


![image](https://github.com/tgstation/tgstation/assets/7501474/ab0f31b6-93d7-4964-8b9c-4fb3c774647a)

THESE DO NOT REPLACE MULTI-Z AND NEVER WILL! They're just a neat way to
add more depth to the game. You can’t really add 10 different z’s for
one mountain, so this can be used to help map area’s with depth without
overusing z-levels

They've been mapped into the top part of the icebox outside. There's not
a good way to do sides of cliffs yet (will need some thinking), so
they're mapped in such a fashion where it doesn't matter much. Later,
this area above icebox can be expanded with properly done side-cliffs,
something like in stardew-valley would work for our grid-system:


![image](https://github.com/tgstation/tgstation/assets/7501474/007964cc-49d5-489c-9a43-2140f29239ce)

Longer demonstration: https://www.youtube.com/watch?v=Eig4jXNZZRQ

Eventually, I'll redo mapgen and add 3x3 icebox (definitely not coping)

## Why It's Good For The Game

The incredible flatness of icebox drives me insane. While multi-z is
great at giving it more depth, the actual terrain itself is still
completely flat. Adding cliffs let's us add 'soft-mountains', which does
wonders for making an area feel more alive

(And I absolutely adore snowy mountains)

## Changelog
🆑
add: Adds cliffs to the north of icebox. Try not to fall of of them!
/🆑
<details>
  <summary>Additional images (now outdated)</summary>


https://github.com/tgstation/tgstation/assets/7501474/572dc749-596c-4cab-9693-43c2270aca96
 

![image](https://github.com/tgstation/tgstation/assets/7501474/e12236d1-fda8-406a-858b-84a9fe5b4dc7)

![image](https://github.com/tgstation/tgstation/assets/7501474/264ae9d8-2f84-4133-8eb3-29e8df6c976e)

![image](https://github.com/tgstation/tgstation/assets/7501474/15a7f378-b595-4d7b-b948-d405916cb431)

![image](https://github.com/tgstation/tgstation/assets/7501474/b058a184-9fd5-4fa9-b0de-9f687bdf4e43)
  
</details>

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
2023-07-28 14:13:43 +00:00

62 lines
2.3 KiB
Plaintext

/// Subsystem to handle falling of off cliffs
MOVEMENT_SUBSYSTEM_DEF(cliff_falling)
name = "Cliff Falling"
priority = FIRE_PRIORITY_CLIFF_FALLING
flags = SS_NO_INIT|SS_TICKER
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
/// Who are currently falling and with which movemanager?
var/list/cliff_grinders = list()
/datum/controller/subsystem/movement/cliff_falling/proc/start_falling(atom/movable/faller, turf/open/cliff/cliff)
// Make them move
var/mover = SSmove_manager.move(moving = faller, direction = cliff.fall_direction, delay = cliff.fall_speed, subsystem = src, priority = MOVEMENT_ABOVE_SPACE_PRIORITY, flags = MOVEMENT_LOOP_OUTSIDE_CONTROL | MOVEMENT_LOOP_NO_DIR_UPDATE)
cliff_grinders[faller] = mover
RegisterSignal(faller, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
RegisterSignal(faller, COMSIG_QDELETING, PROC_REF(clear_references))
RegisterSignal(faller, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(check_move))
/// We just moved, so check if we're still moving right
/datum/controller/subsystem/movement/cliff_falling/proc/on_moved(atom/movable/mover, turf/old_loc)
SIGNAL_HANDLER
var/turf/open/cliff/new_cliff = mover.loc
if(!iscliffturf(new_cliff)) //not a cliff, lets clean up
var/datum/move_loop/move/falling = cliff_grinders[mover]
clear_references(mover)
qdel(falling)
return
new_cliff.on_fall(mover)
if(old_loc.type == new_cliff) //same type of cliff, no worries
return
var/datum/move_loop/move/fall = cliff_grinders[mover]
fall.set_delay(new_cliff.fall_speed) //different cliff, so set the speed
/datum/controller/subsystem/movement/cliff_falling/proc/on_qdel(atom/movable/deletee)
SIGNAL_HANDLER
clear_references(deletee)
/datum/controller/subsystem/movement/cliff_falling/proc/clear_references(atom/movable/deletee)
cliff_grinders -= deletee
UnregisterSignal(deletee, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_MOVABLE_PRE_MOVE))
/// Check if we can move! We do this mostly to determine falling behaviour and make sure we're moving to valid tiles
/datum/controller/subsystem/movement/cliff_falling/proc/check_move(atom/movable/mover, turf/target)
SIGNAL_HANDLER
var/turf/open/cliff/cliff_turf = get_turf(mover)
if(!iscliffturf(cliff_turf)) //we arent on a cliff, WHY ARE WE HERE???
clear_references(mover)
return
if(!cliff_turf.can_move(mover, target))
return COMPONENT_MOVABLE_BLOCK_PRE_MOVE