mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Revert "Merge pull request #4985 from jack-fractal/dev"
This reverts commit1679b4062f, reversing changes made tob149b273d9. Signed-off-by: Mloc-Argent <colmohici@gmail.com> Conflicts: code/datums/visibility_networks/update_triggers.dm
This commit is contained in:
@@ -269,7 +269,6 @@ client
|
||||
body += "<option value='?_src_=vars;setmutantrace=\ref[D]'>Set Mutantrace</option>"
|
||||
body += "<option value='?_src_=vars;setspecies=\ref[D]'>Set Species</option>"
|
||||
body += "<option value='?_src_=vars;makeai=\ref[D]'>Make AI</option>"
|
||||
body += "<option value='?_src_=vars;makemask=\ref[D]'>Make Mask of Nar'sie</option>"
|
||||
body += "<option value='?_src_=vars;makerobot=\ref[D]'>Make cyborg</option>"
|
||||
body += "<option value='?_src_=vars;makemonkey=\ref[D]'>Make monkey</option>"
|
||||
body += "<option value='?_src_=vars;makealien=\ref[D]'>Make alien</option>"
|
||||
@@ -742,18 +741,7 @@ client
|
||||
usr << "Mob doesn't exist anymore"
|
||||
return
|
||||
holder.Topic(href, list("makeai"=href_list["makeai"]))
|
||||
|
||||
|
||||
else if(href_list["makemask"])
|
||||
if(!check_rights(R_SPAWN)) return
|
||||
var/mob/currentMob = locate(href_list["makemask"])
|
||||
if(alert("Confirm mob type change?",,"Transform","Cancel") != "Transform") return
|
||||
if(!currentMob)
|
||||
usr << "Mob doesn't exist anymore"
|
||||
return
|
||||
holder.Topic(href, list("makemask"=href_list["makemask"]))
|
||||
|
||||
|
||||
|
||||
else if(href_list["setmutantrace"])
|
||||
if(!check_rights(R_SPAWN)) return
|
||||
|
||||
|
||||
@@ -642,11 +642,20 @@ datum/mind
|
||||
switch(href_list["cult"])
|
||||
if("clear")
|
||||
if(src in ticker.mode.cult)
|
||||
ticker.mode.remove_cultist(src)
|
||||
ticker.mode.cult -= src
|
||||
ticker.mode.update_cult_icons_removed(src)
|
||||
special_role = null
|
||||
var/datum/game_mode/cult/cult = ticker.mode
|
||||
if (istype(cult))
|
||||
if(!config.objectives_disabled)
|
||||
cult.memoize_cult_objectives(src)
|
||||
current << "\red <FONT size = 3><B>You have been brainwashed! You are no longer a cultist!</B></FONT>"
|
||||
memory = ""
|
||||
log_admin("[key_name_admin(usr)] has de-cult'ed [current].")
|
||||
if("cultist")
|
||||
if(!(src in ticker.mode.cult))
|
||||
ticker.mode.add_cultist(src)
|
||||
ticker.mode.cult += src
|
||||
ticker.mode.update_cult_icons_added(src)
|
||||
special_role = "Cultist"
|
||||
current << "<font color=\"purple\"><b><i>You catch a glimpse of the Realm of Nar-Sie, The Geometer of Blood. You now see how flimsy the world is, you see that it should be open to the knowledge of Nar-Sie.</b></i></font>"
|
||||
current << "<font color=\"purple\"><b><i>Assist your new compatriots in their dark dealings. Their goal is yours, and yours is theirs. You serve the Dark One above all else. Bring It back.</b></i></font>"
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
#define UPDATE_BUFFER 25 // 2.5 seconds
|
||||
|
||||
// CAMERA CHUNK
|
||||
//
|
||||
// A 16x16 grid of the map with a list of turfs that can be seen, are visible and are dimmed.
|
||||
// Allows the mob using this chunk to stream these chunks and know what it can and cannot see.
|
||||
|
||||
/datum/visibility_chunk
|
||||
var/obscured_image = 'icons/effects/cameravis.dmi'
|
||||
var/obscured_sub = "black"
|
||||
var/list/obscuredTurfs = list()
|
||||
var/list/visibleTurfs = list()
|
||||
var/list/obscured = list()
|
||||
var/list/viewpoints = list()
|
||||
var/list/turfs = list()
|
||||
var/list/seenby = list()
|
||||
var/visible = 0
|
||||
var/changed = 0
|
||||
var/updating = 0
|
||||
var/x = 0
|
||||
var/y = 0
|
||||
var/z = 0
|
||||
|
||||
/datum/visibility_chunk/proc/add(mob/new_mob)
|
||||
|
||||
// if this thing doesn't use one of these visibility systems, kick it out
|
||||
if (!new_mob.visibility_interface)
|
||||
return
|
||||
|
||||
// if the mob being added isn't a valid form of that mob, kick it out
|
||||
if (!new_mob.visibility_interface:canBeAddedToChunk(src))
|
||||
return
|
||||
|
||||
// add this chunk to the list of visible chunks
|
||||
new_mob.visibility_interface:addChunk(src)
|
||||
|
||||
visible++
|
||||
seenby += new_mob
|
||||
if(changed && !updating)
|
||||
update()
|
||||
|
||||
/datum/visibility_chunk/proc/remove(mob/new_mob)
|
||||
// if this thing doesn't use one of these visibility systems, kick it out
|
||||
if (!new_mob.visibility_interface)
|
||||
return
|
||||
|
||||
// if the mob being added isn't a valid form of that mob, kick it out
|
||||
if (!new_mob.visibility_interface:canBeAddedToChunk(src))
|
||||
return
|
||||
|
||||
// remove the chunk
|
||||
new_mob.visibility_interface:removeChunk(src)
|
||||
|
||||
// remove the mob from out lists
|
||||
seenby -= new_mob
|
||||
if(visible > 0)
|
||||
visible--
|
||||
|
||||
/datum/visibility_chunk/proc/visibilityChanged(turf/loc)
|
||||
if(!visibleTurfs[loc])
|
||||
return
|
||||
hasChanged()
|
||||
|
||||
/datum/visibility_chunk/proc/hasChanged(var/update_now = 0)
|
||||
if(visible || update_now)
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(UPDATE_BUFFER) // Batch large changes, such as many doors opening or closing at once
|
||||
update()
|
||||
updating = 0
|
||||
else
|
||||
changed = 1
|
||||
|
||||
|
||||
/*
|
||||
This function needs to be overwritten to return True if the viewpoint object is valid, and false if it is not.
|
||||
*/
|
||||
/datum/visibility_chunk/proc/validViewpoint(var/viewpoint)
|
||||
return FALSE
|
||||
|
||||
/*
|
||||
This function needs to be overwritten to return a list of visible turfs for that viewpoint
|
||||
*/
|
||||
/datum/visibility_chunk/proc/getVisibleTurfsForViewpoint(var/viewpoint)
|
||||
return list()
|
||||
|
||||
// returns a list of turfs which can be seen in by the chunks viewpoints
|
||||
/datum/visibility_chunk/proc/getVisibleTurfs()
|
||||
var/list/newVisibleTurfs = list()
|
||||
for(var/viewpoint in viewpoints)
|
||||
if (validViewpoint(viewpoint))
|
||||
for (var/turf/t in getVisibleTurfsForViewpoint(viewpoint))
|
||||
newVisibleTurfs[t]=t
|
||||
return newVisibleTurfs
|
||||
|
||||
/*
|
||||
This function needs to be overwritten to find nearby viewpoint objects to the chunk center.
|
||||
*/
|
||||
/datum/visibility_chunk/proc/findNearbyViewpoints()
|
||||
return FALSE
|
||||
|
||||
/*
|
||||
This function can be overwritten to change or randomize the obscuring images
|
||||
*/
|
||||
/datum/visibility_chunk/proc/setObscuredImage(var/turf/target_turf)
|
||||
if(!target_turf.obscured)
|
||||
target_turf.obscured = image(obscured_image, target_turf, obscured_sub, 15)
|
||||
|
||||
/datum/visibility_chunk/proc/update()
|
||||
|
||||
set background = 1
|
||||
|
||||
// get a list of all the turfs that our viewpoints can see
|
||||
var/list/newVisibleTurfs = getVisibleTurfs()
|
||||
|
||||
// Removes turf that isn't in turfs.
|
||||
newVisibleTurfs &= turfs
|
||||
|
||||
var/list/visAdded = newVisibleTurfs - visibleTurfs
|
||||
var/list/visRemoved = visibleTurfs - newVisibleTurfs
|
||||
|
||||
visibleTurfs = newVisibleTurfs
|
||||
obscuredTurfs = turfs - newVisibleTurfs
|
||||
|
||||
// update the visibility overlays
|
||||
for(var/turf in visAdded)
|
||||
var/turf/t = turf
|
||||
if(t.obscured)
|
||||
obscured -= t.obscured
|
||||
for(var/mob/current_mob in seenby)
|
||||
if (current_mob.visibility_interface)
|
||||
current_mob.visibility_interface:removeObscuredTurf(t)
|
||||
|
||||
for(var/turf in visRemoved)
|
||||
var/turf/t = turf
|
||||
if(obscuredTurfs[t])
|
||||
setObscuredImage(t)
|
||||
obscured += t.obscured
|
||||
for(var/mob/current_mob in seenby)
|
||||
if (current_mob.visibility_interface)
|
||||
current_mob.visibility_interface:addObscuredTurf(t)
|
||||
else
|
||||
seenby -= current_mob
|
||||
|
||||
|
||||
// Create a new chunk, since the chunks are made as they are needed.
|
||||
/datum/visibility_chunk/New(loc, x, y, z)
|
||||
|
||||
// 0xf = 15
|
||||
x &= ~0xf
|
||||
y &= ~0xf
|
||||
|
||||
src.x = x
|
||||
src.y = y
|
||||
src.z = z
|
||||
|
||||
for(var/turf/t in range(10, locate(x + 8, y + 8, z)))
|
||||
if(t.x >= x && t.y >= y && t.x < x + 16 && t.y < y + 16)
|
||||
turfs[t] = t
|
||||
|
||||
// locate all nearby viewpoints
|
||||
findNearbyViewpoints()
|
||||
|
||||
// get the turfs that are visible to those viewpoints
|
||||
visibleTurfs = getVisibleTurfs()
|
||||
|
||||
// Removes turf that isn't in turfs.
|
||||
visibleTurfs &= turfs
|
||||
|
||||
// create the list of turfs we can't see
|
||||
obscuredTurfs = turfs - visibleTurfs
|
||||
|
||||
// create the list of obscuring images to add to viewing clients
|
||||
for(var/turf in obscuredTurfs)
|
||||
var/turf/t = turf
|
||||
setObscuredImage(t)
|
||||
obscured += t.obscured
|
||||
|
||||
#undef UPDATE_BUFFER
|
||||
@@ -1,11 +0,0 @@
|
||||
var/datum/visibility_network/cameras/cameranet = new()
|
||||
var/datum/visibility_network/cult/cultNetwork = new()
|
||||
var/datum/visibility_network/list/visibility_networks = list("ALL_CAMERAS"=cameranet, "CULT" = cultNetwork)
|
||||
|
||||
|
||||
// used by turfs and objects to update all visibility networks
|
||||
/proc/updateVisibilityNetworks(atom/A, var/opacity_check = 1)
|
||||
var/datum/visibility_network/currentNetwork
|
||||
for (var/networkName in visibility_networks)
|
||||
currentNetwork = visibility_networks[networkName]
|
||||
currentNetwork.updateVisibility(A, opacity_check)
|
||||
@@ -1,94 +0,0 @@
|
||||
//UPDATE TRIGGERS, when the chunk (and the surrounding chunks) should update.
|
||||
|
||||
// TURFS
|
||||
|
||||
/turf
|
||||
var/image/obscured
|
||||
|
||||
/turf/proc/visibilityChanged()
|
||||
if(ticker)
|
||||
updateVisibilityNetworks(src)
|
||||
|
||||
/turf/simulated/Del()
|
||||
visibilityChanged()
|
||||
..()
|
||||
|
||||
/turf/simulated/New()
|
||||
..()
|
||||
visibilityChanged()
|
||||
|
||||
|
||||
|
||||
// STRUCTURES
|
||||
|
||||
/obj/structure/Del()
|
||||
if(ticker)
|
||||
updateVisibilityNetworks(src)
|
||||
..()
|
||||
|
||||
/obj/structure/New()
|
||||
..()
|
||||
if(ticker)
|
||||
updateVisibilityNetworks(src)
|
||||
|
||||
// EFFECTS
|
||||
|
||||
/obj/effect/Del()
|
||||
if(ticker)
|
||||
updateVisibilityNetworks(src)
|
||||
..()
|
||||
|
||||
/obj/effect/New()
|
||||
..()
|
||||
if(ticker)
|
||||
updateVisibilityNetworks(src)
|
||||
|
||||
|
||||
// DOORS
|
||||
|
||||
// Simply updates the visibility of the area when it opens/closes/destroyed.
|
||||
/obj/machinery/door/proc/update_nearby_tiles(need_rebuild)
|
||||
|
||||
if(!glass)
|
||||
updateVisibilityNetworks(src,0)
|
||||
|
||||
if(!air_master)
|
||||
return 0
|
||||
|
||||
for(var/turf/simulated/turf in locs)
|
||||
update_heat_protection(turf)
|
||||
air_master.mark_for_update(turf)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
#define UPDATE_VISIBILITY_NETWORK_BUFFER 30
|
||||
|
||||
/mob
|
||||
var/datum/visibility_network/list/visibilityNetworks=list()
|
||||
var/updatingVisibilityNetworks=FALSE
|
||||
|
||||
/mob/Move(n,direct)
|
||||
var/oldLoc = src.loc
|
||||
//. = ..()
|
||||
if(..(n,direct))
|
||||
if(src.visibilityNetworks.len)
|
||||
if(!src.updatingVisibilityNetworks)
|
||||
src.updatingVisibilityNetworks = 1
|
||||
spawn(UPDATE_VISIBILITY_NETWORK_BUFFER)
|
||||
if(oldLoc != src.loc)
|
||||
for (var/datum/visibility_network/currentNetwork in src.visibilityNetworks)
|
||||
currentNetwork.updateMob(src)
|
||||
src.updatingVisibilityNetworks = 0
|
||||
return .
|
||||
|
||||
/mob/proc/addToVisibilityNetwork(var/datum/visibility_network/network)
|
||||
if(network)
|
||||
src.visibilityNetworks+=network
|
||||
|
||||
/mob/proc/removeFromVisibilityNetwork(var/datum/visibility_network/network)
|
||||
if(network)
|
||||
src.visibilityNetworks|=network
|
||||
|
||||
#undef UPDATE_VISIBILITY_NETWORK_BUFFER
|
||||
@@ -1,46 +0,0 @@
|
||||
/datum/visibility_interface
|
||||
var/chunk_type = null
|
||||
var/mob/controller = null
|
||||
var/list/visible_chunks = list()
|
||||
|
||||
|
||||
/datum/visibility_interface/New(var/mob/controller)
|
||||
src.controller = controller
|
||||
|
||||
|
||||
/datum/visibility_interface/proc/validMob()
|
||||
return getClient()
|
||||
|
||||
/datum/visibility_interface/proc/getClient()
|
||||
return controller.client
|
||||
|
||||
/datum/visibility_interface/proc/canBeAddedToChunk(var/datum/visibility_chunk/test_chunk)
|
||||
return istype(test_chunk,chunk_type)
|
||||
|
||||
|
||||
/datum/visibility_interface/proc/addChunk(var/datum/visibility_chunk/test_chunk)
|
||||
visible_chunks+=test_chunk
|
||||
var/client/currentClient = getClient()
|
||||
if(currentClient)
|
||||
currentClient.images += test_chunk.obscured
|
||||
|
||||
|
||||
/datum/visibility_interface/proc/removeChunk(var/datum/visibility_chunk/test_chunk)
|
||||
visible_chunks-=test_chunk
|
||||
var/client/currentClient = getClient()
|
||||
if(currentClient)
|
||||
currentClient.images -= test_chunk.obscured
|
||||
|
||||
|
||||
/datum/visibility_interface/proc/removeObscuredTurf(var/turf/target_turf)
|
||||
if(validMob())
|
||||
var/client/currentClient = getClient()
|
||||
if(currentClient)
|
||||
currentClient.images -= target_turf.obscured
|
||||
|
||||
|
||||
/datum/visibility_interface/proc/addObscuredTurf(var/turf/target_turf)
|
||||
if(validMob())
|
||||
var/client/currentClient = getClient()
|
||||
if(currentClient)
|
||||
currentClient.images -= target_turf.obscured
|
||||
@@ -1,141 +0,0 @@
|
||||
/datum/visibility_network
|
||||
var/list/viewpoints = list()
|
||||
|
||||
// the type of chunk used by this network
|
||||
var/datum/visibility_chunk/ChunkType = /datum/visibility_chunk
|
||||
|
||||
// The chunks of the map, mapping the areas that the viewpoints can see.
|
||||
var/list/chunks = list()
|
||||
|
||||
var/ready = 0
|
||||
|
||||
|
||||
// Creates a chunk key string from x,y,z coordinates
|
||||
/datum/visibility_network/proc/createChunkKey(x,y,z)
|
||||
x &= ~0xf
|
||||
y &= ~0xf
|
||||
return "[x],[y],[z]"
|
||||
|
||||
|
||||
// Checks if a chunk has been Generated in x, y, z.
|
||||
/datum/visibility_network/proc/chunkGenerated(x, y, z)
|
||||
return (chunks[createChunkKey(x, y, z)])
|
||||
|
||||
|
||||
// Returns the chunk in the x, y, z.
|
||||
// If there is no chunk, it creates a new chunk and returns that.
|
||||
/datum/visibility_network/proc/getChunk(x, y, z)
|
||||
var/key = createChunkKey(x, y, z)
|
||||
if(!chunks[key])
|
||||
chunks[key] = new ChunkType(null, x, y, z)
|
||||
return chunks[key]
|
||||
|
||||
|
||||
/datum/visibility_network/proc/visibility(var/mob/targetMob)
|
||||
|
||||
// if we've got not visibility interface on the mob, we canot do this
|
||||
if (!targetMob.visibility_interface)
|
||||
return
|
||||
|
||||
// 0xf = 15
|
||||
var/x1 = max(0, targetMob.x - 16) & ~0xf
|
||||
var/y1 = max(0, targetMob.y - 16) & ~0xf
|
||||
var/x2 = min(world.maxx, targetMob.x + 16) & ~0xf
|
||||
var/y2 = min(world.maxy, targetMob.y + 16) & ~0xf
|
||||
|
||||
var/list/visibleChunks = list()
|
||||
|
||||
for(var/x = x1; x <= x2; x += 16)
|
||||
for(var/y = y1; y <= y2; y += 16)
|
||||
visibleChunks += getChunk(x, y, targetMob.z)
|
||||
|
||||
var/list/remove = targetMob.visibility_interface:visible_chunks - visibleChunks
|
||||
var/list/add = visibleChunks - targetMob.visibility_interface:visible_chunks
|
||||
|
||||
for(var/datum/visibility_chunk/chunk in remove)
|
||||
chunk.remove(targetMob)
|
||||
|
||||
for(var/datum/visibility_chunk/chunk in add)
|
||||
chunk.add(targetMob)
|
||||
|
||||
|
||||
// Updates the chunks that the turf is located in. Use this when obstacles are destroyed or when doors open.
|
||||
/datum/visibility_network/proc/updateVisibility(atom/A, var/opacity_check = 1)
|
||||
if(!ticker || (opacity_check && !A.opacity))
|
||||
return
|
||||
majorChunkChange(A, 2)
|
||||
|
||||
|
||||
/datum/visibility_network/proc/updateChunk(x, y, z)
|
||||
if(!chunkGenerated(x, y, z))
|
||||
return
|
||||
var/datum/visibility_chunk/chunk = getChunk(x, y, z)
|
||||
chunk.hasChanged()
|
||||
|
||||
|
||||
/datum/visibility_network/proc/validViewpoint(var/viewpoint)
|
||||
return FALSE
|
||||
|
||||
|
||||
/datum/visibility_network/proc/addViewpoint(var/viewpoint)
|
||||
if(validViewpoint(viewpoint))
|
||||
majorChunkChange(viewpoint, 1)
|
||||
|
||||
|
||||
/datum/visibility_network/proc/removeViewpoint(var/viewpoint)
|
||||
if(validViewpoint(viewpoint))
|
||||
majorChunkChange(viewpoint, 0)
|
||||
|
||||
/datum/visibility_network/proc/getViewpointFromMob(var/mob/currentMob)
|
||||
return FALSE
|
||||
|
||||
/datum/visibility_network/proc/updateMob(var/mob/currentMob)
|
||||
var/viewpoint = getViewpointFromMob(currentMob)
|
||||
if(viewpoint)
|
||||
updateViewpoint(viewpoint)
|
||||
|
||||
|
||||
/datum/visibility_network/proc/updateViewpoint(var/viewpoint)
|
||||
if(validViewpoint(viewpoint))
|
||||
majorChunkChange(viewpoint, 1)
|
||||
|
||||
|
||||
// Never access this proc directly!!!!
|
||||
// This will update the chunk and all the surrounding chunks.
|
||||
// It will also add the atom to the cameras list if you set the choice to 1.
|
||||
// Setting the choice to 0 will remove the viewpoint from the chunks.
|
||||
// If you want to update the chunks around an object, without adding/removing a viewpoint, use choice 2.
|
||||
/datum/visibility_network/proc/majorChunkChange(atom/c, var/choice)
|
||||
// 0xf = 15
|
||||
if(!c)
|
||||
return
|
||||
|
||||
var/turf/T = get_turf(c)
|
||||
if(T)
|
||||
var/x1 = max(0, T.x - 8) & ~0xf
|
||||
var/y1 = max(0, T.y - 8) & ~0xf
|
||||
var/x2 = min(world.maxx, T.x + 8) & ~0xf
|
||||
var/y2 = min(world.maxy, T.y + 8) & ~0xf
|
||||
|
||||
for(var/x = x1; x <= x2; x += 16)
|
||||
for(var/y = y1; y <= y2; y += 16)
|
||||
if(chunkGenerated(x, y, T.z))
|
||||
var/datum/visibility_chunk/chunk = getChunk(x, y, T.z)
|
||||
if(choice == 0)
|
||||
// Remove the viewpoint.
|
||||
chunk.viewpoints -= c
|
||||
else if(choice == 1)
|
||||
// You can't have the same viewpoint in the list twice.
|
||||
chunk.viewpoints |= c
|
||||
chunk.hasChanged()
|
||||
|
||||
// checks if the network can see a particular atom
|
||||
/datum/visibility_network/proc/checkCanSee(var/atom/target)
|
||||
var/turf/position = get_turf(target)
|
||||
var/datum/visibility_chunk/chunk = getChunk(position.x, position.y, position.z)
|
||||
if(chunk)
|
||||
if(chunk.changed)
|
||||
chunk.hasChanged(1) // Update now, no matter if it's visible or not.
|
||||
if(chunk.visibleTurfs[position])
|
||||
return 1
|
||||
return 0
|
||||
Reference in New Issue
Block a user