Better Tree Transparency (#28377)

* Better Tree Transparency

* Circle and plusy

* Update flora.dm
This commit is contained in:
Kurfursten
2020-12-20 00:16:34 -06:00
committed by GitHub
parent ca6940cdd9
commit ef40ae25e4
3 changed files with 63 additions and 1 deletions

View File

@@ -176,6 +176,20 @@
// atom/item: the item
/lazy_event/on_unequipped
//Called when movable moves into a new turf
// Arguments:
// atom/movable/mover: thing that moved
// location: turf it entered
// oldloc: atom it exited
/lazy_event/on_entered
//Called when movable moves from a turf
// Arguments:
// atom/movable/mover: thing that moved
// location: turf it exited
// newloc: atom it is entering
/lazy_event/on_exited
/datum
/// Associative list of type path -> list(),

View File

@@ -84,6 +84,7 @@
var/const/randomize_on_creation = 1
var/const/log_type = /obj/item/weapon/grown/log/tree
var/holo = FALSE
var/image/transparent
/obj/structure/flora/tree/New()
..()
@@ -110,6 +111,44 @@
layer += rangevalue * (1 - (y + 0.5 * (x & 1)) / world.maxy)
update_transparency()
for(var/turf/T in circlerange(src,2))
if(T.y > y)
T.lazy_register_event(/lazy_event/on_entered, src, .proc/give_transparency)
T.lazy_register_event(/lazy_event/on_exited, src, .proc/remove_transparency)
/obj/structure/flora/tree/Destroy()
for(var/turf/T in circlerange(src,2))
if(T.y > y)
T.lazy_unregister_event(/lazy_event/on_entered, src, .proc/give_transparency)
T.lazy_unregister_event(/lazy_event/on_exited, src, .proc/remove_transparency)
..()
/obj/structure/flora/tree/proc/update_transparency()
transparent = image(icon,src,icon_state)
transparent.color = "[color ? color : "#FFFFFF"]"+"7F"
transparent.override = TRUE
/obj/structure/flora/tree/proc/give_transparency(mover, location, oldloc)
if(!ismob(mover))
return
var/mob/M = mover
if(!M.client)
return
var/client/C = M.client
C.images += transparent
/obj/structure/flora/tree/proc/remove_transparency(mover, location, newloc)
if(!ismob(mover))
return
var/mob/M = mover
if(!M.client)
return
var/client/C = M.client
C.images -= transparent
/obj/structure/flora/tree/examine(mob/user)
.=..()
@@ -191,6 +230,7 @@
/obj/structure/flora/tree/pine/New()
..()
icon_state = "pine_[rand(1, 3)]"
update_transparency()
/obj/structure/flora/tree/pine/xmas
name = "xmas tree"
@@ -203,6 +243,8 @@
/obj/structure/flora/tree/pine/xmas/New()
..()
icon_state = "pine_c"
update_transparency()
/obj/structure/flora/tree/dead
name = "dead tree"
@@ -215,6 +257,7 @@
/obj/structure/flora/tree/dead/New()
..()
icon_state = "tree_[rand(1, 6)]"
update_transparency()
/obj/structure/flora/tree_stump
name = "tree stump"

View File

@@ -120,6 +120,10 @@
return 0
return 1
/turf/Exited(atom/movable/mover, atom/newloc)
..()
lazy_invoke_event(/lazy_event/on_exited, list("mover" = mover, "location" = src, "newloc" = newloc))
/turf/Enter(atom/movable/mover as mob|obj, atom/forget as mob|obj|turf|area)
if (!mover)
return 1
@@ -155,7 +159,7 @@
return 1 //Nothing found to block so return success!
/turf/Entered(atom/movable/A as mob|obj)
/turf/Entered(atom/movable/A as mob|obj, atom/OldLoc)
if(movement_disabled)
to_chat(usr, "<span class='warning'>Movement is admin-disabled.</span>")//This is to identify lag problems
return
@@ -168,6 +172,7 @@
A.inertia_dir = 0
..()
lazy_invoke_event(/lazy_event/on_entered, list("mover" = A, "location" = src, "oldloc" = OldLoc))
var/objects = 0
if(A && A.flags & PROXMOVE)
for(var/atom/Obj in range(1, src))