moisesjpelaez - Physics Private Fields

This commit is contained in:
2025-06-01 22:57:47 +00:00
parent 1a17b646e4
commit 32cdbd8c54

View File

@ -1,64 +1,64 @@
package leenkx.logicnode; package leenkx.logicnode;
import iron.object.Object; import iron.object.Object;
class RemoveParticleFromObjectNode extends LogicNode { class RemoveParticleFromObjectNode extends LogicNode {
public var property0: String; public var property0: String;
public function new(tree: LogicTree) { public function new(tree: LogicTree) {
super(tree); super(tree);
} }
override function run(from: Int) { override function run(from: Int) {
#if lnx_particles #if lnx_particles
var object: Object = inputs[1].get(); var object: Object = inputs[1].get();
if (object == null) return; if (object == null) return;
var mo = cast(object, iron.object.MeshObject); var mo = cast(object, iron.object.MeshObject);
if (mo.particleSystems == null) return; if (mo.particleSystems == null) return;
if (property0 == 'All'){ if (property0 == 'All'){
mo.particleSystems = null; mo.particleSystems = null;
for (c in mo.particleChildren) c.remove(); for (c in mo.particleChildren) c.remove();
mo.particleChildren = null; mo.particleChildren = null;
mo.particleOwner = null; mo.particleOwner = null;
mo.render_emitter = true; mo.render_emitter = true;
} }
else { else {
var slot: Int = -1; var slot: Int = -1;
if (property0 == 'Name'){ if (property0 == 'Name'){
var name: String = inputs[2].get(); var name: String = inputs[2].get();
for (i => psys in mo.particleSystems){ for (i => psys in mo.particleSystems){
if (psys.r.name == name){ slot = i; break; } if (@:privateAccess psys.r.name == name){ slot = i; break; }
} }
} }
else slot = inputs[2].get(); else slot = inputs[2].get();
if (mo.particleSystems.length > slot){ if (mo.particleSystems.length > slot){
for (i in slot+1...mo.particleSystems.length){ for (i in slot+1...mo.particleSystems.length){
var mi = cast(mo.particleChildren[i], iron.object.MeshObject); var mi = cast(mo.particleChildren[i], iron.object.MeshObject);
mi.particleIndex = mi.particleIndex - 1; mi.particleIndex = mi.particleIndex - 1;
} }
mo.particleSystems.splice(slot, 1); mo.particleSystems.splice(slot, 1);
mo.particleChildren[slot].remove(); mo.particleChildren[slot].remove();
mo.particleChildren.splice(slot, 1); mo.particleChildren.splice(slot, 1);
} }
if (slot == 0){ if (slot == 0){
mo.particleSystems = null; mo.particleSystems = null;
mo.particleChildren = null; mo.particleChildren = null;
mo.particleOwner = null; mo.particleOwner = null;
mo.render_emitter = true; mo.render_emitter = true;
} }
} }
#end #end
runOutput(0); runOutput(0);
} }
} }