mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-28 07:20:09 +01:00
Refactors gravity checking (#4591)
Removes a lot of duplicated or redundant code from areas when checking gravity.
This commit is contained in:
+6
-11
@@ -316,7 +316,7 @@ var/list/mob/living/forced_ambiance_list = new
|
||||
L.lastarea = get_area(L.loc)
|
||||
var/area/newarea = get_area(L.loc)
|
||||
var/area/oldarea = L.lastarea
|
||||
if((oldarea.has_gravity == 0) && (newarea.has_gravity == 1) && (L.m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together.
|
||||
if((oldarea.has_gravity() == 0) && (newarea.has_gravity() == 1) && (L.m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together.
|
||||
thunk(L)
|
||||
L.update_floating( L.Check_Dense_Object() )
|
||||
|
||||
@@ -352,11 +352,11 @@ var/list/mob/living/forced_ambiance_list = new
|
||||
L << sound(sound, repeat = 0, wait = 0, volume = 25, channel = 1)
|
||||
L.client.played = world.time
|
||||
|
||||
/area/proc/gravitychange(var/gravitystate = 0, var/area/A)
|
||||
A.has_gravity = gravitystate
|
||||
/area/proc/gravitychange(var/gravitystate = 0)
|
||||
has_gravity = gravitystate
|
||||
|
||||
for(var/mob/M in A)
|
||||
if(has_gravity)
|
||||
for(var/mob/M in src)
|
||||
if(has_gravity())
|
||||
thunk(M)
|
||||
M.update_floating( M.Check_Dense_Object() )
|
||||
|
||||
@@ -395,13 +395,8 @@ var/list/mob/living/forced_ambiance_list = new
|
||||
if(!T)
|
||||
T = get_turf(AT)
|
||||
var/area/A = get_area(T)
|
||||
if(istype(T, /turf/space)) //because space
|
||||
return 0
|
||||
else if(A && A.has_gravity)
|
||||
if(A && A.has_gravity())
|
||||
return 1
|
||||
else
|
||||
if(T && length(SSmachinery.gravity_generators))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//A useful proc for events.
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
|
||||
|
||||
while(src && target &&((((src.x < target.x && dx == EAST) || (src.x > target.x && dx == WEST)) && dist_travelled < range) || (a && a.has_gravity == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf))
|
||||
while(src && target &&((((src.x < target.x && dx == EAST) || (src.x > target.x && dx == WEST)) && dist_travelled < range) || (a && a.has_gravity() == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf))
|
||||
// only stop when we've gone the whole distance (or max throw range) and are on a non-space tile, or hit something, or hit the end of the map, or someone picks it up
|
||||
if(error < 0)
|
||||
var/atom/step = get_step(src, dy)
|
||||
@@ -152,7 +152,7 @@
|
||||
a = get_area(src.loc)
|
||||
else
|
||||
var/error = dist_y/2 - dist_x
|
||||
while(src && target &&((((src.y < target.y && dy == NORTH) || (src.y > target.y && dy == SOUTH)) && dist_travelled < range) || (a && a.has_gravity == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf))
|
||||
while(src && target &&((((src.y < target.y && dy == NORTH) || (src.y > target.y && dy == SOUTH)) && dist_travelled < range) || (a && a.has_gravity() == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf))
|
||||
// only stop when we've gone the whole distance (or max throw range) and are on a non-space tile, or hit something, or hit the end of the map, or someone picks it up
|
||||
if(error < 0)
|
||||
var/atom/step = get_step(src, dx)
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
W.set_color()
|
||||
W.set_up(my_target)
|
||||
|
||||
if((istype(usr.loc, /turf/space)) || (usr.lastarea.has_gravity == 0))
|
||||
if((istype(usr.loc, /turf/space)) || (usr.lastarea.has_gravity() == 0))
|
||||
user.inertia_dir = get_dir(target, user)
|
||||
step(user, user.inertia_dir)
|
||||
else
|
||||
|
||||
@@ -192,7 +192,7 @@ var/const/enterloopsanity = 100
|
||||
var/mob/M = A
|
||||
if(!M.lastarea)
|
||||
M.lastarea = get_area(M.loc)
|
||||
if(M.lastarea.has_gravity == 0)
|
||||
if(M.lastarea.has_gravity() == 0)
|
||||
inertial_drift(M)
|
||||
|
||||
// Footstep SFX logic moved to human_movement.dm - Move().
|
||||
@@ -394,7 +394,7 @@ var/const/enterloopsanity = 100
|
||||
/turf/MouseDrop_T(atom/movable/O as mob|obj, mob/user as mob)
|
||||
var/turf/T = get_turf(user)
|
||||
var/area/A = T.loc
|
||||
if((istype(A) && !(A.has_gravity)) || (istype(T,/turf/space)))
|
||||
if((istype(A) && !(A.has_gravity())) || (istype(T,/turf/space)))
|
||||
return
|
||||
if(istype(O, /obj/screen))
|
||||
return
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
loadProgram(current_map.holodeck_programs["turnoff"], 0)
|
||||
|
||||
if(!linkedholodeck.has_gravity)
|
||||
linkedholodeck.gravitychange(1,linkedholodeck)
|
||||
linkedholodeck.gravitychange(TRUE)
|
||||
|
||||
active = 0
|
||||
use_power = 1
|
||||
@@ -333,17 +333,17 @@
|
||||
active = 1
|
||||
use_power = 1
|
||||
|
||||
if(A.has_gravity)
|
||||
A.gravitychange(0,A)
|
||||
if(A.has_gravity())
|
||||
A.gravitychange(FALSE)
|
||||
else
|
||||
A.gravitychange(1,A)
|
||||
A.gravitychange(TRUE)
|
||||
|
||||
/obj/machinery/computer/HolodeckControl/proc/emergencyShutdown()
|
||||
//Turn it back to the regular non-holographic room
|
||||
loadProgram(current_map.holodeck_programs["turnoff"], 0)
|
||||
|
||||
if(!linkedholodeck.has_gravity)
|
||||
linkedholodeck.gravitychange(1,linkedholodeck)
|
||||
linkedholodeck.gravitychange(TRUE)
|
||||
|
||||
active = 0
|
||||
use_power = 1
|
||||
|
||||
@@ -90,7 +90,7 @@ note dizziness decrements automatically in the mob's Life() proc.
|
||||
var/turf/turf = get_turf(src)
|
||||
if(!istype(turf,/turf/space))
|
||||
var/area/A = turf.loc
|
||||
if(istype(A) && A.has_gravity)
|
||||
if(istype(A) && A.has_gravity())
|
||||
make_floating(0)
|
||||
return
|
||||
else if (Check_Shoegrip())
|
||||
|
||||
@@ -327,7 +327,7 @@ var/list/slot_equipment_priority = list( \
|
||||
|
||||
if(!src.lastarea)
|
||||
src.lastarea = get_area(src.loc)
|
||||
if((istype(src.loc, /turf/space)) || (src.lastarea.has_gravity == 0))
|
||||
if((istype(src.loc, /turf/space)) || (src.lastarea.has_gravity() == 0))
|
||||
src.inertia_dir = get_dir(target, src)
|
||||
step(src, inertia_dir)
|
||||
|
||||
|
||||
@@ -576,7 +576,7 @@ default behaviour is:
|
||||
|
||||
if(!istype(M.loc, /turf/space))
|
||||
var/area/A = get_area(M)
|
||||
if(A.has_gravity)
|
||||
if(A.has_gravity())
|
||||
//this is the gay blood on floor shit -- Added back -- Skie
|
||||
if (M.lying && (prob(M.getBruteLoss() / 6)))
|
||||
var/turf/location = M.loc
|
||||
|
||||
@@ -436,7 +436,7 @@
|
||||
|
||||
if(!lastarea)
|
||||
lastarea = get_area(loc)
|
||||
if(!lastarea.has_gravity)
|
||||
if(!lastarea.has_gravity())
|
||||
return 0
|
||||
|
||||
return 1
|
||||
@@ -451,7 +451,7 @@
|
||||
return 1
|
||||
else
|
||||
var/area/A = T.loc
|
||||
if(A.has_gravity || shoegrip)
|
||||
if(A.has_gravity() || shoegrip)
|
||||
return 1
|
||||
|
||||
for(var/obj/O in orange(1, src))
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
// If we want to move up,but the current area has gravity. Invoke CanAvoidGravity()
|
||||
// to check if this move is possible.
|
||||
if(direction == UP && area.has_gravity && !CanAvoidGravity())
|
||||
if(direction == UP && area.has_gravity() && !CanAvoidGravity())
|
||||
to_chat(src, "<span class='warning'>Gravity stops you from moving upward.</span>")
|
||||
return FALSE
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
/atom/movable/proc/fall_impact(levels_fallen, stopped_early = FALSE)
|
||||
// No gravity, stop falling into spess!
|
||||
var/area/area = get_area(src)
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity))
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity()))
|
||||
return FALSE
|
||||
|
||||
visible_message("\The [src] falls and lands on \the [loc]!", "You hear a thud!")
|
||||
@@ -325,7 +325,7 @@
|
||||
/mob/living/fall_impact(levels_fallen, stopped_early = FALSE)
|
||||
// No gravity, stop falling into spess!
|
||||
var/area/area = get_area(src)
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity))
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity()))
|
||||
return FALSE
|
||||
|
||||
visible_message("\The [src] falls and lands on \the [loc]!",
|
||||
@@ -354,7 +354,7 @@
|
||||
/mob/living/carbon/human/fall_impact(levels_fallen, stopped_early = FALSE)
|
||||
// No gravity, stop falling into spess!
|
||||
var/area/area = get_area(src)
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity))
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity()))
|
||||
return FALSE
|
||||
|
||||
var/obj/item/weapon/rig/rig = get_rig()
|
||||
@@ -503,7 +503,7 @@
|
||||
/atom/movable/proc/fall_collateral(levels_fallen, stopped_early = FALSE)
|
||||
// No gravity, stop falling into spess!
|
||||
var/area/area = get_area(src)
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity))
|
||||
if (istype(loc, /turf/space) || (area && !area.has_gravity()))
|
||||
return null
|
||||
|
||||
var/list/fall_specs = fall_get_specs(levels_fallen)
|
||||
|
||||
@@ -341,13 +341,13 @@
|
||||
var/alert = 0
|
||||
var/area/area = get_area(src)
|
||||
if(new_state) // If we turned on
|
||||
if(gravity_in_level() == 0)
|
||||
if(!area.has_gravity())
|
||||
alert = 1
|
||||
gravity_is_on = 1
|
||||
investigate_log("was brought online and is now producing gravity for this level.", "gravity")
|
||||
message_admins("The gravity generator was brought online. (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
|
||||
else
|
||||
if(gravity_in_level() == 1)
|
||||
if(area.has_gravity())
|
||||
alert = 1
|
||||
gravity_is_on = 0
|
||||
investigate_log("was brought offline and there is now no gravity for this level.", "gravity")
|
||||
@@ -423,14 +423,6 @@
|
||||
shake_camera(M, 5, 1)
|
||||
M.playsound_local(our_turf, 'sound/effects/alert.ogg', 100, 1, 0.5)
|
||||
|
||||
/obj/machinery/gravity_generator/main/proc/gravity_in_level()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!T)
|
||||
return 0
|
||||
if(SSmachinery.gravity_generators)
|
||||
return length(SSmachinery.gravity_generators)
|
||||
return 0
|
||||
|
||||
/obj/machinery/gravity_generator/main/proc/update_list()
|
||||
var/turf/T = get_turf(src.loc)
|
||||
if(T)
|
||||
@@ -439,18 +431,11 @@
|
||||
|
||||
if(on)
|
||||
for(var/area/A in localareas)
|
||||
A.has_gravity = 1
|
||||
if(round_start)
|
||||
A.gravitychange(A.has_gravity,A,1)
|
||||
else
|
||||
A.gravitychange(A.has_gravity,A)
|
||||
if(round_start == 1)
|
||||
round_start = 0
|
||||
A.gravitychange(TRUE)
|
||||
SSmachinery.gravity_generators += src
|
||||
else
|
||||
for(var/area/A in localareas)
|
||||
A.has_gravity = 0
|
||||
A.gravitychange(A.has_gravity,A)
|
||||
A.gravitychange(FALSE)
|
||||
SSmachinery.gravity_generators -= src
|
||||
|
||||
/obj/machinery/gravity_generator/main/Initialize()
|
||||
|
||||
@@ -175,9 +175,8 @@
|
||||
/obj/item/projectile/energy/gravitydisabler/on_impact(atom/target)
|
||||
. = ..()
|
||||
var/area/A = get_area(target)
|
||||
if(A && A.has_gravity == 1)
|
||||
A.has_gravity = 0
|
||||
A.gravitychange(A.has_gravity,A)
|
||||
if(A && A.has_gravity())
|
||||
A.gravitychange(FALSE)
|
||||
addtimer(CALLBACK(src, .proc/turnongravity), 150)
|
||||
|
||||
if(istype(target, /obj/machinery/gravity_generator/main))
|
||||
@@ -185,8 +184,7 @@
|
||||
T.eshutoff()
|
||||
|
||||
/obj/item/projectile/energy/gravitydisabler/proc/turnongravity(var/area/A)
|
||||
A.has_gravity = 1
|
||||
A.gravitychange(A.has_gravity,A)
|
||||
A.gravitychange(TRUE)
|
||||
|
||||
/obj/item/projectile/energy/bee
|
||||
name = "bees"
|
||||
|
||||
Reference in New Issue
Block a user