Refactor move code

This commit is contained in:
Aronai Sieyes
2020-04-26 16:42:50 -04:00
parent 5874df8756
commit d3da6ae4a5
45 changed files with 359 additions and 429 deletions
+9 -13
View File
@@ -176,19 +176,15 @@
add_fingerprint(user)
return M
/atom/movable/proc/handle_buckled_mob_movement(newloc,direct)
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/L = A
// if(!L.Move(newloc, direct))
if(!L.forceMove(newloc, direct))
loc = L.loc
last_move = L.last_move
L.inertia_dir = last_move
return FALSE
else
L.set_dir(dir)
return TRUE
/atom/movable/proc/handle_buckled_mob_movement(atom/old_loc, direct)
for(var/A in buckled_mobs)
var/mob/living/L = A
L.forceMove(loc, direct)
L.last_move = last_move
L.inertia_dir = last_move
if(!buckle_dir)
L.set_dir(dir)
/atom/movable/proc/can_buckle_check(mob/living/M, forced = FALSE)
if(!buckled_mobs)
+8 -9
View File
@@ -113,12 +113,11 @@ steam.start() -- spawns the effect
T.hotspot_expose(1000,100)
return ..()
/obj/effect/effect/sparks/Move()
..()
var/turf/T = src.loc
if (istype(T, /turf))
/obj/effect/effect/sparks/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
if(isturf(loc))
var/turf/T = loc
T.hotspot_expose(1000,100)
return
/datum/effect/effect/system/spark_spread
var/total_sparks = 0 // To stop it being spammed and lagging!
@@ -225,8 +224,8 @@ steam.start() -- spawns the effect
time_to_live = 600
//var/list/projectiles
/obj/effect/effect/smoke/bad/Move()
..()
/obj/effect/effect/smoke/bad/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
for(var/mob/living/L in get_turf(src))
affect(L)
@@ -281,8 +280,8 @@ steam.start() -- spawns the effect
STOP_PROCESSING(SSobj, src)
return ..()
/obj/effect/effect/smoke/elemental/Move()
..()
/obj/effect/effect/smoke/elemental/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
for(var/mob/living/L in range(1, src))
affect(L)
@@ -12,10 +12,6 @@
qdel(src)
return
/obj/effect/expl_particles/Move()
..()
return
/datum/effect/system/expl_particles
var/number = 10
var/turf/location
+3 -3
View File
@@ -18,12 +18,12 @@
break
..() // delete target
Move()
..()
Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
// After target moves, check for nearby stakes. If associated, move to target
for(var/obj/structure/target_stake/M in view(3,src))
if(M.density == 0 && M.pinned_target == src)
M.loc = loc
M.forceMove(loc)
// This may seem a little counter-intuitive but I assure you that's for a purpose.
// Stakes are the ones that carry targets, yes, but in the stake code we set
@@ -122,18 +122,6 @@
if(!has_buckled_mobs())
qdel(src)
/obj/effect/energy_net/Move()
..()
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/occupant = A
occupant.buckled = null
occupant.forceMove(src.loc)
occupant.buckled = src
if (occupant && (src.loc != occupant.loc))
unbuckle_mob(occupant)
qdel(src)
/obj/effect/energy_net/user_unbuckle_mob(mob/living/buckled_mob, mob/user)
user.setClickCooldown(user.get_attack_speed())
visible_message("<span class='danger'>[user] begins to tear at \the [src]!</span>")
@@ -145,7 +145,7 @@
bound_height = width * world.icon_size
update_state()
Move()
Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
if(dir in list(EAST, WEST))
bound_width = width * world.icon_size
-9
View File
@@ -230,15 +230,6 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
to_chat(user, "<span class='notice'>You'll need the keys in one of your hands to drive this [callme].</span>")
/obj/structure/bed/chair/janicart/Move()
..()
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/L = A
if(L.buckled == src)
L.loc = loc
/obj/structure/bed/chair/janicart/post_buckle_mob(mob/living/M)
update_mob()
return ..()
@@ -286,15 +286,10 @@
held = null
/obj/structure/bed/roller/Move()
..()
/obj/structure/bed/roller/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
playsound(src, 'sound/effects/roll.ogg', 100, 1)
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/L = A
if(L.buckled == src)
L.loc = src.loc
/obj/structure/bed/roller/post_buckle_mob(mob/living/M as mob)
if(M.buckled == src)
@@ -140,22 +140,24 @@
return
..()
/obj/structure/bed/chair/office/Move()
..()
/obj/structure/bed/chair/office/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
playsound(src, 'sound/effects/roll.ogg', 100, 1)
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/occupant = A
occupant.buckled = null
occupant.Move(src.loc)
occupant.buckled = src
if (occupant && (src.loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)
Bump(O)
else
unbuckle_mob()
/obj/structure/bed/chair/office/handle_buckled_mob_movement(atom/new_loc, direction)
for(var/A in buckled_mobs)
var/mob/living/occupant = A
occupant.buckled = null
occupant.Move(src.loc)
occupant.buckled = src
if (occupant && (src.loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)
Bump(O)
else
unbuckle_mob()
/obj/structure/bed/chair/office/Bump(atom/A)
..()
@@ -91,8 +91,9 @@
create_track()
driving = 0
/obj/structure/bed/chair/wheelchair/Move()
..()
/obj/structure/bed/chair/wheelchair/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
cut_overlays()
playsound(src, 'sound/effects/roll.ogg', 75, 1)
if(has_buckled_mobs())
+3 -3
View File
@@ -8,11 +8,11 @@
w_class = ITEMSIZE_HUGE
var/obj/item/target/pinned_target // the current pinned target
Move()
..()
Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
// Move the pinned target along with the stake
if(pinned_target in view(3, src))
pinned_target.loc = loc
pinned_target.forceMove(loc)
else // Sanity check: if the pinned target can't be found in immediate view
pinned_target = null
+1 -1
View File
@@ -413,7 +413,7 @@
/obj/structure/window/Move()
var/ini_dir = dir
update_nearby_tiles(need_rebuild=1)
..()
. = ..()
set_dir(ini_dir)
update_nearby_tiles(need_rebuild=1)