Adds bullet impact particle effects! (#25177)

* Initial commit

* Cleaning up + more debris

* Adds missing trailing newline

* CI doesn't like these and starts an infinite loop it seems

* Hacky solution? I call it fixing CI

* Final fixes
This commit is contained in:
DGamerL
2024-05-06 21:44:14 +02:00
committed by GitHub
parent a750e3596e
commit b04bdf4ff9
14 changed files with 187 additions and 3 deletions
+62
View File
@@ -148,3 +148,65 @@
/obj/effect/decal/proc/on_scoop()
return
/// These effects can be added to anything to hold particles, which is useful because Byond only allows a single particle per atom
/obj/effect/abstract/particle_holder
anchored = TRUE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
layer = ABOVE_ALL_MOB_LAYER
vis_flags = VIS_INHERIT_PLANE
invisibility = FALSE
///typepath of the last location we're in, if it's different when moved then we need to update vis contents
var/last_attached_location_type
/// The main item we're attached to at the moment, particle holders hold particles for something
var/atom/parent
/// The mob that is holding our item
var/mob/holding_parent
/obj/effect/abstract/particle_holder/Initialize(mapload, particle_path = null)
. = ..()
if(!loc)
stack_trace("particle holder was created with no loc!")
return INITIALIZE_HINT_QDEL
parent = loc
if(ismovable(parent))
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
RegisterSignal(parent, COMSIG_PARENT_QDELETING, PROC_REF(on_qdel))
particles = new particle_path
update_visual_contents(parent)
/obj/effect/abstract/particle_holder/Destroy(force)
if(parent)
UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING))
QDEL_NULL(particles)
return ..()
///signal called when parent is moved
/obj/effect/abstract/particle_holder/proc/on_move(atom/movable/attached, atom/oldloc, direction)
SIGNAL_HANDLER
if(parent.loc.type != last_attached_location_type)
update_visual_contents(attached)
///signal called when parent is deleted
/obj/effect/abstract/particle_holder/proc/on_qdel(atom/movable/attached, force)
SIGNAL_HANDLER
qdel(src)//our parent is gone and we need to be as well
///logic proc for particle holders, aka where they move.
///subtypes of particle holders can override this for particles that should always be turf level or do special things when repositioning.
///this base subtype has some logic for items, as the loc of items becomes mobs very often hiding the particles
/obj/effect/abstract/particle_holder/proc/update_visual_contents(atom/movable/attached_to)
// Remove old
if(holding_parent && !(QDELETED(holding_parent)))
holding_parent.vis_contents -= src
// Add new
if(isitem(attached_to) && ismob(attached_to.loc)) //special case we want to also be emitting from the mob
var/mob/particle_mob = attached_to.loc
last_attached_location_type = attached_to.loc
particle_mob.vis_contents += src
// Readd to ourselves
attached_to.vis_contents |= src