mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Component strengthening course (#40480)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
||||||
var/list/orbiters
|
var/list/orbiters
|
||||||
var/datum/callback/orbiter_spy
|
var/datum/callback/orbiter_spy
|
||||||
|
var/datum/callback/orbited_spy
|
||||||
|
|
||||||
//radius: range to orbit at, radius of the circle formed by orbiting (in pixels)
|
//radius: range to orbit at, radius of the circle formed by orbiting (in pixels)
|
||||||
//clockwise: whether you orbit clockwise or anti clockwise
|
//clockwise: whether you orbit clockwise or anti clockwise
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
orbiters = list()
|
orbiters = list()
|
||||||
orbiter_spy = CALLBACK(src, .proc/orbiter_move_react)
|
orbiter_spy = CALLBACK(src, .proc/orbiter_move_react)
|
||||||
|
orbited_spy = CALLBACK(src, .proc/move_react)
|
||||||
|
|
||||||
var/atom/master = parent
|
var/atom/master = parent
|
||||||
master.orbiters = src
|
master.orbiters = src
|
||||||
@@ -22,17 +24,25 @@
|
|||||||
begin_orbit(orbiter, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
begin_orbit(orbiter, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
||||||
|
|
||||||
/datum/component/orbiter/RegisterWithParent()
|
/datum/component/orbiter/RegisterWithParent()
|
||||||
if(ismovableatom(parent))
|
var/atom/master = parent
|
||||||
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/move_react)
|
if(ismovableatom(master))
|
||||||
|
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, orbited_spy)
|
||||||
|
var/atom/target = master.loc
|
||||||
|
while(!isturf(target))
|
||||||
|
RegisterSignal(target, COMSIG_MOVABLE_MOVED, orbited_spy)
|
||||||
|
target = target.loc
|
||||||
|
|
||||||
/datum/component/orbiter/UnregisterFromParent()
|
/datum/component/orbiter/UnregisterFromParent()
|
||||||
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
|
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
|
||||||
|
|
||||||
/datum/component/orbiter/Destroy()
|
/datum/component/orbiter/Destroy()
|
||||||
var/atom/master = parent
|
var/atom/master = parent
|
||||||
master.orbiters = src
|
master.orbiters = null
|
||||||
|
for(var/i in orbiters)
|
||||||
|
end_orbit(i)
|
||||||
orbiters = null
|
orbiters = null
|
||||||
orbiter_spy = null
|
QDEL_NULL(orbiter_spy)
|
||||||
|
QDEL_NULL(orbited_spy)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/datum/component/orbiter/InheritComponent(datum/component/orbiter/newcomp, original, list/arguments)
|
/datum/component/orbiter/InheritComponent(datum/component/orbiter/newcomp, original, list/arguments)
|
||||||
@@ -46,9 +56,17 @@
|
|||||||
orbiters += newcomp.orbiters
|
orbiters += newcomp.orbiters
|
||||||
|
|
||||||
/datum/component/orbiter/proc/begin_orbit(atom/movable/orbiter, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
/datum/component/orbiter/proc/begin_orbit(atom/movable/orbiter, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
||||||
|
if(!isnull(orbiters[orbiter]))
|
||||||
|
return // We're already here
|
||||||
|
if(orbiter == parent) // Stop it, this is silly
|
||||||
|
if(!length(orbiters))
|
||||||
|
qdel(src)
|
||||||
|
return
|
||||||
|
if(orbiter.orbiting)
|
||||||
|
orbiter.orbiting.end_orbit(orbiter)
|
||||||
orbiters[orbiter] = lockinorbit
|
orbiters[orbiter] = lockinorbit
|
||||||
orbiter.orbiting = src
|
orbiter.orbiting = src
|
||||||
RegisterSignal(orbiter, list(COMSIG_MOVABLE_MOVED), orbiter_spy)
|
RegisterSignal(orbiter, COMSIG_MOVABLE_MOVED, orbiter_spy)
|
||||||
var/matrix/initial_transform = matrix(orbiter.transform)
|
var/matrix/initial_transform = matrix(orbiter.transform)
|
||||||
|
|
||||||
// Head first!
|
// Head first!
|
||||||
@@ -74,17 +92,40 @@
|
|||||||
/datum/component/orbiter/proc/end_orbit(atom/movable/orbiter)
|
/datum/component/orbiter/proc/end_orbit(atom/movable/orbiter)
|
||||||
if(isnull(orbiters[orbiter]))
|
if(isnull(orbiters[orbiter]))
|
||||||
return
|
return
|
||||||
|
UnregisterSignal(orbiter, COMSIG_MOVABLE_MOVED)
|
||||||
orbiter.SpinAnimation(0, 0)
|
orbiter.SpinAnimation(0, 0)
|
||||||
orbiters -= orbiter
|
orbiters -= orbiter
|
||||||
orbiter.stop_orbit(src)
|
orbiter.stop_orbit(src)
|
||||||
if(!length(orbiters))
|
orbiter.orbiting = null
|
||||||
|
if(!length(orbiters) && !QDELING(src))
|
||||||
qdel(src)
|
qdel(src)
|
||||||
|
|
||||||
|
// This proc can receive signals by either the thing being directly orbited or anything holding it
|
||||||
/datum/component/orbiter/proc/move_react(atom/orbited, atom/oldloc, direction)
|
/datum/component/orbiter/proc/move_react(atom/orbited, atom/oldloc, direction)
|
||||||
var/turf/oldturf = get_turf(oldloc)
|
var/turf/oldturf = get_turf(oldloc)
|
||||||
var/turf/newturf = get_turf(parent)
|
var/turf/newturf = get_turf(parent)
|
||||||
|
if(newturf == oldturf)
|
||||||
|
return
|
||||||
|
if(!newturf)
|
||||||
|
qdel(src)
|
||||||
|
|
||||||
|
// Handling the signals of stuff holding us (or not anymore)
|
||||||
|
// These are prety rarely activated, how often are you following something in a bag?
|
||||||
|
if(!isturf(oldloc)) // We used to be registered to it, probably
|
||||||
|
var/atom/target = oldloc
|
||||||
|
while(!isturf(target))
|
||||||
|
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
|
||||||
|
target = target.loc
|
||||||
|
if(orbited.loc != newturf) // We want to know when anything holding us moves too
|
||||||
|
var/atom/target = orbited.loc
|
||||||
|
while(!isturf(target))
|
||||||
|
RegisterSignal(target, COMSIG_MOVABLE_MOVED, orbited_spy, TRUE)
|
||||||
|
target = target.loc
|
||||||
|
|
||||||
for(var/i in orbiters)
|
for(var/i in orbiters)
|
||||||
var/atom/movable/thing = i
|
var/atom/movable/thing = i
|
||||||
|
if(thing.loc == newturf)
|
||||||
|
continue
|
||||||
if(!newturf || (!orbiters[thing] && thing.loc != oldturf && thing.loc != newturf))
|
if(!newturf || (!orbiters[thing] && thing.loc != oldturf && thing.loc != newturf))
|
||||||
end_orbit(thing)
|
end_orbit(thing)
|
||||||
continue
|
continue
|
||||||
@@ -99,7 +140,7 @@
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
|
|
||||||
/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lockinorbit = FALSE)
|
/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lockinorbit = FALSE)
|
||||||
if(!istype(A))
|
if(!istype(A) || !get_turf(A))
|
||||||
return
|
return
|
||||||
|
|
||||||
return A.AddComponent(/datum/component/orbiter, src, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
return A.AddComponent(/datum/component/orbiter, src, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
/mob/camera/forceMove(atom/destination)
|
/mob/camera/forceMove(atom/destination)
|
||||||
|
var/oldloc = loc
|
||||||
loc = destination
|
loc = destination
|
||||||
|
Moved(oldloc, NONE, TRUE)
|
||||||
|
|
||||||
/mob/camera/emote(act, m_type=1, message = null, intentional = FALSE)
|
/mob/camera/emote(act, m_type=1, message = null, intentional = FALSE)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -31,7 +31,16 @@ INITIALIZE_IMMEDIATE(/mob/dead)
|
|||||||
return
|
return
|
||||||
|
|
||||||
/mob/dead/forceMove(atom/destination)
|
/mob/dead/forceMove(atom/destination)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
var/turf/old_turf = get_turf(src)
|
||||||
|
var/turf/new_turf = get_turf(destination)
|
||||||
|
if (old_turf?.z != new_turf?.z)
|
||||||
|
onTransitZ(old_turf?.z, new_turf?.z)
|
||||||
|
var/oldloc = loc
|
||||||
|
>>>>>>> 1cb74aff0b... Component strengthening course (#40480)
|
||||||
loc = destination
|
loc = destination
|
||||||
|
Moved(oldloc, NONE, TRUE)
|
||||||
|
|
||||||
/mob/dead/Stat()
|
/mob/dead/Stat()
|
||||||
..()
|
..()
|
||||||
|
|||||||
Reference in New Issue
Block a user