Particle Manager Mod [Utility]

Sozin

Dog Emperor
Jul 9, 2016
642
1,257
505
A tool meant for use by custom block modders to enhance their blocks with more advanced particle effects.

Install this with TTMM. For use with the Block Injector Library.

For Modders:
  • See usage details/instructions provided in both the following post, and/or the mod github repo
  • There's a set of some sample blocks using this mod attached to this post.
  • ^ WARNING: you must take care to change said block IDs, or they will overwrite their originals (they're all modified versions of extant blocks, either by me, or other modders, as credited in the files themselves)
  • For more details on how to manipulate particle effects in general, see: my guide to ParticleSystems (current unwritten)

Sample effects produced in conjunction with this mod:

Charged halo which appears only when tech block is attached to is anchored
(and halo appears only when attached)



Weapon Charging effects! (Warning: will delay first shot appropriately. AI will be inconvenienced if their target moves out of aim too much)


Weapon Charge Effects that work even when AI-controlled


Burst-Fire charge handling


For a look at the code itself, visit the Github Repository.
 

Attachments

Last edited:

Sozin

Dog Emperor
Jul 9, 2016
642
1,257
505
Modder Usage Instructions:

Add "ParticleManager.ModuleParticleManager" under root layer (deserializer)
sample usage: (in JSON block file)


JSON:
"Deserializer": {
  "ParticleManager.ModuleParticleManager": {
    "Input": [
      {
        "m_system": "/_spindle/m_BF_Radar_111_Sensor/FX_HE_PlasmaTeeth_Beam/ParticleSystem.",
        "value": 0.0,
        "CannonBarrel": null,
        "type": "Attach"
      },
      {
        "m_system": "/FX_HE_PlasmaTeeth_Beam_copy/ParticleSystem.",
        "value": 0.0,
        "CannonBarrel": null,
        "type": "WeaponFiring"
      }
    ],
    "Debug": true
  }
}
ModuleParticleManager has many fields which are initially empty. Pretty much all of these fields (which have been set public for Unity convenience reasons), should not be touched, because they, at best, provide no utility, and at worst, interfere with vital functions.

There are only two fields that you should be modifying in JSON files:
  • Input
  • Debug
Debug will enable debug printing in TT's output log when set to true (false by default).
Input is where configuration of the system is done.


Input consists of an array of ParticleSystemMetadata objects
C#:
[Serializable()]
public class ParticleSystemMetadata
{
    public ParticleSystem m_system;
    public float value;
    public CannonBarrel CannonBarrel;
    public MetadataType type;

    public ParticleSystemMetadata()
    {
        this.m_system = null;
        this.value = 0.0f;
        this.CannonBarrel = null;
        this.type = MetadataType.None;
    }
}
Each ParticleSystemMetadata object has 4 fields: m_system, value, CannonBarrel, type

The only 2 mandatory fields are m_system, and type

m_system should be passed a reference of the target ParticleSystem that you want controlled

type should be passed a MetadataType enum, either in int, or string form. It determines how the ParticleManager will handle the provided system. Additional parameters may be necessary depending on the type requested.
C#:
[Serializable()]
public enum MetadataType
{
    Attach = 0,
    Anchor = 1,
    WeaponCharge = 2,
    BarrelCharge = 3,
    WeaponFiring = 4,
    None = 6
}
Attach
Attach plays the particle system when the block is attached to a tech, and doesn't otherwise.
JSON:
{
  "m_system": "/_gimbalBase/_gimbalElev/fx_Lightning/ParticleSystem.",
  "type": "Attach"
}
Anchor
Anchor plays the particle system when the block is on a tech that's anchored, and doesn't otherwise.
JSON:
{
  "m_system": "/_gimbalBase/_gimbalElev/fx_Lightning/ParticleSystem.",
  "type": "Anchor"
}
WeaponFiring
WeaponFiring will play a particle system as long as that weapon is actively firing at something.
JSON:
{
  "m_system": "/_gimbalBase/_gimbalElev/fx_Lightning/ParticleSystem.",
  "type": "WeaponFiring"
}
Note: WeaponFiring effects will play the entire duration the weapon is ordered to fire, including charge times.

WeaponCharge
WeaponCharge will play a particle system from the moment a weapon tries to fire, till the time it fires its first shot. If the provided time for how long the particle system will play is longer than the time normally spent before the first shot is fire (i.e. spinner spinup), the ParticleManager will artificially inflate the time until the first shot is fired. (spinup times are unaffected) Nota Bene: all particle systems will stop playing when the parent block is removed from the tech
JSON:
{
  "m_system": "/_gimbalBase/_gimbalElev/fx_Lightning/ParticleSystem.",
  "value": 5.0,
  "type": "WeaponCharge"    // test
}

Nota Bene: all particle systems will stop playing when the parent block is removed from the tech
 
Last edited:

Sozin

Dog Emperor
Jul 9, 2016
642
1,257
505
Modder Usage Instructions (cont.)
BarrelCharge
BarrelCharge will play a particle system for the requested time value provided, right before the barrel it's attached to fires. It will delay the first shot from firing until the first barrel has been charged
JSON:
{
  "m_system": "/_gimbalBase/_gimbalElev/FX_HE_PlasmaTeeth_Beam/ParticleSystem.",
  "value": 1.5,
  "CannonBarrel": "/_gimbalBase/_gimbalElev/_barrel_L/CannonBarrel.",
  "type": "BarrelCharge"
}
Important things to note about BarrelCharge:
  • unlike WeaponCharge, it requires a CannonBarrel reference. If one is not provided, it will automatically assign it to barrel #0, whichever barrel that happens to be
  • like Weaponcharge, "value" indicates exactly how long you want the designated ParticleSystem to play before the barrel will fire
  • you are fully able to give a value that's arbitarily large, but the manager *will* forcibly truncate it to at max the cycle time (the time before said barrel will fire again)
  • ^ Note how it truncates to cycle time, not shot reload. that's because if multiple barrel charge animations need to be playing at the same time, the manager will handle it, and play then as appropriate
  • So far, I've only tested with ParticleSystems set on loop=true. I assume it works with one-off systems, but haven't explicitly tested them yet
  • *DO NOT SET ParticleSystem.main.prewarm = true*, or the particles will not display (if loop=true)
 
Last edited: