From bbe5d67e447982f78547564c70f3d0bea5f2a209 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Tue, 24 Mar 2015 09:40:24 +0100 Subject: [PATCH] Refactors the AI eye. Now possible to customize chunk obfuscation image per chunk type. Obfuscation images are stored per type (thus the small datum structure) to reduce memory footprint in the case of multiple chunks using the same image. --- code/game/machinery/machinery.dm | 2 +- code/modules/mob/freelook/chunk.dm | 25 +++++++++++-------- code/modules/mob/freelook/eye.dm | 3 +++ code/modules/mob/freelook/update_triggers.dm | 2 +- .../mob/living/silicon/ai/freelook/eye.dm | 3 --- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 5a4e6d7255..481098c59d 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -196,7 +196,7 @@ Class Procs: user.set_machine(src) /obj/machinery/CouldNotUseTopic(var/mob/user) - usr.unset_machine() + user.unset_machine() //////////////////////////////////////////////////////////////////////////////////////////// diff --git a/code/modules/mob/freelook/chunk.dm b/code/modules/mob/freelook/chunk.dm index ecc9d0b4d3..8c6c7d043a 100644 --- a/code/modules/mob/freelook/chunk.dm +++ b/code/modules/mob/freelook/chunk.dm @@ -5,6 +5,10 @@ // A 16x16 grid of the map with a list of turfs that can be seen, are visible and are dimmed. // Allows the Eye to stream these chunks and know what it can and cannot see. +/datum/obfuscation + var/icon = 'icons/effects/cameravis.dmi' + var/icon_state = "black" + /datum/chunk var/list/obscuredTurfs = list() var/list/visibleTurfs = list() @@ -17,6 +21,7 @@ var/x = 0 var/y = 0 var/z = 0 + var/datum/obfuscation/obfuscation = new() // Add an eye to the chunk, then update if changed. @@ -83,29 +88,29 @@ for(var/turf in visAdded) var/turf/t = turf - if(t.obscured) - obscured -= t.obscured + if(t.obfuscations[obfuscation.type]) + obscured -= t.obfuscations[obfuscation.type] for(var/eye in seenby) var/mob/eye/m = eye if(!m || !m.owner) continue if(m.owner.client) - m.owner.client.images -= t.obscured + m.owner.client.images -= t.obfuscations[obfuscation.type] 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) + if(!t.obfuscations[obfuscation.type]) + t.obfuscations[obfuscation.type] = image(obfuscation.icon, t, obfuscation.icon_state, 15) - obscured += t.obscured + obscured += t.obfuscations[obfuscation.type] for(var/eye in seenby) var/mob/eye/m = eye if(!m || !m.owner) seenby -= m continue if(m.owner.client) - m.owner.client.images += t.obscured + m.owner.client.images += t.obfuscations[obfuscation.type] /datum/chunk/proc/acquireVisibleTurfs(var/list/visible) @@ -134,8 +139,8 @@ 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 + if(!t.obfuscations[obfuscation.type]) + t.obfuscations[obfuscation.type] = image(obfuscation.icon, t, obfuscation.icon_state, 15) + obscured += t.obfuscations[obfuscation.type] #undef UPDATE_BUFFER diff --git a/code/modules/mob/freelook/eye.dm b/code/modules/mob/freelook/eye.dm index 337ff65910..e83f209028 100644 --- a/code/modules/mob/freelook/eye.dm +++ b/code/modules/mob/freelook/eye.dm @@ -56,6 +56,9 @@ mob/eye/Del() T = get_turf(T) loc = T + if(owner.client) + owner.client.eye = src + visualnet.visibility(src) return 1 return 0 diff --git a/code/modules/mob/freelook/update_triggers.dm b/code/modules/mob/freelook/update_triggers.dm index 609787efcd..9bba162c40 100644 --- a/code/modules/mob/freelook/update_triggers.dm +++ b/code/modules/mob/freelook/update_triggers.dm @@ -8,7 +8,7 @@ VN.updateVisibility(A, opacity_check) /turf - var/image/obscured + var/list/image/obfuscations = new() /turf/drain_power() return -1 diff --git a/code/modules/mob/living/silicon/ai/freelook/eye.dm b/code/modules/mob/living/silicon/ai/freelook/eye.dm index ac21161de3..b7dce613f8 100644 --- a/code/modules/mob/living/silicon/ai/freelook/eye.dm +++ b/code/modules/mob/living/silicon/ai/freelook/eye.dm @@ -17,8 +17,6 @@ if(cancel_tracking) ai.ai_cancel_tracking() - if(ai.client) - ai.client.eye = src //Holopad if(ai.holo) ai.holo.move_hologram(ai) @@ -41,7 +39,6 @@ eyeobj.ai = src eyeobj.owner = src eyeobj.name = "[src.name] (AI Eye)" // Give it a name - eyeobj.visualnet = cameranet spawn(5) eyeobj.loc = src.loc