mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
Cleans up the forced gravity component and makes it use signals (#38962)
* Cleans up the forced gravity component and makes it use signals * Suffer not a bool
This commit is contained in:
committed by
Tad Hardesty
parent
948bb4b0ec
commit
9631eabbc3
@@ -63,6 +63,7 @@
|
||||
#define COMSIG_ATOM_ROTATE "atom_rotate" //from base of atom/shuttleRotate(): (rotation, params)
|
||||
#define COMSIG_ATOM_DIR_CHANGE "atom_dir_change" //from base of atom/setDir(): (old_dir, new_dir)
|
||||
#define COMSIG_ATOM_CONTENTS_DEL "atom_contents_del" //from base of atom/handle_atom_del(): (atom/deleted)
|
||||
#define COMSIG_ATOM_HAS_GRAVITY "atom_has_gravity" //from base of atom/has_gravity(): (turf/location, list/forced_gravities)
|
||||
/////////////////
|
||||
#define COMSIG_ATOM_ATTACK_GHOST "atom_attack_ghost" //from base of atom/attack_ghost(): (mob/dead/observer/ghost)
|
||||
#define COMSIG_ATOM_ATTACK_HAND "atom_attack_hand" //from base of atom/attack_hand(): (mob/user)
|
||||
@@ -88,6 +89,7 @@
|
||||
|
||||
// /turf signals
|
||||
#define COMSIG_TURF_CHANGE "turf_change" //from base of turf/ChangeTurf(): (path, list/new_baseturfs, flags, list/transferring_comps)
|
||||
#define COMSIG_TURF_HAS_GRAVITY "turf_has_gravity" //from base of atom/has_gravity(): (atom/asker, list/forced_gravities)
|
||||
|
||||
// /atom/movable signals
|
||||
#define COMSIG_MOVABLE_MOVED "movable_moved" //from base of atom/movable/Moved(): (/atom, dir)
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
/datum/component/forced_gravity
|
||||
var/gravity = 1
|
||||
var/gravity
|
||||
var/ignore_space = FALSE //If forced gravity should also work on space turfs
|
||||
|
||||
/datum/component/forced_gravity/Initialize(forced_value = 1)
|
||||
if(!isatom(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
gravity = forced_value
|
||||
RegisterSignal(COMSIG_ATOM_HAS_GRAVITY, .proc/gravity_check)
|
||||
if(isturf(parent))
|
||||
RegisterSignal(COMSIG_TURF_HAS_GRAVITY, .proc/turf_gravity_check)
|
||||
|
||||
gravity = forced_value
|
||||
|
||||
/datum/component/forced_gravity/proc/gravity_check(turf/location, list/gravs)
|
||||
if(!ignore_space && isspaceturf(location))
|
||||
return
|
||||
gravs += gravity
|
||||
|
||||
/datum/component/forced_gravity/proc/turf_gravity_check(atom/checker, list/gravs)
|
||||
return gravity_check(parent, gravs)
|
||||
+13
-17
@@ -445,26 +445,22 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
if(!T)
|
||||
return 0
|
||||
|
||||
//Gravity forced on the atom
|
||||
var/datum/component/forced_gravity/FG = GetComponent(/datum/component/forced_gravity)
|
||||
if(FG)
|
||||
if(!FG.ignore_space && isspaceturf(T))
|
||||
return 0
|
||||
else
|
||||
return FG.gravity
|
||||
var/list/forced_gravity = list()
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_HAS_GRAVITY, T, forced_gravity)
|
||||
if(!forced_gravity.len)
|
||||
SEND_SIGNAL(T, COMSIG_TURF_HAS_GRAVITY, src, forced_gravity)
|
||||
if(forced_gravity.len)
|
||||
var/max_grav
|
||||
for(var/i in forced_gravity)
|
||||
max_grav = max(max_grav, i)
|
||||
if(max_grav)
|
||||
return max_grav
|
||||
|
||||
//Gravity forced on the turf
|
||||
FG = T.GetComponent(/datum/component/forced_gravity)
|
||||
if(FG)
|
||||
if(!FG.ignore_space && isspaceturf(T))
|
||||
return 0
|
||||
else
|
||||
return FG.gravity
|
||||
|
||||
var/area/A = get_area(T)
|
||||
if(isspaceturf(T)) // Turf never has gravity
|
||||
return 0
|
||||
else if(A.has_gravity) // Areas which always has gravity
|
||||
|
||||
var/area/A = get_area(T)
|
||||
if(A.has_gravity) // Areas which always has gravity
|
||||
return A.has_gravity
|
||||
else
|
||||
// There's a gravity generator on our z level
|
||||
|
||||
Reference in New Issue
Block a user