-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ports various implementations of particle effects from TGMC #2454
Open
ma44
wants to merge
6
commits into
Mojave-Sun:master
Choose a base branch
from
ma44:real-tgmc-particle
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c7f21b6
coolio particles
ma44 b2860aa
nice
ma44 282edc1
fix
ma44 d0fe51a
Move particle code out of vanilla /code
ma44 484424e
Merge remote-tracking branch 'upstream/master' into real-tgmc-particle
ma44 3628982
Merge remote-tracking branch 'upstream/master' into real-tgmc-particle
ma44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//generator types | ||
#define GEN_NUM "num" | ||
#define GEN_VECTOR "vector" | ||
#define GEN_BOX "box" | ||
#define GEN_COLOR "color" | ||
#define GEN_CIRCLE "circle" | ||
#define GEN_SPHERE "sphere" | ||
#define GEN_SQUARE "square" | ||
#define GEN_CUBE "cube" | ||
|
||
///particle editor var modifiers | ||
#define P_DATA_GENERATOR "generator" | ||
#define P_DATA_ICON_ADD "icon_add" | ||
#define P_DATA_ICON_REMOVE "icon_remove" | ||
#define P_DATA_ICON_WEIGHT "icon_edit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
///objects can only have one particle on them at a time, so we use these abstract effects to hold and display the effects. You know, so multiple particle effects can exist at once. | ||
///also because some objects do not display particles due to how their visuals are built | ||
/obj/effect/abstract/particle_holder | ||
anchored = TRUE | ||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT | ||
layer = ABOVE_ALL_MOB_LAYER | ||
vis_flags = VIS_INHERIT_PLANE | ||
///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/datum/weakref/weak_attached | ||
///besides the item we're also sometimes attached to other stuff! (items held emitting particles on a mob) | ||
var/datum/weakref/weak_additional | ||
|
||
/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 | ||
if(ismovable(loc)) | ||
RegisterSignal(loc, COMSIG_MOVABLE_MOVED, .proc/on_move) | ||
RegisterSignal(loc, COMSIG_PARENT_QDELETING, .proc/on_qdel) | ||
weak_attached = WEAKREF(loc) | ||
particles = new particle_path | ||
update_visual_contents(loc) | ||
|
||
/obj/effect/abstract/particle_holder/Destroy(force) | ||
var/atom/movable/attached = weak_attached.resolve() | ||
var/atom/movable/additional_attached | ||
if(weak_additional) | ||
additional_attached = weak_additional.resolve() | ||
if(attached) | ||
attached.vis_contents -= src | ||
UnregisterSignal(loc, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING)) | ||
if(additional_attached) | ||
additional_attached.vis_contents -= src | ||
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(attached.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(weak_additional) | ||
var/atom/movable/resolved_location = weak_additional.resolve() | ||
if(resolved_location) | ||
resolved_location.vis_contents -= src | ||
//add to 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 | ||
weak_additional = WEAKREF(particle_mob) | ||
particle_mob.vis_contents += src | ||
//readd to ourselves | ||
attached_to.vis_contents |= src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#define DEBRIS_SPARKS "spark" | ||
#define DEBRIS_WOOD "wood" | ||
#define DEBRIS_ROCK "rock" | ||
#define DEBRIS_GLASS "glass" | ||
#define DEBRIS_LEAF "leaf" | ||
#define DEBRIS_SNOW "snow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#define DEBRIS_SPARKS "spark" | ||
#define DEBRIS_WOOD "wood" | ||
#define DEBRIS_ROCK "rock" | ||
#define DEBRIS_GLASS "glass" | ||
#define DEBRIS_LEAF "leaf" | ||
#define DEBRIS_SNOW "snow" | ||
|
||
/particles/debris | ||
icon = 'mojave/icons/effects/particles/generic_particles.dmi' | ||
width = 500 | ||
height = 500 | ||
count = 10 | ||
spawning = 10 | ||
lifespan = 0.7 SECONDS | ||
fade = 0.4 SECONDS | ||
drift = generator(GEN_CIRCLE, 0, 7) | ||
scale = 0.7 | ||
velocity = list(50, 0) | ||
friction = generator(GEN_NUM, 0.1, 0.15) | ||
spin = generator(GEN_NUM, -20, 20) | ||
|
||
/particles/impact_smoke | ||
icon = 'icons/effects/effects.dmi' | ||
icon_state = "smoke" | ||
width = 500 | ||
height = 500 | ||
count = 20 | ||
spawning = 20 | ||
lifespan = 0.7 SECONDS | ||
fade = 8 SECONDS | ||
grow = 0.1 | ||
scale = 0.2 | ||
spin = generator(GEN_NUM, -20, 20) | ||
velocity = list(50, 0) | ||
friction = generator(GEN_NUM, 0.1, 0.5) | ||
|
||
/datum/element/debris | ||
element_flags = ELEMENT_BESPOKE | ||
id_arg_index = 2 | ||
|
||
///Icon state of debris when impacted by a projectile | ||
var/debris = null | ||
///Velocity of debris particles | ||
var/debris_velocity = -15 | ||
///Amount of debris particles | ||
var/debris_amount = 8 | ||
///Scale of particle debris | ||
var/debris_scale = 0.7 | ||
|
||
/datum/element/debris/Attach(datum/target, _debris_icon_state, _debris_velocity = -15, _debris_amount = 8, _debris_scale = 0.7) | ||
. = ..() | ||
debris = _debris_icon_state | ||
debris_velocity = _debris_velocity | ||
debris_amount = _debris_amount | ||
debris_scale = _debris_scale | ||
RegisterSignal(target, COMSIG_ATOM_BULLET_ACT, .proc/register_for_impact) | ||
|
||
/datum/element/debris/Detach(datum/source, force) | ||
. = ..() | ||
UnregisterSignal(source, COMSIG_ATOM_BULLET_ACT) | ||
|
||
/datum/element/debris/proc/register_for_impact(datum/source, obj/projectile/proj) | ||
SIGNAL_HANDLER | ||
INVOKE_ASYNC(src, .proc/on_impact, source, proj) | ||
|
||
/datum/element/debris/proc/on_impact(datum/source, obj/projectile/P) | ||
//if(!P.ammo.ping) | ||
// return | ||
var/angle = !isnull(P.Angle) ? P.Angle : round(get_angle(P.starting, source), 1) | ||
var/x_component = sin(angle) * debris_velocity | ||
var/y_component = cos(angle) * debris_velocity | ||
var/x_component_smoke = sin(angle) * -15 | ||
var/y_component_smoke = cos(angle) * -15 | ||
var/obj/effect/abstract/particle_holder/debris_visuals | ||
var/obj/effect/abstract/particle_holder/smoke_visuals | ||
var/position_offset = rand(-6,6) | ||
smoke_visuals = new(source, /particles/impact_smoke) | ||
smoke_visuals.particles.position = list(position_offset, position_offset) | ||
smoke_visuals.particles.velocity = list(x_component_smoke, y_component_smoke) | ||
if(debris) //&& !(P.ammo.flags_ammo_behavior & AMMO_ENERGY || P.ammo.flags_ammo_behavior & AMMO_XENO)) | ||
debris_visuals = new(source, /particles/debris) | ||
debris_visuals.particles.position = generator(GEN_CIRCLE, position_offset, position_offset) | ||
debris_visuals.particles.velocity = list(x_component, y_component) | ||
debris_visuals.layer = ABOVE_OBJ_LAYER + 0.02 | ||
debris_visuals.particles.icon_state = debris | ||
debris_visuals.particles.count = debris_amount | ||
debris_visuals.particles.spawning = debris_amount | ||
debris_visuals.particles.scale = debris_scale | ||
smoke_visuals.layer = ABOVE_OBJ_LAYER + 0.01 | ||
/* | ||
if(P.ammo.sound_bounce) | ||
var/pitch = 0 | ||
if(P.ammo.flags_ammo_behavior & AMMO_SOUND_PITCH) | ||
pitch = 55000 | ||
playsound(source, P.ammo.sound_bounce, 50, 1, frequency = pitch) | ||
*/ | ||
addtimer(CALLBACK(src, .proc/remove_ping, src, smoke_visuals, debris_visuals), 0.7 SECONDS) | ||
|
||
/datum/element/debris/proc/remove_ping(hit, obj/effect/abstract/particle_holder/smoke_visuals, obj/effect/abstract/particle_holder/debris_visuals) | ||
QDEL_NULL(smoke_visuals) | ||
if(debris_visuals) | ||
QDEL_NULL(debris_visuals) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway to reasonably clean this up?