Merge pull request #8659 from Ghommie/Ghommie-cit57

ports "Componentizes orbiting"
This commit is contained in:
kevinz000
2019-06-23 06:50:32 -07:00
committed by GitHub
19 changed files with 223 additions and 245 deletions
+1 -4
View File
@@ -342,10 +342,7 @@
if(cooldown>world.time)
to_chat(owner, "<span class='cultbold'>You aren't ready to place another blood mark yet!</span>")
return
if(owner.orbiting && owner.orbiting.orbiting)
target = owner.orbiting.orbiting
else
target = get_turf(owner)
target = owner.orbiting?.parent || get_turf(owner)
if(!target)
return
C.cult_team.blood_target = target
@@ -273,23 +273,12 @@
to_chat(user, "<span class='notice'>You release the wisp. It begins to bob around your head.</span>")
icon_state = "lantern"
wisp.orbit(user, 20)
user.update_sight()
SSblackbox.record_feedback("tally", "wisp_lantern", 1, "Freed")
else
to_chat(user, "<span class='notice'>You return the wisp to the lantern.</span>")
var/mob/target
if(wisp.orbiting)
target = wisp.orbiting.orbiting
wisp.stop_orbit()
wisp.forceMove(src)
if (istype(target))
target.update_sight()
to_chat(target, "<span class='notice'>Your vision returns to normal.</span>")
icon_state = "lantern-blue"
wisp.forceMove(src)
SSblackbox.record_feedback("tally", "wisp_lantern", 1, "Returned")
/obj/item/wisp_lantern/Initialize()
@@ -302,7 +291,7 @@
qdel(wisp)
else
wisp.visible_message("<span class='notice'>[wisp] has a sad feeling for a moment, then it passes.</span>")
..()
return ..()
/obj/effect/wisp
name = "friendly wisp"
@@ -314,6 +303,25 @@
var/sight_flags = SEE_MOBS
var/lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE
/obj/effect/wisp/orbit(atom/thing, radius, clockwise, rotation_speed, rotation_segments, pre_rotation, lockinorbit)
. = ..()
if(ismob(thing))
RegisterSignal(thing, COMSIG_MOB_UPDATE_SIGHT, .proc/update_user_sight)
var/mob/being = thing
being.update_sight()
to_chat(thing, "<span class='notice'>The wisp enhances your vision.</span>")
/obj/effect/wisp/stop_orbit(datum/component/orbiter/orbits)
. = ..()
if(ismob(orbits.parent))
UnregisterSignal(orbits.parent, COMSIG_MOB_UPDATE_SIGHT)
to_chat(orbits.parent, "<span class='notice'>Your vision returns to normal.</span>")
/obj/effect/wisp/proc/update_user_sight(mob/user)
user.sight |= sight_flags
if(!isnull(lighting_alpha))
user.lighting_alpha = min(user.lighting_alpha, lighting_alpha)
//Red/Blue Cubes
/obj/item/warp_cube
name = "blue cube"
@@ -781,19 +789,17 @@
var/turf/T = get_turf(src)
var/list/contents = T.GetAllContents()
var/mob/dead/observer/current_spirits = list()
var/list/orbiters = list()
for(var/thing in contents)
var/atom/A = thing
if (A.orbiters)
orbiters += A.orbiters
A.transfer_observers_to(src)
for(var/thing in orbiters)
var/datum/orbit/O = thing
if (isobserver(O.orbiter))
var/mob/dead/observer/G = O.orbiter
ghost_counter++
G.invisibility = 0
current_spirits |= G
for(var/i in orbiters?.orbiters)
if(!isobserver(i))
continue
var/mob/dead/observer/G = i
ghost_counter++
G.invisibility = 0
current_spirits |= G
for(var/mob/dead/observer/G in spirits - current_spirits)
G.invisibility = GLOB.observer_default_invisibility
+2
View File
@@ -26,7 +26,9 @@
return
/mob/camera/forceMove(atom/destination)
var/oldloc = loc
loc = destination
Moved(oldloc, NONE, TRUE)
/mob/camera/emote(act, m_type=1, message = null, intentional = FALSE)
return
+2
View File
@@ -34,7 +34,9 @@ INITIALIZE_IMMEDIATE(/mob/dead)
var/turf/new_turf = get_turf(destination)
if (old_turf?.z != new_turf?.z)
onTransitZ(old_turf?.z, new_turf?.z)
var/oldloc = loc
loc = destination
Moved(oldloc, NONE, TRUE)
/mob/dead/Stat()
..()
+3 -6
View File
@@ -429,9 +429,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/orbitsize = (I.Width()+I.Height())*0.5
orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25)
if(orbiting && orbiting.orbiting != target)
to_chat(src, "<span class='notice'>Now orbiting [target].</span>")
var/rot_seg
switch(ghost_orbit)
@@ -450,10 +447,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/orbit()
setDir(2)//reset dir so the right directional sprites show up
..()
return ..()
/mob/dead/observer/stop_orbit()
..()
/mob/dead/observer/stop_orbit(datum/component/orbiter/orbits)
. = ..()
//restart our floating animation after orbit is done.
pixel_y = 0
animate(src, pixel_y = 2, time = 10, loop = -1)
+1 -7
View File
@@ -871,13 +871,7 @@
return
/mob/proc/update_sight()
for(var/O in orbiters)
var/datum/orbit/orbit = O
var/obj/effect/wisp/wisp = orbit.orbiter
if (istype(wisp))
sight |= wisp.sight_flags
if(!isnull(wisp.lighting_alpha))
lighting_alpha = min(lighting_alpha, wisp.lighting_alpha)
SEND_SIGNAL(src, COMSIG_MOB_UPDATE_SIGHT)
sync_lighting_plane_alpha()
+3 -3
View File
@@ -148,7 +148,7 @@
if(INCORPOREAL_MOVE_BASIC)
var/T = get_step(L,direct)
if(T)
L.loc = T
L.forceMove(T)
L.setDir(direct)
if(INCORPOREAL_MOVE_SHADOW)
if(prob(50))
@@ -190,7 +190,7 @@
new /obj/effect/temp_visual/dir_setting/ninja/shadow(mobloc, L.dir)
var/T = get_step(L,direct)
if(T)
L.loc = T
L.forceMove(T)
L.setDir(direct)
if(INCORPOREAL_MOVE_JAUNT) //Incorporeal move, but blocked by holy-watered tiles and salt piles.
var/turf/open/floor/stepTurf = get_step(L, direct)
@@ -209,7 +209,7 @@
to_chat(L, "<span class='warning'>Holy energies block your path!</span>")
return
L.loc = get_step(L, direct)
L.forceMove(stepTurf)
L.setDir(direct)
return TRUE
-135
View File
@@ -1,135 +0,0 @@
/datum/orbit
var/atom/movable/orbiter
var/atom/orbiting
var/lock = TRUE
var/turf/lastloc
var/lastprocess
/datum/orbit/New(_orbiter, _orbiting, _lock)
orbiter = _orbiter
orbiting = _orbiting
SSorbit.processing += src
if (!orbiting.orbiters)
orbiting.orbiters = list()
orbiting.orbiters += src
if (orbiter.orbiting)
orbiter.stop_orbit()
orbiter.orbiting = src
Check()
lock = _lock
//do not qdel directly, use stop_orbit on the orbiter. (This way the orbiter can bind to the orbit stopping)
/datum/orbit/Destroy(force = FALSE)
SSorbit.processing -= src
if (orbiter)
orbiter.orbiting = null
orbiter = null
if (orbiting)
if (orbiting.orbiters)
orbiting.orbiters -= src
if (!orbiting.orbiters.len)//we are the last orbit, delete the list
orbiting.orbiters = null
orbiting = null
return ..()
/datum/orbit/proc/Check(turf/targetloc, list/checked_already = list())
//Avoid infinite loops for people who end up orbiting themself through another orbiter
checked_already[src] = TRUE
if (!orbiter)
qdel(src)
return
if (!orbiting)
orbiter.stop_orbit()
return
if (!orbiter.orbiting) //admin wants to stop the orbit.
orbiter.orbiting = src //set it back to us first
orbiter.stop_orbit()
var/atom/movable/AM = orbiting
if(istype(AM) && AM.orbiting && AM.orbiting.orbiting == orbiter)
orbiter.stop_orbit()
return
lastprocess = world.time
if (!targetloc)
targetloc = get_turf(orbiting)
if (!targetloc || (!lock && orbiter.loc != lastloc && orbiter.loc != targetloc))
orbiter.stop_orbit()
return
var/turf/old_turf = get_turf(orbiter)
var/turf/new_turf = get_turf(targetloc)
if (old_turf?.z != new_turf?.z)
orbiter.onTransitZ(old_turf?.z, new_turf?.z)
// DO NOT PORT TO FORCEMOVE - MEMECODE WILL KILL MC
orbiter.loc = targetloc
orbiter.update_parallax_contents()
orbiter.update_light()
lastloc = orbiter.loc
for(var/other_orbit in orbiter.orbiters)
var/datum/orbit/OO = other_orbit
//Skip if checked already
if(checked_already[OO])
continue
OO.Check(targetloc, checked_already)
/atom/movable/var/datum/orbit/orbiting = null
/atom/var/list/orbiters = null
//A: atom to orbit
//radius: range to orbit at, radius of the circle formed by orbiting (in pixels)
//clockwise: whether you orbit clockwise or anti clockwise
//rotation_speed: how fast to rotate (how many ds should it take for a rotation to complete)
//rotation_segments: the resolution of the orbit circle, less = a more block circle, this can be used to produce hexagons (6 segments) triangles (3 segments), and so on, 36 is the best default.
//pre_rotation: Chooses to rotate src 90 degress towards the orbit dir (clockwise/anticlockwise), useful for things to go "head first" like ghosts
//lockinorbit: Forces src to always be on A's turf, otherwise the orbit cancels when src gets too far away (eg: ghosts)
/atom/movable/proc/orbit(atom/A, radius = 10, clockwise = FALSE, rotation_speed = 20, rotation_segments = 36, pre_rotation = TRUE, lockinorbit = FALSE)
if (!istype(A))
return
new/datum/orbit(src, A, lockinorbit)
if (!orbiting) //something failed, and our orbit datum deleted itself
return
var/matrix/initial_transform = matrix(transform)
//Head first!
if (pre_rotation)
var/matrix/M = matrix(transform)
var/pre_rot = 90
if(!clockwise)
pre_rot = -90
M.Turn(pre_rot)
transform = M
var/matrix/shift = matrix(transform)
shift.Translate(0,radius)
transform = shift
SpinAnimation(rotation_speed, -1, clockwise, rotation_segments)
//we stack the orbits up client side, so we can assign this back to normal server side without it breaking the orbit
transform = initial_transform
/atom/movable/proc/stop_orbit()
SpinAnimation(0,0)
qdel(orbiting)
/atom/Destroy(force = FALSE)
. = ..()
if (orbiters)
for (var/thing in orbiters)
var/datum/orbit/O = thing
if (O.orbiter)
O.orbiter.stop_orbit()
/atom/movable/Destroy(force = FALSE)
. = ..()
if (orbiting)
stop_orbit()
/atom/movable/proc/transfer_observers_to(atom/movable/target)
if(orbiters)
for(var/thing in orbiters)
var/datum/orbit/O = thing
if(O.orbiter && isobserver(O.orbiter))
var/mob/dead/observer/D = O.orbiter
D.ManualFollow(target)
+6 -6
View File
@@ -33,8 +33,8 @@
return
/obj/singularity/energy_ball/Destroy()
if(orbiting && istype(orbiting.orbiting, /obj/singularity/energy_ball))
var/obj/singularity/energy_ball/EB = orbiting.orbiting
if(orbiting && istype(orbiting.parent, /obj/singularity/energy_ball))
var/obj/singularity/energy_ball/EB = orbiting.parent
EB.orbiting_balls -= src
for(var/ball in orbiting_balls)
@@ -146,12 +146,12 @@
. = ..()
/obj/singularity/energy_ball/stop_orbit()
if (orbiting && istype(orbiting.orbiting, /obj/singularity/energy_ball))
var/obj/singularity/energy_ball/orbitingball = orbiting.orbiting
if (orbiting && istype(orbiting.parent, /obj/singularity/energy_ball))
var/obj/singularity/energy_ball/orbitingball = orbiting.parent
orbitingball.orbiting_balls -= src
orbitingball.dissipate_strength = orbitingball.orbiting_balls.len
..()
if (!loc && !QDELETED(src))
. = ..()
if (!QDELETED(src))
qdel(src)