Some different parallax shit (#10858)

* Some different parallax shit

Fixes parallax not letting your view reduce below size 7
Removes parallax forcing you to see things over walls
Fixes whatever other seeing space bugs there are

* Some code improvements
Fixes hyperspace transit layering bug
This commit is contained in:
clusterfack
2016-07-08 23:16:09 -05:00
committed by GitHub
parent 2f04651415
commit 131f5659fc
9 changed files with 101 additions and 107 deletions

View File

@@ -206,7 +206,7 @@ var/global/obj/screen/clicker/catcher = new()
mymob:schematics_background = using
reload_fullscreen()
update_parallax_and_dust()
update_parallax_existence()
//Triggered when F12 is pressed (Unless someone changed something in the DMF)
/mob/verb/button_pressed_F12()

View File

@@ -1,6 +1,8 @@
/*
* This file handles all parallax-related business once the parallax itself is initialized with the rest of the HUD
*/
#define PARALLAX_IMAGE_WIDTH 15
#define PARALLAX_IMAGE_TILES (PARALLAX_IMAGE_WIDTH**2)
var/list/parallax_on_clients = list()
@@ -11,9 +13,10 @@ var/list/parallax_on_clients = list()
icon = 'icons/turf/space.dmi'
icon_state = "blank"
name = "space parallax"
screen_loc = "CENTER,CENTER"
blend_mode = BLEND_ADD
layer = AREA_LAYER
plane = PLANE_SPACE_PARALLAX//changing this var doesn't actually change the plane of its overlays
plane = PLANE_SPACE_PARALLAX
globalscreen = 1
var/parallax_speed = 0
@@ -24,6 +27,7 @@ var/list/parallax_on_clients = list()
/obj/screen/plane_master/parallax_master
plane = PLANE_SPACE_PARALLAX
blend_mode = BLEND_MULTIPLY
color = list(
1,0,0,0,
0,1,0,0,
@@ -31,62 +35,35 @@ var/list/parallax_on_clients = list()
0,0,0,0,
0,0,0,1)
/obj/screen/plane_master/parallax_spacemaster //Turns space white, causing the parallax to only show in areas with opacity. Somehow
plane = PLANE_SPACE_BACKGROUND
color = list(
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
1,1,1,1)
/obj/screen/plane_master/parallax_dustmaster
plane = PLANE_SPACE_DUST
color = list(0,0,0,0)
/datum/hud/proc/update_parallax()
var/client/C = mymob.client
if(!parallax_initialized || C.updating_parallax) return
for(var/turf/T in range(get_turf(C.eye),C.view))
if(istype(T,/turf/space))
C.updating_parallax = 1
break
if(!C.updating_parallax)
/datum/hud/proc/update_parallax_existence()
if(!parallax_initialized)
return
initialize_parallax()
update_parallax()
update_parallax_values()
//multiple sub-procs for profiling purposes
if(update_parallax1())
update_parallax2(0)
update_parallax3()
C.updating_parallax = 0
else
C.updating_parallax = 0
/datum/hud/proc/update_parallax_and_dust()
/datum/hud/proc/initialize_parallax()
var/client/C = mymob.client
if(!parallax_initialized || C.updating_parallax) return
C.updating_parallax = 1
if(update_parallax1())
update_parallax2(1)
update_parallax3()
C.updating_parallax = 0
else
C.updating_parallax = 0
/datum/hud/proc/update_parallax1()
var/client/C = mymob.client
//DO WE UPDATE PARALLAX
if(C.prefs.space_parallax)//have to exclude Centcom so parallax doens't appear during hyperspace
parallax_on_clients |= C
else
for(var/obj/screen/parallax/bgobj in C.parallax)
C.screen -= bgobj
parallax_on_clients -= C
C.screen -= C.parallax_master
C.screen -= C.parallax_dustmaster
return 0
if(!C.parallax_master)
C.parallax_master = getFromPool(/obj/screen/plane_master/parallax_master)
if(!C.parallax_spacemaster)
C.parallax_spacemaster = getFromPool(/obj/screen/plane_master/parallax_spacemaster)
if(!C.parallax_dustmaster)
C.parallax_dustmaster = getFromPool(/obj/screen/plane_master/parallax_dustmaster)
return 1
/datum/hud/proc/update_parallax2(forcerecalibrate = 0)
var/client/C = mymob.client
//DO WE HAVE TO REPLACE ALL THE LAYERS
if(!C.parallax.len)
for(var/obj/screen/parallax/bgobj in parallax_icon)
@@ -95,34 +72,49 @@ var/list/parallax_on_clients = list()
parallax_layer.base_offset_x = bgobj.base_offset_x
parallax_layer.base_offset_y = bgobj.base_offset_y
parallax_layer.parallax_speed = bgobj.parallax_speed
parallax_layer.screen_loc = bgobj.screen_loc
C.parallax += parallax_layer
if(bgobj.parallax_speed)
C.parallax_movable += parallax_layer
var/parallax_loaded = 0
for(var/obj/screen/S in C.screen)
if(istype(S,/obj/screen/parallax))
parallax_loaded = 1
break
if(!C.parallax_offset.len)
C.parallax_offset["horizontal"] = 0
C.parallax_offset["vertical"] = 0
if(forcerecalibrate || !parallax_loaded)
C.screen |= C.parallax_dustmaster
/datum/hud/proc/update_parallax()
var/client/C = mymob.client
if(C.prefs.space_parallax)
parallax_on_clients |= C
for(var/obj/screen/parallax/bgobj in C.parallax)
C.screen |= bgobj
C.screen |= C.parallax_master
C.screen |= C.parallax_dustmaster
C.parallax_dustmaster.color = list(0,0,0,0)
C.screen |= C.parallax_spacemaster
if(C.prefs.space_dust)
C.parallax_dustmaster.color = list(
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1)
else
C.parallax_dustmaster.color = list(0,0,0,0)
else
for(var/obj/screen/parallax/bgobj in C.parallax)
C.screen -= bgobj
parallax_on_clients -= C
C.screen -= C.parallax_master
C.screen -= C.parallax_spacemaster
C.parallax_dustmaster.color = list(0,0,0,0)
if(!C.parallax_offset.len)
C.parallax_offset["horizontal"] = 0
C.parallax_offset["vertical"] = 0
/datum/hud/proc/update_parallax3()
/datum/hud/proc/update_parallax_values()
var/client/C = mymob.client
if(!parallax_initialized)
return
if(!(locate(/turf/space) in trange(C.view,get_turf(C.eye))))
return
//ACTUALLY MOVING THE PARALLAX
var/turf/posobj = get_turf(C.eye)
@@ -135,7 +127,7 @@ var/list/parallax_on_clients = list()
C.previous_turf = posobj
for(var/obj/screen/parallax/bgobj in C.parallax)
for(var/obj/screen/parallax/bgobj in C.parallax_movable)
if(bgobj.parallax_speed)//only the middle and front layers actually move
var/accumulated_offset_x = bgobj.base_offset_x - round(C.parallax_offset["horizontal"] * bgobj.parallax_speed * (C.prefs.parallax_speed/2))
var/accumulated_offset_y = bgobj.base_offset_y - round(C.parallax_offset["vertical"] * bgobj.parallax_speed * (C.prefs.parallax_speed/2))
@@ -150,9 +142,9 @@ var/list/parallax_on_clients = list()
while(accumulated_offset_y < -720)
accumulated_offset_y += 1440
bgobj.screen_loc = "CENTER-7:[accumulated_offset_x],CENTER-7:[accumulated_offset_y]"
bgobj.screen_loc = "CENTER:[accumulated_offset_x],CENTER:[accumulated_offset_y]"
else
bgobj.screen_loc = "CENTER-7:[bgobj.base_offset_x],CENTER-7:[bgobj.base_offset_y]"
bgobj.screen_loc = "CENTER:[bgobj.base_offset_x],CENTER:[bgobj.base_offset_y]"
//Parallax generation code below
@@ -160,98 +152,99 @@ var/list/parallax_on_clients = list()
#define PARALLAX3_ICON_NUMBER 14
#define PARALLAX2_ICON_NUMBER 10
/datum/controller/game_controller/proc/cachespaceparallax()
/datum/controller/game_controller/proc/create_global_parallax_icons()
var/list/plane1 = list()
var/list/plane2 = list()
var/list/plane3 = list()
var/list/pixel_x = list()
var/list/pixel_y = list()
var/index = 1
for(var/i = 0 to 224)
for(var/i = 0 to (PARALLAX_IMAGE_TILES-1))
for(var/j = 1 to 9)
plane1 += rand(1,26)
plane2 += rand(1,26)
plane3 += rand(1,26)
pixel_x += 32 * (i%15)
pixel_y += 32 * round(i/15)
pixel_x += world.icon_size * (i%PARALLAX_IMAGE_WIDTH)
pixel_y += world.icon_size * round(i/PARALLAX_IMAGE_WIDTH)
for(var/i in 0 to 8)
var/obj/screen/parallax/parallax_layer = new /obj/screen/parallax()
var/obj/screen/parallax/parallax_layer = getFromPool(/obj/screen/parallax)
var/list/L = list()
for(var/j in 1 to 225)
if(plane1[j+i*225] <= PARALLAX4_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax4.dmi',"[plane1[j+i*225]]")
for(var/j in 1 to PARALLAX_IMAGE_TILES)
if(plane1[j+i*PARALLAX_IMAGE_TILES] <= PARALLAX4_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax4.dmi',"[plane1[j+i*PARALLAX_IMAGE_TILES]]")
I.pixel_x = pixel_x[j]
I.pixel_y = pixel_y[j]
I.plane = PLANE_SPACE_PARALLAX
L += I
parallax_layer.overlays = L
parallax_layer.parallax_speed = 0
parallax_layer.plane = PLANE_SPACE_PARALLAX
calibrate_parallax(parallax_layer,i+1)
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
index++
for(var/i in 0 to 8)
var/obj/screen/parallax/parallax_layer = new /obj/screen/parallax()
var/obj/screen/parallax/parallax_layer = getFromPool(/obj/screen/parallax)
var/list/L = list()
for(var/j in 1 to 225)
if(plane2[j+i*225] <= PARALLAX3_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax3.dmi',"[plane2[j+i*225]]")
for(var/j in 1 to PARALLAX_IMAGE_TILES)
if(plane2[j+i*PARALLAX_IMAGE_TILES] <= PARALLAX3_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax3.dmi',"[plane2[j+i*PARALLAX_IMAGE_TILES]]")
I.pixel_x = pixel_x[j]
I.pixel_y = pixel_y[j]
I.plane = PLANE_SPACE_PARALLAX
L += I
parallax_layer.overlays = L
parallax_layer.parallax_speed = 1
parallax_layer.plane = PLANE_SPACE_PARALLAX
calibrate_parallax(parallax_layer,i+1)
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
index++
for(var/i in 0 to 8)
var/obj/screen/parallax/parallax_layer = new /obj/screen/parallax()
var/obj/screen/parallax/parallax_layer = getFromPool(/obj/screen/parallax)
var/list/L = list()
for(var/j in 1 to 225)
if(plane3[j+i*225] <= PARALLAX2_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax2.dmi',"[plane3[j+i*225]]")
for(var/j in 1 to PARALLAX_IMAGE_TILES)
if(plane3[j+i*PARALLAX_IMAGE_TILES] <= PARALLAX2_ICON_NUMBER)
var/image/I = image('icons/turf/space_parallax2.dmi',"[plane3[j+i*PARALLAX_IMAGE_TILES]]")
I.pixel_x = pixel_x[j]
I.pixel_y = pixel_y[j]
I.plane = PLANE_SPACE_PARALLAX
L += I
parallax_layer.overlays = L
parallax_layer.parallax_speed = 2
parallax_layer.plane = PLANE_SPACE_PARALLAX
calibrate_parallax(parallax_layer,i+1)
parallax_layer.calibrate_parallax(i+1)
parallax_icon[index] = parallax_layer
index++
parallax_initialized = 1
/proc/calibrate_parallax(var/obj/screen/parallax/p_layer,var/i)
if(!p_layer || !i) return
/obj/screen/parallax/proc/calibrate_parallax(var/i)
if(!i) return
/* Placement of screen objects
1 2 3
4 5 6
7 8 9
*/
base_offset_x = -7*world.icon_size
base_offset_y = -7*world.icon_size
switch(i)
if(1,4,7)
p_layer.base_offset_x = -480
base_offset_x -= world.icon_size*PARALLAX_IMAGE_WIDTH
if(3,6,9)
p_layer.base_offset_x = 480
base_offset_x += world.icon_size*PARALLAX_IMAGE_WIDTH
switch(i)
if(1,2,3)
p_layer.base_offset_y = 480
base_offset_y += world.icon_size*PARALLAX_IMAGE_WIDTH
if(7,8,9)
p_layer.base_offset_y = -480
base_offset_y -= world.icon_size*PARALLAX_IMAGE_WIDTH
screen_loc = "CENTER:[base_offset_x],CENTER:[base_offset_y]"
#undef PARALLAX4_ICON_NUMBER
#undef PARALLAX3_ICON_NUMBER
#undef PARALLAX2_ICON_NUMBER
#undef PARALLAX2_ICON_NUMBER
#undef PARALLAX_IMAGE_WIDTH
#undef PARALLAX_IMAGE_TILES

View File

@@ -103,7 +103,7 @@ datum/controller/game_controller/proc/setup()
log_startup_progress(" Finished caching damage icons in [stop_watch(watch)]s.")
log_startup_progress("Caching space parallax simulation...")
cachespaceparallax()
create_global_parallax_icons()
log_startup_progress(" Finished caching space parallax simulation in [stop_watch(watch)]s.")
buildcamlist()

View File

@@ -335,15 +335,15 @@
if(locate(/mob) in src)
for(var/client/C in parallax_on_clients)
if((get_turf(C.eye) == destination) && (C.mob.hud_used))
C.mob.hud_used.update_parallax()
C.mob.hud_used.update_parallax_values()
/mob/update_client_hook(atom/destination)
if(locate(/mob) in src)
for(var/client/C in parallax_on_clients)
if((get_turf(C.eye) == destination) && (C.mob.hud_used))
C.mob.hud_used.update_parallax()
C.mob.hud_used.update_parallax_values()
else if(client && hud_used)
hud_used.update_parallax()
hud_used.update_parallax_values()
/atom/movable/proc/forceEnter(atom/destination)
if(destination)

View File

@@ -33,7 +33,7 @@ var/list/camera_names=list()
var/hear_voice = 0
var/vision_flags = SEE_SELF | SEE_PIXELS //Only applies when viewing the camera through a console. REMOVE SEE_PIXELS IF IT IS DEEMED TOO BUGGY TO WORK AND LUMMOX REFUSES TO FIX IT
var/vision_flags = SEE_SELF //Only applies when viewing the camera through a console.
/obj/machinery/camera/update_icon()
var/EMPd = stat & EMPED

View File

@@ -1,5 +1,5 @@
/turf/space/transit
plane = PLANE_BASE
plane = PLANE_TURF
var/pushdirection // push things that get caught in the transit tile this direction
/turf/space/transit/New()

View File

@@ -66,9 +66,10 @@
////////////
//PARALLAX//
////////////
var/updating_parallax = 0
var/list/parallax = list()
var/list/parallax_movable = list()
var/list/parallax_offset = list()
var/turf/previous_turf = null
var/obj/screen/plane_master/parallax_master/parallax_master = null
var/obj/screen/plane_master/parallax_dustmaster/parallax_dustmaster = null
var/obj/screen/plane_master/parallax_dustmaster/parallax_dustmaster = null
var/obj/screen/plane_master/parallax_spacemaster/parallax_spacemaster = null

View File

@@ -259,7 +259,7 @@
to_chat(usr, "Space parallax is now activated.")
if(mob && mob.hud_used)
mob.hud_used.update_parallax_and_dust()
mob.hud_used.update_parallax_existence()
/client/verb/toggle_space_dust()
set name = "Toggle Space Dust"
@@ -275,7 +275,7 @@
to_chat(usr, "Space dust is now activated.")
if(mob && mob.hud_used)
mob.hud_used.update_parallax_and_dust()
mob.hud_used.update_parallax_existence()
/client/verb/toggle_parallax_speed()
set name = "Change Parallax Speed"

View File

@@ -46,7 +46,7 @@
delayNextMove(0)
sight |= SEE_SELF | SEE_PIXELS
sight |= SEE_SELF
..()