mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-22 03:26:21 +01:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
VN.updateVisibility(A, opacity_check)
|
||||
|
||||
/turf
|
||||
var/image/obscured
|
||||
var/list/image/obfuscations = new()
|
||||
|
||||
/turf/drain_power()
|
||||
return -1
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user