mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 12:37:26 +01:00
Remove legacy viewpoint code, move back to Bay's and /tg/'s system
This commit is contained in:
@@ -29,6 +29,16 @@ atom/proc/CanPass(atom/movable/mover, turf/target, height=1.5, air_group = 0)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
//Convenience function for atoms to update turfs they occupy
|
||||
/atom/movable/proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master)
|
||||
return 0
|
||||
|
||||
for(var/turf/simulated/turf in locs)
|
||||
air_master.mark_for_update(turf)
|
||||
|
||||
return 1
|
||||
|
||||
//Basically another way of calling CanPass(null, other, 0, 0) and CanPass(null, other, 1.5, 1).
|
||||
//Returns:
|
||||
|
||||
@@ -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,150 +0,0 @@
|
||||
/datum/visibility_network
|
||||
var/list/viewpoints = list()
|
||||
var/cameras_unsorted = 1
|
||||
// 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
|
||||
|
||||
|
||||
/datum/visibility_network/proc/process_sort()
|
||||
if(cameras_unsorted)
|
||||
viewpoints = dd_sortedObjectList(viewpoints)
|
||||
cameras_unsorted = 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)
|
||||
return checkTurfVis(position)
|
||||
|
||||
/datum/visibility_network/proc/checkTurfVis(var/turf/position)
|
||||
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
|
||||
@@ -494,7 +494,7 @@
|
||||
|
||||
/obj/item/weapon/camera_bug/attack_self(mob/usr as mob)
|
||||
var/list/cameras = new/list()
|
||||
for (var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
if (C.bugged && C.status)
|
||||
cameras.Add(C)
|
||||
if (length(cameras) == 0)
|
||||
|
||||
@@ -72,13 +72,11 @@ var/engwords = list("travel", "blood", "join", "hell", "destroy", "technology",
|
||||
blood.override = 1
|
||||
for(var/mob/living/silicon/ai/AI in player_list)
|
||||
AI.client.images += blood
|
||||
cultNetwork.viewpoints+=src
|
||||
cultNetwork.addViewpoint(src)
|
||||
cult_viewpoints += src
|
||||
|
||||
/obj/effect/rune/Del()
|
||||
..()
|
||||
cultNetwork.viewpoints-=src
|
||||
cultNetwork.removeViewpoint(src)
|
||||
cult_viewpoints -= src
|
||||
|
||||
/obj/effect/rune/examine()
|
||||
set src in view(2)
|
||||
|
||||
@@ -313,7 +313,7 @@ rcd light flash thingy on matter drain
|
||||
|
||||
power_type = /client/proc/reactivate_camera
|
||||
|
||||
/client/proc/reactivate_camera(obj/machinery/camera/C as obj in cameranet.viewpoints)
|
||||
/client/proc/reactivate_camera(obj/machinery/camera/C as obj in cameranet.cameras)
|
||||
set name = "Reactivate Camera"
|
||||
set category = "Malfunction"
|
||||
if (istype (C, /obj/machinery/camera))
|
||||
@@ -337,7 +337,7 @@ rcd light flash thingy on matter drain
|
||||
|
||||
power_type = /client/proc/upgrade_camera
|
||||
|
||||
/client/proc/upgrade_camera(obj/machinery/camera/C as obj in cameranet.viewpoints)
|
||||
/client/proc/upgrade_camera(obj/machinery/camera/C as obj in cameranet.cameras)
|
||||
set name = "Upgrade Camera"
|
||||
set category = "Malfunction"
|
||||
if(istype(C))
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
C.auto_turn()
|
||||
|
||||
C.network = uniquelist(tempnetwork)
|
||||
tempnetwork = difflist(C.network,RESTRICTED_CAMERA_NETWORKS)
|
||||
tempnetwork = difflist(C.network,restricted_camera_networks)
|
||||
if(!tempnetwork.len)//Camera isn't on any open network - remove its chunk from AI visibility.
|
||||
cameranet.removeCamera(C)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
var/list/T = list()
|
||||
T["Cancel"] = "Cancel"
|
||||
for (var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
var/list/tempnetwork = C.network&src.network
|
||||
if (tempnetwork.len)
|
||||
T[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
cameranet.process_sort()
|
||||
|
||||
var/cameras[0]
|
||||
for(var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
var/cam[0]
|
||||
cam["name"] = C.c_tag
|
||||
cam["deact"] = !C.can_use()
|
||||
@@ -155,7 +155,7 @@
|
||||
if(href_list["switchTo"])
|
||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||
var/obj/machinery/camera/C = locate(href_list["switchTo"]) in cameranet.viewpoints
|
||||
var/obj/machinery/camera/C = locate(href_list["switchTo"]) in cameranet.cameras
|
||||
if(!C) return
|
||||
|
||||
switch_to_camera(usr, C)
|
||||
|
||||
@@ -25,15 +25,6 @@
|
||||
if(!height || air_group) return 0
|
||||
else return ..()
|
||||
|
||||
//Looks like copy/pasted code... I doubt 'need_rebuild' is even used here - Nodrak
|
||||
/obj/machinery/shield/proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master) return 0
|
||||
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/shield/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if(!istype(W)) return
|
||||
|
||||
|
||||
@@ -1109,15 +1109,6 @@ steam.start() -- spawns the effect
|
||||
if(air_group) return 0
|
||||
return !density
|
||||
|
||||
|
||||
proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master)
|
||||
return 0
|
||||
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
|
||||
return 1
|
||||
|
||||
/datum/effect/effect/system/reagents_explosion
|
||||
var/amount // TNT equivalent
|
||||
var/flashing = 0 // does explosion creates flash effect?
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
/obj/item/device/handtv/attack_self(mob/usr as mob)
|
||||
var/list/cameras = new/list()
|
||||
for (var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
if (C.hasbug && C.status)
|
||||
cameras.Add(C)
|
||||
if (length(cameras) == 0)
|
||||
|
||||
@@ -34,14 +34,6 @@
|
||||
update_nearby_tiles()
|
||||
..()
|
||||
|
||||
proc/update_nearby_tiles(need_rebuild) //Copypasta from airlock code
|
||||
if(!air_master)
|
||||
return 0
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -157,13 +157,6 @@
|
||||
CheckHardness()
|
||||
return
|
||||
|
||||
proc/update_nearby_tiles(need_rebuild) //Copypasta from airlock code
|
||||
if(!air_master) return 0
|
||||
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
|
||||
return 1
|
||||
|
||||
/obj/structure/mineral_door/iron
|
||||
mineralType = "metal"
|
||||
hardness = 3
|
||||
|
||||
@@ -27,13 +27,6 @@ obj/structure/windoor_assembly
|
||||
var/secure = 0 //Whether or not this creates a secure windoor
|
||||
var/state = "01" //How far the door assembly has progressed
|
||||
|
||||
/obj/structure/windoor_assembly/proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master) return 0
|
||||
|
||||
air_master.mark_for_update(loc)
|
||||
|
||||
return 1
|
||||
|
||||
obj/structure/windoor_assembly/New(dir=NORTH)
|
||||
..()
|
||||
src.ini_dir = src.dir
|
||||
|
||||
@@ -403,14 +403,6 @@ var/global/wcColored
|
||||
dir = ini_dir
|
||||
update_nearby_tiles(need_rebuild=1)
|
||||
|
||||
|
||||
//This proc has to do with airgroups and atmos, it has nothing to do with smoothwindows, that's update_nearby_tiles().
|
||||
/obj/structure/window/proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master) return 0
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
|
||||
return 1
|
||||
|
||||
//checks if this window is full-tile one
|
||||
/obj/structure/window/proc/is_fulltile()
|
||||
if(dir & (dir - 1))
|
||||
|
||||
@@ -52,7 +52,7 @@ var/intercom_range_display_status = 0
|
||||
del(C)
|
||||
|
||||
if(camera_range_display_status)
|
||||
for(var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
new/obj/effect/debugging/camera_range(C.loc)
|
||||
feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
@@ -68,7 +68,7 @@ var/intercom_range_display_status = 0
|
||||
|
||||
var/list/obj/machinery/camera/CL = list()
|
||||
|
||||
for(var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
CL += C
|
||||
|
||||
var/output = {"<B>CAMERA ANOMALIES REPORT</B><HR>
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
return null
|
||||
|
||||
var/list/L = list()
|
||||
for(var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
var/list/temp = C.network & key.networks
|
||||
if(temp.len)
|
||||
L.Add(C)
|
||||
|
||||
@@ -406,7 +406,7 @@ var/list/ai_list = list()
|
||||
unset_machine()
|
||||
src << browse(null, t1)
|
||||
if (href_list["switchcamera"])
|
||||
switchCamera(locate(href_list["switchcamera"])) in cameranet.viewpoints
|
||||
switchCamera(locate(href_list["switchcamera"])) in cameranet.cameras
|
||||
if (href_list["showalerts"])
|
||||
ai_alerts()
|
||||
//Carn: holopad requests
|
||||
@@ -712,11 +712,11 @@ var/list/ai_list = list()
|
||||
|
||||
var/mob/living/silicon/ai/U = usr
|
||||
|
||||
for (var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for (var/obj/machinery/camera/C in cameranet.cameras)
|
||||
if(!C.can_use())
|
||||
continue
|
||||
|
||||
var/list/tempnetwork = difflist(C.network,RESTRICTED_CAMERA_NETWORKS,1)
|
||||
var/list/tempnetwork = difflist(C.network,restricted_camera_networks,1)
|
||||
if(tempnetwork.len)
|
||||
for(var/i in tempnetwork)
|
||||
cameralist[i] = i
|
||||
@@ -730,7 +730,7 @@ var/list/ai_list = list()
|
||||
if(isnull(network))
|
||||
network = old_network // If nothing is selected
|
||||
else
|
||||
for(var/obj/machinery/camera/C in cameranet.viewpoints)
|
||||
for(var/obj/machinery/camera/C in cameranet.cameras)
|
||||
if(!C.can_use())
|
||||
continue
|
||||
if(network in C.network)
|
||||
|
||||
@@ -1,25 +1,156 @@
|
||||
/datum/visibility_network/cameras
|
||||
ChunkType = /datum/visibility_chunk/camera
|
||||
// CAMERA NET
|
||||
//
|
||||
// The datum containing all the chunks.
|
||||
|
||||
/datum/visibility_network/cameras/getViewpointFromMob(var/mob/currentMob)
|
||||
var/mob/living/silicon/robot/currentRobot=currentMob
|
||||
if(currentRobot)
|
||||
return currentRobot.camera
|
||||
return FALSE
|
||||
var/datum/cameranet/cameranet = new()
|
||||
|
||||
/datum/visibility_network/cameras/validViewpoint(var/viewpoint)
|
||||
var/obj/machinery/camera/c = viewpoint
|
||||
if (!c)
|
||||
return FALSE
|
||||
return c.can_use()
|
||||
/datum/cameranet
|
||||
// The cameras on the map, no matter if they work or not. Updated in obj/machinery/camera.dm by New() and Del().
|
||||
var/list/cameras = list()
|
||||
var/cameras_unsorted = 1
|
||||
// The chunks of the map, mapping the areas that the cameras can see.
|
||||
var/list/chunks = list()
|
||||
var/ready = 0
|
||||
|
||||
/datum/cameranet/proc/process_sort()
|
||||
if(cameras_unsorted)
|
||||
cameras = dd_sortedObjectList(cameras)
|
||||
cameras_unsorted = 0
|
||||
|
||||
// adding some indirection so that I don't have to edit a ton of files
|
||||
/datum/visibility_network/cameras/proc/addCamera(var/camera)
|
||||
return addViewpoint(camera)
|
||||
// Checks if a chunk has been Generated in x, y, z.
|
||||
/datum/cameranet/proc/chunkGenerated(x, y, z)
|
||||
x &= ~0xf
|
||||
y &= ~0xf
|
||||
var/key = "[x],[y],[z]"
|
||||
return (chunks[key])
|
||||
|
||||
/datum/visibility_network/cameras/proc/removeCamera(var/camera)
|
||||
return removeViewpoint(camera)
|
||||
// Returns the chunk in the x, y, z.
|
||||
// If there is no chunk, it creates a new chunk and returns that.
|
||||
/datum/cameranet/proc/getCameraChunk(x, y, z)
|
||||
x &= ~0xf
|
||||
y &= ~0xf
|
||||
var/key = "[x],[y],[z]"
|
||||
if(!chunks[key])
|
||||
chunks[key] = new /datum/camerachunk(null, x, y, z)
|
||||
|
||||
/datum/visibility_network/cameras/proc/checkCameraVis(var/atom/target)
|
||||
return checkCanSee(target)
|
||||
return chunks[key]
|
||||
|
||||
// Updates what the aiEye can see. It is recommended you use this when the aiEye moves or it's location is set.
|
||||
|
||||
/datum/cameranet/proc/visibility(mob/aiEye/ai)
|
||||
// 0xf = 15
|
||||
var/x1 = max(0, ai.x - 16) & ~0xf
|
||||
var/y1 = max(0, ai.y - 16) & ~0xf
|
||||
var/x2 = min(world.maxx, ai.x + 16) & ~0xf
|
||||
var/y2 = min(world.maxy, ai.y + 16) & ~0xf
|
||||
|
||||
var/list/visibleChunks = list()
|
||||
|
||||
for(var/x = x1; x <= x2; x += 16)
|
||||
for(var/y = y1; y <= y2; y += 16)
|
||||
visibleChunks += getCameraChunk(x, y, ai.z)
|
||||
|
||||
var/list/remove = ai.visibleCameraChunks - visibleChunks
|
||||
var/list/add = visibleChunks - ai.visibleCameraChunks
|
||||
|
||||
for(var/chunk in remove)
|
||||
var/datum/camerachunk/c = chunk
|
||||
c.remove(ai)
|
||||
|
||||
for(var/chunk in add)
|
||||
var/datum/camerachunk/c = chunk
|
||||
c.add(ai)
|
||||
|
||||
// Updates the chunks that the turf is located in. Use this when obstacles are destroyed or when doors open.
|
||||
|
||||
/datum/cameranet/proc/updateVisibility(atom/A, var/opacity_check = 1)
|
||||
|
||||
if(!ticker || (opacity_check && !A.opacity))
|
||||
return
|
||||
majorChunkChange(A, 2)
|
||||
|
||||
/datum/cameranet/proc/updateChunk(x, y, z)
|
||||
// 0xf = 15
|
||||
if(!chunkGenerated(x, y, z))
|
||||
return
|
||||
var/datum/camerachunk/chunk = getCameraChunk(x, y, z)
|
||||
chunk.hasChanged()
|
||||
|
||||
// Removes a camera from a chunk.
|
||||
|
||||
/datum/cameranet/proc/removeCamera(obj/machinery/camera/c)
|
||||
if(c.can_use())
|
||||
majorChunkChange(c, 0)
|
||||
|
||||
// Add a camera to a chunk.
|
||||
|
||||
/datum/cameranet/proc/addCamera(obj/machinery/camera/c)
|
||||
if(c.can_use())
|
||||
majorChunkChange(c, 1)
|
||||
|
||||
// Used for Cyborg cameras. Since portable cameras can be in ANY chunk.
|
||||
|
||||
/datum/cameranet/proc/updatePortableCamera(obj/machinery/camera/c)
|
||||
if(c.can_use())
|
||||
majorChunkChange(c, 1)
|
||||
//else
|
||||
// majorChunkChange(c, 0)
|
||||
|
||||
// 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 camera from the chunks.
|
||||
// If you want to update the chunks around an object, without adding/removing a camera, use choice 2.
|
||||
|
||||
/datum/cameranet/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
|
||||
|
||||
//world << "X1: [x1] - Y1: [y1] - X2: [x2] - Y2: [y2]"
|
||||
|
||||
for(var/x = x1; x <= x2; x += 16)
|
||||
for(var/y = y1; y <= y2; y += 16)
|
||||
if(chunkGenerated(x, y, T.z))
|
||||
var/datum/camerachunk/chunk = getCameraChunk(x, y, T.z)
|
||||
if(choice == 0)
|
||||
// Remove the camera.
|
||||
chunk.cameras -= c
|
||||
else if(choice == 1)
|
||||
// You can't have the same camera in the list twice.
|
||||
chunk.cameras |= c
|
||||
chunk.hasChanged()
|
||||
|
||||
// Will check if a mob is on a viewable turf. Returns 1 if it is, otherwise returns 0.
|
||||
|
||||
/datum/cameranet/proc/checkCameraVis(mob/living/target as mob)
|
||||
|
||||
// 0xf = 15
|
||||
var/turf/position = get_turf(target)
|
||||
return checkTurfVis(position)
|
||||
|
||||
/datum/cameranet/proc/checkTurfVis(var/turf/position)
|
||||
var/datum/camerachunk/chunk = getCameraChunk(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
|
||||
|
||||
// Debug verb for VVing the chunk that the turf is in.
|
||||
/*
|
||||
/turf/verb/view_chunk()
|
||||
set src in world
|
||||
|
||||
if(cameranet.chunkGenerated(x, y, z))
|
||||
var/datum/camerachunk/chunk = cameranet.getCameraChunk(x, y, z)
|
||||
usr.client.debug_variables(chunk)
|
||||
*/
|
||||
@@ -1,23 +1,168 @@
|
||||
/datum/visibility_chunk/camera
|
||||
#define UPDATE_BUFFER 25 // 2.5 seconds
|
||||
|
||||
/datum/visibility_chunk/camera/validViewpoint(var/viewpoint)
|
||||
var/obj/machinery/camera/c = viewpoint
|
||||
if(!c)
|
||||
return FALSE
|
||||
if(!c.can_use())
|
||||
return FALSE
|
||||
var/turf/point = locate(src.x + 8, src.y + 8, src.z)
|
||||
if(get_dist(point, c) > 24)
|
||||
return FALSE
|
||||
return TRUE
|
||||
// CAMERA CHUNK
|
||||
//
|
||||
// A 16x16 grid of the map with a list of turfs that can be seen, are visible and are dimmed.
|
||||
// Allows the AI Eye to stream these chunks and know what it can and cannot see.
|
||||
|
||||
/datum/camerachunk
|
||||
var/list/obscuredTurfs = list()
|
||||
var/list/visibleTurfs = list()
|
||||
var/list/obscured = list()
|
||||
var/list/cameras = 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/camera/getVisibleTurfsForViewpoint(var/viewpoint)
|
||||
var/obj/machinery/camera/c = viewpoint
|
||||
return c.can_see()
|
||||
// Add an AI eye to the chunk, then update if changed.
|
||||
|
||||
/datum/camerachunk/proc/add(mob/aiEye/ai)
|
||||
if(!ai.ai)
|
||||
return
|
||||
ai.visibleCameraChunks += src
|
||||
if(ai.ai.client)
|
||||
ai.ai.client.images += obscured
|
||||
visible++
|
||||
seenby += ai
|
||||
if(changed && !updating)
|
||||
update()
|
||||
|
||||
// Remove an AI eye from the chunk, then update if changed.
|
||||
|
||||
/datum/camerachunk/proc/remove(mob/aiEye/ai)
|
||||
if(!ai.ai)
|
||||
return
|
||||
ai.visibleCameraChunks -= src
|
||||
if(ai.ai.client)
|
||||
ai.ai.client.images -= obscured
|
||||
seenby -= ai
|
||||
if(visible > 0)
|
||||
visible--
|
||||
|
||||
// Called when a chunk has changed. I.E: A wall was deleted.
|
||||
|
||||
/datum/camerachunk/proc/visibilityChanged(turf/loc)
|
||||
if(!visibleTurfs[loc])
|
||||
return
|
||||
hasChanged()
|
||||
|
||||
// Updates the chunk, makes sure that it doesn't update too much. If the chunk isn't being watched it will
|
||||
// instead be flagged to update the next time an AI Eye moves near it.
|
||||
|
||||
/datum/camerachunk/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
|
||||
|
||||
// The actual updating. It gathers the visible turfs from cameras and puts them into the appropiate lists.
|
||||
|
||||
/datum/camerachunk/proc/update()
|
||||
|
||||
set background = 1
|
||||
|
||||
var/list/newVisibleTurfs = list()
|
||||
|
||||
for(var/camera in cameras)
|
||||
var/obj/machinery/camera/c = camera
|
||||
|
||||
if(!c)
|
||||
continue
|
||||
|
||||
if(!c.can_use())
|
||||
continue
|
||||
|
||||
var/turf/point = locate(src.x + 8, src.y + 8, src.z)
|
||||
if(get_dist(point, c) > 24)
|
||||
continue
|
||||
|
||||
for(var/turf/t in c.can_see())
|
||||
newVisibleTurfs[t] = t
|
||||
|
||||
// Removes turf that isn't in turfs.
|
||||
newVisibleTurfs &= turfs
|
||||
|
||||
var/list/visAdded = newVisibleTurfs - visibleTurfs
|
||||
var/list/visRemoved = visibleTurfs - newVisibleTurfs
|
||||
|
||||
visibleTurfs = newVisibleTurfs
|
||||
obscuredTurfs = turfs - newVisibleTurfs
|
||||
|
||||
for(var/turf in visAdded)
|
||||
var/turf/t = turf
|
||||
if(t.obscured)
|
||||
obscured -= t.obscured
|
||||
for(var/eye in seenby)
|
||||
var/mob/aiEye/m = eye
|
||||
if(!m || !m.ai)
|
||||
continue
|
||||
if(m.ai.client)
|
||||
m.ai.client.images -= t.obscured
|
||||
|
||||
for(var/turf in visRemoved)
|
||||
var/turf/t = turf
|
||||
if(obscuredTurfs[t])
|
||||
if(!t.obscured)
|
||||
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
|
||||
|
||||
obscured += t.obscured
|
||||
for(var/eye in seenby)
|
||||
var/mob/aiEye/m = eye
|
||||
if(!m || !m.ai)
|
||||
seenby -= m
|
||||
continue
|
||||
if(m.ai.client)
|
||||
m.ai.client.images += t.obscured
|
||||
|
||||
// Create a new camera chunk, since the chunks are made as they are needed.
|
||||
|
||||
/datum/camerachunk/New(loc, x, y, z)
|
||||
|
||||
// 0xf = 15
|
||||
x &= ~0xf
|
||||
y &= ~0xf
|
||||
|
||||
src.x = x
|
||||
src.y = y
|
||||
src.z = z
|
||||
|
||||
/datum/visibility_chunk/camera/findNearbyViewpoints()
|
||||
for(var/obj/machinery/camera/c in range(16, locate(x + 8, y + 8, z)))
|
||||
if(c.can_use())
|
||||
viewpoints += c
|
||||
cameras += c
|
||||
|
||||
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
|
||||
|
||||
for(var/camera in cameras)
|
||||
var/obj/machinery/camera/c = camera
|
||||
if(!c)
|
||||
continue
|
||||
|
||||
if(!c.can_use())
|
||||
continue
|
||||
|
||||
for(var/turf/t in c.can_see())
|
||||
visibleTurfs[t] = t
|
||||
|
||||
// Removes turf that isn't in turfs.
|
||||
visibleTurfs &= turfs
|
||||
|
||||
obscuredTurfs = turfs - visibleTurfs
|
||||
|
||||
for(var/turf in obscuredTurfs)
|
||||
var/turf/t = turf
|
||||
if(!t.obscured)
|
||||
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
|
||||
obscured += t.obscured
|
||||
|
||||
#undef UPDATE_BUFFER
|
||||
@@ -1,51 +1,41 @@
|
||||
// AI EYE
|
||||
//
|
||||
// A mob that the AI controls to look around the station with.
|
||||
// An invisible (no icon) mob that the AI controls to look around the station with.
|
||||
// It streams chunks as it moves around, which will show it what the AI can and cannot see.
|
||||
|
||||
/mob/aiEye
|
||||
name = "Inactive AI Eye"
|
||||
icon = 'icons/mob/AI.dmi'
|
||||
icon_state = "eye"
|
||||
alpha = 127
|
||||
icon = 'icons/obj/status_display.dmi' // For AI friend secret shh :o
|
||||
var/list/visibleCameraChunks = list()
|
||||
var/mob/living/silicon/ai/ai = null
|
||||
density = 0
|
||||
status_flags = GODMODE // You can't damage it.
|
||||
mouse_opacity = 0
|
||||
see_in_dark = 7
|
||||
invisibility = INVISIBILITY_AI_EYE
|
||||
|
||||
/mob/aiEye/New()
|
||||
..()
|
||||
visibility_interface = new /datum/visibility_interface/ai_eye(src)
|
||||
invisibility = INVISIBILITY_MAXIMUM
|
||||
|
||||
// Movement code. Returns 0 to stop air movement from moving it.
|
||||
/mob/aiEye/Move()
|
||||
return 0
|
||||
|
||||
// Hide popout menu verbs
|
||||
/mob/aiEye/examine()
|
||||
/mob/aiEye/examine(atom/A as mob|obj|turf in view())
|
||||
set popup_menu = 0
|
||||
set src = usr.contents
|
||||
return 0
|
||||
|
||||
/mob/aiEye/pull()
|
||||
set popup_menu = 0
|
||||
set src = usr.contents
|
||||
return 0
|
||||
|
||||
/mob/aiEye/point()
|
||||
set popup_menu = 0
|
||||
set src = usr.contents
|
||||
return 0
|
||||
/mob/aiEye/examine(mob/user)
|
||||
|
||||
// Use this when setting the aiEye's location.
|
||||
// It will also stream the chunk that the new loc is in.
|
||||
/mob/aiEye/setLoc(var/T, var/cancel_tracking = 1)
|
||||
|
||||
/mob/aiEye/setLoc(var/T)
|
||||
if(ai)
|
||||
if(!isturf(ai.loc))
|
||||
return
|
||||
|
||||
if(cancel_tracking)
|
||||
ai.ai_cancel_tracking()
|
||||
|
||||
T = get_turf(T)
|
||||
loc = T
|
||||
cameranet.visibility(src)
|
||||
@@ -54,7 +44,6 @@
|
||||
//Holopad
|
||||
if(ai.holo)
|
||||
ai.holo.move_hologram()
|
||||
|
||||
|
||||
/mob/aiEye/proc/getLoc()
|
||||
|
||||
@@ -63,10 +52,6 @@
|
||||
return
|
||||
return ai.eyeobj.loc
|
||||
|
||||
|
||||
/mob/aiEye/Move()
|
||||
return 0
|
||||
|
||||
// AI MOVEMENT
|
||||
|
||||
// The AI's "eye". Described on the top of the page.
|
||||
@@ -78,7 +63,6 @@
|
||||
var/acceleration = 1
|
||||
var/obj/machinery/hologram/holopad/holo = null
|
||||
|
||||
|
||||
// Intiliaze the eye by assigning it's "ai" variable to us. Then set it's loc to us.
|
||||
/mob/living/silicon/ai/New()
|
||||
..()
|
||||
@@ -87,7 +71,7 @@
|
||||
spawn(5)
|
||||
eyeobj.loc = src.loc
|
||||
|
||||
/mob/living/silicon/ai/Destroy()
|
||||
/mob/living/silicon/ai/Del()
|
||||
eyeobj.ai = null
|
||||
del(eyeobj) // No AI, no Eye
|
||||
..()
|
||||
@@ -96,9 +80,7 @@
|
||||
if(istype(usr, /mob/living/silicon/ai))
|
||||
var/mob/living/silicon/ai/AI = usr
|
||||
if(AI.eyeobj && AI.client.eye == AI.eyeobj)
|
||||
AI.cameraFollow = null
|
||||
if (isturf(src.loc) || isturf(src))
|
||||
AI.eyeobj.setLoc(src)
|
||||
AI.eyeobj.setLoc(src)
|
||||
|
||||
// This will move the AIEye. It will also cause lights near the eye to light up, if toggled.
|
||||
// This is handled in the proc below this one.
|
||||
@@ -122,23 +104,24 @@
|
||||
else
|
||||
user.sprint = initial
|
||||
|
||||
user.cameraFollow = null
|
||||
|
||||
//user.unset_machine() //Uncomment this if it causes problems.
|
||||
//user.lightNearbyCamera()
|
||||
|
||||
|
||||
// Return to the Core.
|
||||
/mob/living/silicon/ai/proc/view_core()
|
||||
|
||||
/mob/living/silicon/ai/proc/core()
|
||||
set category = "AI Commands"
|
||||
set name = "AI Core"
|
||||
|
||||
view_core()
|
||||
|
||||
|
||||
/mob/living/silicon/ai/proc/view_core()
|
||||
current = null
|
||||
cameraFollow = null
|
||||
unset_machine()
|
||||
|
||||
if(src.eyeobj && src.loc)
|
||||
src.eyeobj.z = src.z
|
||||
src.eyeobj.loc = src.loc
|
||||
else
|
||||
if(!src.eyeobj)
|
||||
src << "ERROR: Eyeobj not found. Creating new eye..."
|
||||
src.eyeobj = new(src.loc)
|
||||
src.eyeobj.ai = src
|
||||
@@ -146,11 +129,11 @@
|
||||
|
||||
if(client && client.eye)
|
||||
client.eye = src
|
||||
|
||||
for(var/datum/visibility_chunk/camera/c in eyeobj.visibility_interface.visible_chunks)
|
||||
for(var/datum/camerachunk/c in eyeobj.visibleCameraChunks)
|
||||
c.remove(eyeobj)
|
||||
src.eyeobj.setLoc(src)
|
||||
|
||||
/mob/living/silicon/ai/verb/toggle_acceleration()
|
||||
/mob/living/silicon/ai/proc/toggle_acceleration()
|
||||
set category = "AI Commands"
|
||||
set name = "Toggle Camera Acceleration"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
HOW IT WORKS
|
||||
|
||||
It works by first creating a camera network datum. Inside of this camera network are "chunks" (which will be
|
||||
explained later) and "cameras". The cameras list is kept up to date by obj/machinery/camera/New() and Destroy().
|
||||
explained later) and "cameras". The cameras list is kept up to date by obj/machinery/camera/New() and Del().
|
||||
|
||||
Next the camera network has chunks. These chunks are a 16x16 tile block of turfs and cameras contained inside the chunk.
|
||||
These turfs are then sorted out based on what the cameras can and cannot see. If none of the cameras can see the turf, inside
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
WHERE IS EVERYTHING?
|
||||
|
||||
cameraNetwork.dm = Everything about the cameraNetwork datum.
|
||||
cameranet.dm = Everything about the cameranet datum.
|
||||
chunk.dm = Everything about the chunk datum.
|
||||
eye.dm = Everything about the AI and the AIEye.
|
||||
updating.dm = Everything about triggers that will update chunks.
|
||||
|
||||
@@ -1,3 +1,80 @@
|
||||
#define BORG_CAMERA_BUFFER 30
|
||||
|
||||
//UPDATE TRIGGERS, when the chunk (and the surrounding chunks) should update.
|
||||
|
||||
// TURFS
|
||||
|
||||
/turf
|
||||
var/image/obscured
|
||||
|
||||
/turf/proc/visibilityChanged()
|
||||
if(ticker)
|
||||
cameranet.updateVisibility(src)
|
||||
|
||||
/turf/simulated/Del()
|
||||
visibilityChanged()
|
||||
..()
|
||||
|
||||
/turf/simulated/New()
|
||||
..()
|
||||
visibilityChanged()
|
||||
|
||||
|
||||
|
||||
// STRUCTURES
|
||||
|
||||
/obj/structure/Del()
|
||||
if(ticker)
|
||||
cameranet.updateVisibility(src)
|
||||
..()
|
||||
|
||||
/obj/structure/New()
|
||||
..()
|
||||
if(ticker)
|
||||
cameranet.updateVisibility(src)
|
||||
|
||||
// EFFECTS
|
||||
|
||||
/obj/effect/Del()
|
||||
if(ticker)
|
||||
cameranet.updateVisibility(src)
|
||||
..()
|
||||
|
||||
/obj/effect/New()
|
||||
..()
|
||||
if(ticker)
|
||||
cameranet.updateVisibility(src)
|
||||
|
||||
|
||||
// DOORS
|
||||
|
||||
// Simply updates the visibility of the area when it opens/closes/destroyed.
|
||||
/obj/machinery/door/update_nearby_tiles(need_rebuild)
|
||||
. = ..(need_rebuild)
|
||||
// Glass door glass = 1
|
||||
// don't check then?
|
||||
if(!glass && cameranet)
|
||||
cameranet.updateVisibility(src, 0)
|
||||
|
||||
|
||||
// ROBOT MOVEMENT
|
||||
|
||||
// Update the portable camera everytime the Robot moves.
|
||||
// This might be laggy, comment it out if there are problems.
|
||||
/mob/living/silicon/robot/var/updating = 0
|
||||
|
||||
/mob/living/silicon/robot/Move()
|
||||
var/oldLoc = src.loc
|
||||
. = ..()
|
||||
if(.)
|
||||
if(src.camera && src.camera.network.len)
|
||||
if(!updating)
|
||||
updating = 1
|
||||
spawn(BORG_CAMERA_BUFFER)
|
||||
if(oldLoc != src.loc)
|
||||
cameranet.updatePortableCamera(src.camera)
|
||||
updating = 0
|
||||
|
||||
// CAMERA
|
||||
|
||||
// An addition to deactivate which removes/adds the camera from the chunk list based on if it works or not.
|
||||
@@ -5,30 +82,29 @@
|
||||
/obj/machinery/camera/deactivate(user as mob, var/choice = 1)
|
||||
..(user, choice)
|
||||
if(src.can_use())
|
||||
cameranet.addViewpoint(src)
|
||||
cameranet.addCamera(src)
|
||||
else
|
||||
src.SetLuminosity(0)
|
||||
cameranet.removeViewpoint(src)
|
||||
cameranet.removeCamera(src)
|
||||
|
||||
/obj/machinery/camera/New()
|
||||
..()
|
||||
//Camera must be added to global list of all cameras no matter what...
|
||||
if(cameranet.cameras_unsorted || !ticker)
|
||||
cameranet.viewpoints += src
|
||||
cameranet.cameras += src
|
||||
cameranet.cameras_unsorted = 1
|
||||
else
|
||||
dd_insertObjectList(cameranet.viewpoints, src)
|
||||
dd_insertObjectList(cameranet.cameras, src)
|
||||
|
||||
var/list/open_networks = difflist(network,RESTRICTED_CAMERA_NETWORKS) //...but if all of camera's networks are restricted, it only works for specific camera consoles.
|
||||
var/list/open_networks = difflist(network,restricted_camera_networks) //...but if all of camera's networks are restricted, it only works for specific camera consoles.
|
||||
if(open_networks.len) //If there is at least one open network, chunk is available for AI usage.
|
||||
cameranet.addViewpoint(src)
|
||||
cameranet.addCamera(src)
|
||||
|
||||
/obj/machinery/camera/Del()
|
||||
|
||||
cameranet.viewpoints -= src
|
||||
var/list/open_networks = difflist(network,RESTRICTED_CAMERA_NETWORKS)
|
||||
cameranet.cameras -= src
|
||||
var/list/open_networks = difflist(network,restricted_camera_networks)
|
||||
if(open_networks.len)
|
||||
cameranet.removeViewpoint(src)
|
||||
cameranet.removeCamera(src)
|
||||
..()
|
||||
|
||||
#undef BORG_CAMERA_BUFFER
|
||||
@@ -1,10 +0,0 @@
|
||||
/datum/visibility_interface/ai_eye
|
||||
chunk_type = /datum/visibility_chunk/camera
|
||||
|
||||
/datum/visibility_interface/ai_eye/getClient()
|
||||
var/mob/aiEye/eye = controller
|
||||
if (!eye)
|
||||
return FALSE
|
||||
if (!eye.ai)
|
||||
return FALSE
|
||||
return eye.ai.client
|
||||
@@ -19,54 +19,6 @@ It reuses a lot of code from the AIEye cameraNetwork. In order to work properly,
|
||||
if (vp)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
|
||||
/datum/visibility_chunk/cult/validViewpoint(var/atom/viewpoint)
|
||||
var/turf/point = locate(src.x + 8, src.y + 8, src.z)
|
||||
if(get_dist(point, viewpoint) > 24)
|
||||
return FALSE
|
||||
|
||||
if (isCultRune(viewpoint) || isCultViewpoint(viewpoint))
|
||||
return viewpoint:can_use()
|
||||
return FALSE
|
||||
|
||||
|
||||
/datum/visibility_chunk/cult/getVisibleTurfsForViewpoint(var/viewpoint)
|
||||
var/obj/effect/rune/rune = viewpoint
|
||||
if (rune)
|
||||
return rune.can_see()
|
||||
var/obj/cult_viewpoint/cvp = viewpoint
|
||||
if (cvp)
|
||||
return cvp.can_see()
|
||||
return null
|
||||
|
||||
|
||||
/datum/visibility_chunk/cult/findNearbyViewpoints()
|
||||
for(var/obj/cult_viewpoint/vp in range(16, locate(x + 8, y + 8, z)))
|
||||
if(vp.can_use())
|
||||
viewpoints += vp
|
||||
for(var/obj/effect/rune/rune in range(16, locate(x + 8, y + 8, z)))
|
||||
viewpoints += rune
|
||||
|
||||
|
||||
/datum/visibility_network/cult
|
||||
ChunkType = /datum/visibility_chunk/cult
|
||||
|
||||
|
||||
/datum/visibility_network/cult/validViewpoint(var/viewpoint)
|
||||
if (isCultRune(viewpoint) || isCultViewpoint(viewpoint))
|
||||
return viewpoint:can_use()
|
||||
return FALSE
|
||||
|
||||
/datum/visibility_network/cult/getViewpointFromMob(var/mob/currentMob)
|
||||
for(var/obj/cult_viewpoint/currentView in currentMob)
|
||||
return currentView
|
||||
return FALSE
|
||||
|
||||
|
||||
/datum/visibility_interface/cult
|
||||
chunk_type = /datum/visibility_chunk/cult
|
||||
|
||||
|
||||
/*
|
||||
RUNE JUNK
|
||||
|
||||
@@ -52,7 +52,6 @@ mob/spirit/proc/Spirit_Move(direct)
|
||||
mob/spirit/setLoc(var/T)
|
||||
T = get_turf(T)
|
||||
loc = T
|
||||
cultNetwork.visibility(src)
|
||||
|
||||
mob/spirit/verb/toggle_acceleration()
|
||||
set category = "Spirit"
|
||||
|
||||
@@ -38,9 +38,6 @@ mob/spirit/New()
|
||||
|
||||
loc = pick(latejoin)
|
||||
|
||||
// hook them to the cult visibility network
|
||||
visibility_interface = new /datum/visibility_interface/cult(src)
|
||||
|
||||
// no nameless spirits
|
||||
if (!name)
|
||||
name = "Boogyman"
|
||||
|
||||
@@ -18,9 +18,6 @@ var/obj/cult_viewpoint/list/cult_viewpoints = list()
|
||||
/obj/cult_viewpoint/New(var/mob/target)
|
||||
owner = target
|
||||
//src.loc = owner
|
||||
owner.addToVisibilityNetwork(cultNetwork)
|
||||
cultNetwork.viewpoints+=src
|
||||
cultNetwork.addViewpoint(src)
|
||||
cult_viewpoints+=src
|
||||
//handle_missing_mask()
|
||||
..()
|
||||
@@ -28,10 +25,7 @@ var/obj/cult_viewpoint/list/cult_viewpoints = list()
|
||||
|
||||
/obj/cult_viewpoint/Del()
|
||||
processing_objects.Remove(src)
|
||||
cultNetwork.viewpoints-=src
|
||||
cultNetwork.removeViewpoint(src)
|
||||
cult_viewpoints-=src
|
||||
owner.removeFromVisibilityNetwork(cultNetwork)
|
||||
..()
|
||||
return
|
||||
|
||||
@@ -134,6 +128,8 @@ var/obj/cult_viewpoint/list/cult_viewpoints = list()
|
||||
|
||||
|
||||
/obj/cult_viewpoint/proc/get_display_name()
|
||||
if(istype(src,/obj/effect/rune))
|
||||
return name
|
||||
if (!owner)
|
||||
return
|
||||
if (cult_name)
|
||||
|
||||
+1
-1
@@ -801,7 +801,7 @@ var/list/cheartstopper = list("potassium_chloride") //this stops the heart when
|
||||
#define GETPULSE_HAND 0 //less accurate (hand)
|
||||
#define GETPULSE_TOOL 1 //more accurate (med scanner, sleeper, etc)
|
||||
|
||||
var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accessed by preexisting terminals. AIs and new terminals can't use them.
|
||||
var/list/restricted_camera_networks = list( //Those networks can only be accessed by preexisting terminals. AIs and new terminals can't use them.
|
||||
"CentCom",
|
||||
"ERT",
|
||||
"NukeOps",
|
||||
|
||||
@@ -218,11 +218,6 @@
|
||||
#include "code\datums\spells\trigger.dm"
|
||||
#include "code\datums\spells\turf_teleport.dm"
|
||||
#include "code\datums\spells\wizard.dm"
|
||||
#include "code\datums\visibility_networks\chunk.dm"
|
||||
#include "code\datums\visibility_networks\dictionary.dm"
|
||||
#include "code\datums\visibility_networks\update_triggers.dm"
|
||||
#include "code\datums\visibility_networks\visibility_interface.dm"
|
||||
#include "code\datums\visibility_networks\visibility_network.dm"
|
||||
#include "code\datums\wires\airlock.dm"
|
||||
#include "code\datums\wires\alarm.dm"
|
||||
#include "code\datums\wires\apc.dm"
|
||||
@@ -1273,7 +1268,6 @@
|
||||
#include "code\modules\mob\living\silicon\ai\freelook\eye.dm"
|
||||
#include "code\modules\mob\living\silicon\ai\freelook\read_me.dm"
|
||||
#include "code\modules\mob\living\silicon\ai\freelook\update_triggers.dm"
|
||||
#include "code\modules\mob\living\silicon\ai\freelook\visibility_interface.dm"
|
||||
#include "code\modules\mob\living\silicon\decoy\death.dm"
|
||||
#include "code\modules\mob\living\silicon\decoy\decoy.dm"
|
||||
#include "code\modules\mob\living\silicon\decoy\life.dm"
|
||||
|
||||
Reference in New Issue
Block a user