mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-27 22:18:27 +01:00
Refactor move code
This commit is contained in:
@@ -377,10 +377,9 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
following = null
|
||||
return ..()
|
||||
|
||||
/mob/Move()
|
||||
/mob/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
update_following()
|
||||
update_following()
|
||||
|
||||
/mob/Life()
|
||||
// to catch teleports etc which directly set loc
|
||||
|
||||
@@ -6,30 +6,28 @@
|
||||
// This might be laggy, comment it out if there are problems.
|
||||
/mob/living/silicon/var/updating = 0
|
||||
|
||||
/mob/living/silicon/robot/Move()
|
||||
var/oldLoc = src.loc
|
||||
/mob/living/silicon/robot/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(provides_camera_vision())
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(BORG_CAMERA_BUFFER)
|
||||
if(oldLoc != src.loc)
|
||||
cameranet.updatePortableCamera(src.camera)
|
||||
updating = 0
|
||||
if(!provides_camera_vision())
|
||||
return
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(BORG_CAMERA_BUFFER)
|
||||
if(old_loc != src.loc)
|
||||
cameranet.updatePortableCamera(src.camera)
|
||||
updating = 0
|
||||
|
||||
/mob/living/silicon/AI/Move()
|
||||
var/oldLoc = src.loc
|
||||
/mob/living/silicon/ai/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(provides_camera_vision())
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(BORG_CAMERA_BUFFER)
|
||||
if(oldLoc != src.loc)
|
||||
cameranet.updateVisibility(oldLoc, 0)
|
||||
cameranet.updateVisibility(loc, 0)
|
||||
updating = 0
|
||||
if(!provides_camera_vision())
|
||||
return
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(BORG_CAMERA_BUFFER)
|
||||
if(old_loc != src.loc)
|
||||
cameranet.updateVisibility(old_loc, 0)
|
||||
cameranet.updateVisibility(loc, 0)
|
||||
updating = 0
|
||||
|
||||
#undef BORG_CAMERA_BUFFER
|
||||
|
||||
|
||||
@@ -4,18 +4,17 @@
|
||||
|
||||
/mob/living/var/updating_cult_vision = 0
|
||||
|
||||
/mob/living/Move()
|
||||
var/oldLoc = src.loc
|
||||
/mob/living/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(cultnet.provides_vision(src))
|
||||
if(!updating_cult_vision)
|
||||
updating_cult_vision = 1
|
||||
spawn(CULT_UPDATE_BUFFER)
|
||||
if(oldLoc != src.loc)
|
||||
cultnet.updateVisibility(oldLoc, 0)
|
||||
cultnet.updateVisibility(loc, 0)
|
||||
updating_cult_vision = 0
|
||||
if(!cultnet.provides_vision(src))
|
||||
return
|
||||
if(!updating_cult_vision)
|
||||
updating_cult_vision = 1
|
||||
spawn(CULT_UPDATE_BUFFER)
|
||||
if(old_loc != src.loc)
|
||||
cultnet.updateVisibility(old_loc, 0)
|
||||
cultnet.updateVisibility(loc, 0)
|
||||
updating_cult_vision = 0
|
||||
|
||||
#undef CULT_UPDATE_BUFFER
|
||||
|
||||
|
||||
@@ -33,15 +33,14 @@
|
||||
touching.clear_reagents()
|
||||
..()
|
||||
|
||||
/mob/living/carbon/Move(NewLoc, direct)
|
||||
/mob/living/carbon/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(src.nutrition && src.stat != 2)
|
||||
if(src.nutrition && src.stat != 2)
|
||||
src.nutrition -= DEFAULT_HUNGER_FACTOR/10
|
||||
if(src.m_intent == "run")
|
||||
src.nutrition -= DEFAULT_HUNGER_FACTOR/10
|
||||
if(src.m_intent == "run")
|
||||
src.nutrition -= DEFAULT_HUNGER_FACTOR/10
|
||||
if((FAT in src.mutations) && src.m_intent == "run" && src.bodytemperature <= 360)
|
||||
src.bodytemperature += 2
|
||||
if((FAT in src.mutations) && src.m_intent == "run" && src.bodytemperature <= 360)
|
||||
src.bodytemperature += 2
|
||||
|
||||
// Moving around increases germ_level faster
|
||||
if(germ_level < GERM_LEVEL_MOVE_CAP && prob(8))
|
||||
|
||||
@@ -33,52 +33,52 @@
|
||||
if (cell_use_power(A.active_usage))
|
||||
return ..()
|
||||
|
||||
/mob/living/silicon/robot/Move(a, b, flag)
|
||||
|
||||
/mob/living/silicon/robot/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
|
||||
if(module)
|
||||
if(module.type == /obj/item/weapon/robot_module/robot/janitor)
|
||||
var/turf/tile = loc
|
||||
if(isturf(tile))
|
||||
tile.clean_blood()
|
||||
if (istype(tile, /turf/simulated))
|
||||
var/turf/simulated/S = tile
|
||||
S.dirt = 0
|
||||
for(var/A in tile)
|
||||
if(istype(A, /obj/effect))
|
||||
if(istype(A, /obj/effect/rune) || istype(A, /obj/effect/decal/cleanable) || istype(A, /obj/effect/overlay))
|
||||
qdel(A)
|
||||
else if(istype(A, /obj/item))
|
||||
var/obj/item/cleaned_item = A
|
||||
cleaned_item.clean_blood()
|
||||
else if(istype(A, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/cleaned_human = A
|
||||
if(cleaned_human.lying)
|
||||
if(cleaned_human.head)
|
||||
cleaned_human.head.clean_blood()
|
||||
cleaned_human.update_inv_head(0)
|
||||
if(cleaned_human.wear_suit)
|
||||
cleaned_human.wear_suit.clean_blood()
|
||||
cleaned_human.update_inv_wear_suit(0)
|
||||
else if(cleaned_human.w_uniform)
|
||||
cleaned_human.w_uniform.clean_blood()
|
||||
cleaned_human.update_inv_w_uniform(0)
|
||||
if(cleaned_human.shoes)
|
||||
cleaned_human.shoes.clean_blood()
|
||||
cleaned_human.update_inv_shoes(0)
|
||||
cleaned_human.clean_blood(1)
|
||||
cleaned_human << "<font color='red'>[src] cleans your face!</font>"
|
||||
if(!module)
|
||||
return
|
||||
|
||||
if((module_state_1 && istype(module_state_1, /obj/item/weapon/storage/bag/ore)) || (module_state_2 && istype(module_state_2, /obj/item/weapon/storage/bag/ore)) || (module_state_3 && istype(module_state_3, /obj/item/weapon/storage/bag/ore))) //Borgs and drones can use their mining bags ~automagically~ if they're deployed in a slot. Only mining bags, as they're optimized for mass use.
|
||||
var/obj/item/weapon/storage/bag/ore/B = null
|
||||
if(istype(module_state_1, /obj/item/weapon/storage/bag/ore)) //First orebag has priority, if they for some reason have multiple.
|
||||
B = module_state_1
|
||||
else if(istype(module_state_2, /obj/item/weapon/storage/bag/ore))
|
||||
B = module_state_2
|
||||
else if(istype(module_state_3, /obj/item/weapon/storage/bag/ore))
|
||||
B = module_state_3
|
||||
var/turf/tile = loc
|
||||
if(isturf(tile))
|
||||
B.gather_all(tile, src, 1) //Shhh, unless the bag fills, don't spam the borg's chat with stuff that's going on every time they move!
|
||||
return
|
||||
//Borgs and drones can use their mining bags ~automagically~ if they're deployed in a slot. Only mining bags, as they're optimized for mass use.
|
||||
if(istype(module_state_1, /obj/item/weapon/storage/bag/ore) || istype(module_state_2, /obj/item/weapon/storage/bag/ore) || istype(module_state_3, /obj/item/weapon/storage/bag/ore))
|
||||
var/obj/item/weapon/storage/bag/ore/B = null
|
||||
if(istype(module_state_1, /obj/item/weapon/storage/bag/ore)) //First orebag has priority, if they for some reason have multiple.
|
||||
B = module_state_1
|
||||
else if(istype(module_state_2, /obj/item/weapon/storage/bag/ore))
|
||||
B = module_state_2
|
||||
else if(istype(module_state_3, /obj/item/weapon/storage/bag/ore))
|
||||
B = module_state_3
|
||||
var/turf/tile = loc
|
||||
if(isturf(tile))
|
||||
B.gather_all(tile, src, 1) //Shhh, unless the bag fills, don't spam the borg's chat with stuff that's going on every time they move!
|
||||
|
||||
if(istype(module, /obj/item/weapon/robot_module/robot/janitor) && isturf(loc))
|
||||
var/turf/tile = loc
|
||||
tile.clean_blood()
|
||||
if (istype(tile, /turf/simulated))
|
||||
var/turf/simulated/S = tile
|
||||
S.dirt = 0
|
||||
for(var/A in tile)
|
||||
if(istype(A, /obj/effect))
|
||||
if(istype(A, /obj/effect/rune) || istype(A, /obj/effect/decal/cleanable) || istype(A, /obj/effect/overlay))
|
||||
qdel(A)
|
||||
else if(istype(A, /obj/item))
|
||||
var/obj/item/cleaned_item = A
|
||||
cleaned_item.clean_blood()
|
||||
else if(istype(A, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/cleaned_human = A
|
||||
if(cleaned_human.lying)
|
||||
if(cleaned_human.head)
|
||||
cleaned_human.head.clean_blood()
|
||||
cleaned_human.update_inv_head(0)
|
||||
if(cleaned_human.wear_suit)
|
||||
cleaned_human.wear_suit.clean_blood()
|
||||
cleaned_human.update_inv_wear_suit(0)
|
||||
else if(cleaned_human.w_uniform)
|
||||
cleaned_human.w_uniform.clean_blood()
|
||||
cleaned_human.update_inv_w_uniform(0)
|
||||
if(cleaned_human.shoes)
|
||||
cleaned_human.shoes.clean_blood()
|
||||
cleaned_human.update_inv_shoes(0)
|
||||
cleaned_human.clean_blood(1)
|
||||
cleaned_human << "<font color='red'>[src] cleans your face!</font>"
|
||||
@@ -54,8 +54,8 @@
|
||||
var/step = get_step_to(src, food, 0)
|
||||
Move(step)
|
||||
|
||||
/mob/living/simple_mob/animal/goat/Move()
|
||||
..()
|
||||
/mob/living/simple_mob/animal/goat/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(!stat)
|
||||
for(var/obj/effect/plant/SV in loc)
|
||||
SV.die_off(1)
|
||||
|
||||
@@ -196,29 +196,15 @@
|
||||
next = null
|
||||
..()
|
||||
|
||||
/mob/living/simple_mob/animal/space/space_worm/Move()
|
||||
var/attachementNextPosition = loc
|
||||
/mob/living/simple_mob/animal/space/space_worm/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(previous)
|
||||
if(previous.z != z)
|
||||
previous.z_transitioning = TRUE
|
||||
else
|
||||
previous.z_transitioning = FALSE
|
||||
previous.forceMove(attachementNextPosition) // None of this 'ripped in half by an airlock' business.
|
||||
update_icon()
|
||||
|
||||
/mob/living/simple_mob/animal/space/space_worm/forceMove()
|
||||
var/attachementNextPosition = loc
|
||||
. = ..()
|
||||
if(.)
|
||||
if(previous)
|
||||
if(previous.z != z)
|
||||
previous.z_transitioning = TRUE
|
||||
else
|
||||
previous.z_transitioning = FALSE
|
||||
previous.forceMove(attachementNextPosition) // None of this 'ripped in half by an airlock' business. x 2
|
||||
update_icon()
|
||||
if(previous)
|
||||
if(previous.z != z)
|
||||
previous.z_transitioning = TRUE
|
||||
else
|
||||
previous.z_transitioning = FALSE
|
||||
previous.forceMove(old_loc) // None of this 'ripped in half by an airlock' business.
|
||||
update_icon()
|
||||
|
||||
/mob/living/simple_mob/animal/space/space_worm/head/Bump(atom/obstacle)
|
||||
if(open_maw && !stat && obstacle != previous)
|
||||
|
||||
@@ -366,17 +366,7 @@
|
||||
anim(mobloc,mob,'icons/mob/mob.dmi',,"shadow",,mob.dir)
|
||||
mob.forceMove(get_step(mob, direct))
|
||||
mob.dir = direct
|
||||
// Crossed is always a bit iffy
|
||||
for(var/obj/S in mob.loc)
|
||||
if(istype(S,/obj/effect/step_trigger) || istype(S,/obj/effect/beam))
|
||||
S.Crossed(mob)
|
||||
|
||||
var/area/A = get_area_master(mob)
|
||||
if(A)
|
||||
A.Entered(mob)
|
||||
if(isturf(mob.loc))
|
||||
var/turf/T = mob.loc
|
||||
T.Entered(mob)
|
||||
mob.Post_Incorpmove()
|
||||
return 1
|
||||
|
||||
@@ -468,13 +458,7 @@
|
||||
|
||||
/mob/proc/update_gravity()
|
||||
return
|
||||
/*
|
||||
// The real Move() proc is above, but touching that massive block just to put this in isn't worth it.
|
||||
/mob/Move(var/newloc, var/direct)
|
||||
. = ..(newloc, direct)
|
||||
if(.)
|
||||
post_move(newloc, direct)
|
||||
*/
|
||||
|
||||
// Called when a mob successfully moves.
|
||||
// Would've been an /atom/movable proc but it caused issues.
|
||||
/mob/Moved(atom/oldloc)
|
||||
|
||||
Reference in New Issue
Block a user