mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
The One Where You Can Aim Lights
This commit is contained in:
@@ -94,7 +94,6 @@
|
||||
cone = new()
|
||||
cone_hint_x = movable_parent.light_cone_x_offset
|
||||
cone_hint_y = movable_parent.light_cone_y_offset
|
||||
cone.transform = cone.transform.Translate(-32, -32)
|
||||
set_direction(movable_parent.dir)
|
||||
if(!isnull(_range))
|
||||
movable_parent.set_light_range(_range)
|
||||
@@ -436,19 +435,52 @@
|
||||
var/turf/lit_turf = t
|
||||
lit_turf.dynamic_lumcount -= difference
|
||||
|
||||
///Here we append the behavior associated to changing lum_power.
|
||||
///Moves the light directional_atom that emits our "light" based on our position and our direction
|
||||
/datum/component/overlay_lighting/proc/cast_directional_light()
|
||||
var/final_distance = cast_range
|
||||
|
||||
//Lower the distance by 1 if we're not looking at a cardinal direction, and we're not a short cast
|
||||
if(final_distance > SHORT_CAST && !(ALL_CARDINALS & current_direction))
|
||||
final_distance -= 1
|
||||
var/turf/scanning = get_turf(current_holder)
|
||||
|
||||
. = 0
|
||||
for(var/i in 1 to final_distance)
|
||||
var/turf/next_turf = get_step(scanning, current_direction)
|
||||
if(isnull(next_turf) || IS_OPAQUE_TURF(next_turf))
|
||||
if(isnull(next_turf) || IS_OPAQUE_TURF_DIR(next_turf, reverse_dir[current_direction]))
|
||||
break
|
||||
scanning = next_turf
|
||||
.++
|
||||
|
||||
directional_atom.forceMove(scanning)
|
||||
directional_atom.face_light(GET_PARENT, dir2angle(current_direction), .)
|
||||
|
||||
///Tries to place the directional light in a specific turf
|
||||
/datum/component/overlay_lighting/proc/place_directional_light(turf/target)
|
||||
var/final_distance = round(cast_range*2)
|
||||
|
||||
//Lower the distance by 1 if we're not looking at a cardinal direction, and we're not a short cast
|
||||
if(final_distance > SHORT_CAST && !(ALL_CARDINALS & get_dir(GET_PARENT, target)))
|
||||
final_distance -= 1
|
||||
var/turf/scanning = get_turf(GET_PARENT)
|
||||
|
||||
. = 0
|
||||
for(var/i in 1 to final_distance)
|
||||
var/next_dir = get_dir(scanning, target)
|
||||
var/turf/next_turf = get_step(scanning, next_dir)
|
||||
if(isnull(next_turf) || IS_OPAQUE_TURF_DIR(next_turf, get_dir(scanning, next_turf)))
|
||||
break
|
||||
scanning = next_turf
|
||||
.++
|
||||
|
||||
directional_atom.forceMove(scanning)
|
||||
var/turf/Ts = get_turf(GET_PARENT)
|
||||
var/turf/To = get_turf(GET_LIGHT_SOURCE)
|
||||
|
||||
var/angle = Get_Angle(Ts, To)
|
||||
|
||||
directional_atom.face_light(GET_PARENT, angle, .)
|
||||
set_cone_direction(NORTH, angle)
|
||||
|
||||
///Called when current_holder changes loc.
|
||||
/datum/component/overlay_lighting/proc/on_holder_dir_change(atom/movable/source, olddir, newdir)
|
||||
@@ -460,14 +492,23 @@
|
||||
SIGNAL_HANDLER
|
||||
set_direction(newdir)
|
||||
|
||||
///Sets the cone's direction for directional lighting
|
||||
/datum/component/overlay_lighting/proc/set_cone_direction(dir, angle)
|
||||
cone.reset_transform()
|
||||
if(dir)
|
||||
cone.set_dir(dir)
|
||||
if(angle)
|
||||
cone.transform = turn(cone.transform, angle)
|
||||
cone.apply_standard_transform()
|
||||
|
||||
///Sets a new direction for the directional cast, then updates luminosity
|
||||
/datum/component/overlay_lighting/proc/set_direction(newdir)
|
||||
/datum/component/overlay_lighting/proc/set_direction(newdir, skip_update)
|
||||
if(!newdir)
|
||||
return
|
||||
if(current_direction == newdir)
|
||||
return
|
||||
current_direction = newdir
|
||||
cone.set_dir(newdir)
|
||||
set_cone_direction(newdir)
|
||||
|
||||
if(newdir & NORTH)
|
||||
cone.pixel_y = 16
|
||||
@@ -476,8 +517,10 @@
|
||||
else
|
||||
if(!isnull(cone_hint_y))
|
||||
cone.pixel_y = cone_hint_y
|
||||
directional_atom.pixel_y = cone_hint_y
|
||||
else
|
||||
cone.pixel_y = 0
|
||||
directional_atom.pixel_y = 0
|
||||
|
||||
if(newdir & EAST)
|
||||
cone.pixel_x = 16
|
||||
@@ -487,12 +530,15 @@
|
||||
if(!isnull(cone_hint_x))
|
||||
if(newdir & NORTH)
|
||||
cone.pixel_x = -1*cone_hint_x
|
||||
directional_atom.pixel_x = -1*cone_hint_x
|
||||
else
|
||||
cone.pixel_x = cone_hint_x
|
||||
directional_atom.pixel_x = cone_hint_x
|
||||
else
|
||||
cone.pixel_x = 0
|
||||
directional_atom.pixel_x = 0
|
||||
|
||||
if(overlay_lighting_flags & LIGHTING_ON)
|
||||
if(!skip_update && (overlay_lighting_flags & LIGHTING_ON))
|
||||
make_luminosity_update()
|
||||
|
||||
/datum/component/overlay_lighting/proc/on_parent_crafted(datum/source, atom/movable/new_craft)
|
||||
|
||||
Reference in New Issue
Block a user