Ludeon Forums

RimWorld => Mods => Tools => Topic started by: CannibarRechter on October 02, 2017, 06:59:57 AM

Title: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 02, 2017, 06:59:57 AM
Hi,

I am releasing a new graphics tool called CompFX. It allows modders, using XML only, to attach a "comp" to any ThingWithComps in order to achieve an overlay effect (including animated overlays). It supports a very wide variety of overlays. It also supports UNDERLAYS. Proper use of the comp usually involves a patch, like this:

Code: [Select]
<Operation Class="PatchOperationAdd">
<xpath>*/ThingDef[defName = "FueledStove"]/comps</xpath>
<value>
<li Class="CR.CompProperties_FXOverlay">
<fxType>FX_Flash</fxType> <!-- optional, defaults to FX_Flash -->
<fxPath>FX/RedLight</fxPath> <!-- REQUIRED -->
<fxSize>1</fxSize> <!-- optional, defaults to 1 -->
<fxAbove>true</fxAbove>             <!-- optional, defaults to true -->
<fxTicks>10</fxTicks> <!-- optional, defaults to 60 -->
<fxAmount>5</fxAmount> <!-- required for some FX, see individual FX descr -->
<fxOption1>30</fxOption1> <!-- required for some FX, see individual FX descr -->
<fxOption2>0.2</fxOption2> <!-- required for some FX, see individual FX descr -->
<fxDependency>Fueled</fxDependency> <!-- optional, defaults to None -->
<fxOffset>(0,0,0.1)</fxOffset> <!-- optional, defaults to (0,0,0) -->
</li>
</value>
</Operation>

Documentation is included in the Examples/Example.xml directory. However, the basic gist of it is that CompFX supports the following FX types:

Code: [Select]
fxType (enum, default FX_Overlay):

FX_Overlay, // the effect is just to overlay the thing, that is all
FX_Flash,      // the effect is to appear and dissapear @fxTicks interval
FX_Animate,      // the effect is to overlay images in sequence @fxTicks interval
FX_Flicker, // the effect is random frames @fxTicks interval
FX_Spin,     // the effect is to spin around the middle; spin fxAmount (degrees) @fxTicks rate
FX_SpinJitter, // the effect is to periodically spin in a random direction and portion of @fxAmount (degrees) @fxTicks rate
FX_Pulse, // the effect is to grow and shrink by fxAmount @fxTicks rate
FX_Pop, // the effect is to grow--by fxAmount @fxTicks rate--and then start over
FX_Fade, // the effect is to fade in and out of transparency
FX_Mote         // the effect is animates versions of the frame into the air, like smoke

This is a tool for modders who want to graphically touch up rimworld. This mod makes use of one Harmony call in order to check to see if a work location has been worked at. This helps the tool able to satisfies the "Worked" dependency type. For example, you might have a stove smoke extra if it's been worked at. Currently supported dependencies are Powered, Fueled, Worked, and None.

For additional info see the Examples.xml file.

The download is found by following the link in my sig.

Version 1.1 Release Notes:

-Addressed significant performance defect with FX_Mote
-Added triggered (event based) FX

Version 1.2 Release Notes:

--Addressed an off-by-1 error that prevented the Worked signal from processing until after work stopped
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 02, 2017, 08:16:10 PM
You're a genius of coding, I've tried to create some effects and everything works perfectly.
But I can not create an effect, FX_Fade seems the most suitable for that, but I would that the effect will be repeated only once, starting from the transparency and reached the maximum opacity it should disappear without the transition effect.
Other thing, but maybe I ask for the impossible, I would like to tie the effect to a certain event, for example refueling a machine, or creating an object with that machine, in short a sort of switch. It's possible with your tool?
Thanks
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 02, 2017, 08:32:26 PM
The entire system is predicate on an ongoing effect of some sort, not just display it once. That said, it wouldn't really be a big change to allow the FX to be triggered. Thing is, I don't know how to get a hold of game events, and get them to comps.

Looking at ThingWithComps right now, I see it has a BroadcastCompSignal and ReceiveCompSignal methods. I think comps can be programmed to communicate with other comps that way.

As for your FX type (fade in, but not out), that's easily programmed. It's exactly analagous to the logic difference between Pulse (grow and shrink) and Pop (grow and start over).

The Refuelable already broadcasts a signal, and so does Powered. That means all I have to do is implement the Receive, and I'll get it. I need to go read all the other comps now.

Here are all signals broadcast by Rimworld:

Code: [Select]

RimWorld\CompBreakdownable.cs:77:            this.parent.BroadcastCompSignal("Breakdown");
RimWorld\CompFlickable.cs:61:                    this.parent.BroadcastCompSignal("FlickedOn");
RimWorld\CompFlickable.cs:65:                    this.parent.BroadcastCompSignal("FlickedOff");
RimWorld\CompPowerTrader.cs:85:                    this.parent.BroadcastCompSignal("PowerTurnedOn");
RimWorld\CompPowerTrader.cs:100:                    this.parent.BroadcastCompSignal("PowerTurnedOff");
RimWorld\CompRefuelable.cs:225:                this.parent.BroadcastCompSignal("RanOutOfFuel");
RimWorld\CompRefuelable.cs:242:            this.parent.BroadcastCompSignal("Refueled");
RimWorld\CompRefuelable.cs:284:                        this.<>f__this.parent.BroadcastCompSignal("Refueled");
RimWorld\CompRefuelable.cs:293:                        this.<>f__this.parent.BroadcastCompSignal("Refueled");
RimWorld\CompSchedule.cs:35:                this.parent.BroadcastCompSignal((!this.intAllowed) ? "ScheduledOff" : "ScheduledOn");
RimWorld\CompTemperatureRuinable.cs:65:                    this.parent.BroadcastCompSignal("RuinedByTemperature");
Verse\ThingWithComps.cs:120:        public void BroadcastCompSignal(string signal)
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 03, 2017, 08:25:40 AM
Hi, I looked over this all last night before going to bed. This should be really easy to implement, and I will get an updated version of it out soon. It was actually helpful to look at, because it will make my "Worked" dependency easier to manage.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 03, 2017, 09:36:11 AM
Great!! I love your tool, this is what I did today, a custom fire animation for my pyre (PS the refuel icon is horrible)
(https://i.imgur.com/sgE0W1y.png)

A question, the textures for the glow effects are still unmoddable or I doing something wrong? The only one thath I tested that shows a new texture is the glow of the fires
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 03, 2017, 10:17:27 AM
Check Moddable for the ability to change out the Refuel icon. All you have to do is install Moddable, go to the XML and enable the ModdableUI def. After that, just place the texture you want in $MOD/Textures/UI/Overlays/OutOfFuel.

In any case, all FX should be working, so if you think something's not, post the CompFX XML you used, and tell me how you did it.

BTW, some building types don't draw in real time (they 'paint' instead). To check this, go to the Building or its Base, and see if the drawerType is "MapMeshOnly". For CompFX to render those, I believe you have to change it to something like "MapMeshAndRealtime," but you should verify the spelling on that before trying it.

Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 03, 2017, 08:37:40 PM
Okay. I have a rudimentary test version up and am debugging it. It currently supports any signal type the game delivers (or any signal type a future modder creates: signals are plain text). The format is as follows:

Code: [Select]
  <li Class="CR.CompProperties_FXOverlayTriggered">
<fxType>FX_Fade</fxType>
<fxPath>FX/BlastFlame</fxPath>
<fxSize>3</fxSize>
<fxTicks>300</fxTicks>
<fxAmount>1</fxAmount>
<fxOption1>-1</fxOption1>
<fxTriggerDurationTicks>300</fxTriggerDurationTicks>
<fxTriggerDelayTicks>300</fxTriggerDelayTicks>
<fxTriggerSignal>FlickedOn</fxTriggerSignal>
  </li>

You'll see this new def is an extension of the old, with 3 additional attributes.

triggerDuration: how long the signal makes the effect trigger
triggerDelay: how long after the signal the effect should start
signalName: the name of the signal

On a related note, I implemented some new fade types tonite: fade-in and fade-out. They are implemented as options to the FX_FadeEffect, which by default uses a sin curve of simulation ticks.

I have a bug or two so far, so I have to work on that, but you'll have something to play with soon. Any modder who is making a custom comp, all they have to is call their parent Thing with parent.BroadcastCompSignal( "somesignalname" ) and with that, you can trigger any effect of the new signal. Literally 1 line of code.

Pretty neat; surprised signals aren't used more than they are.

In other news, it's pretty funny watching big fireballs blow off anytime a pawn turns on a light switch. LOL.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 04, 2017, 08:02:15 AM
Great!! This opens at an infinity of possible effects and combinations, I already have many interesting ideas, shame I don't have enough time.
About the glow effect, I can't find it in your tool, it should be a simply effect, an image  that overlaps everything without any animated effect, with the option to choose its rgbA value.
A curiosity, there is a limit on the number of frames for the animations?
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 04, 2017, 09:57:03 AM
I see what you mean about glow. That would be a bit tricky to implement, as I assume you mean the glow would follow the shape of the object, which would therefore require detailed calculations for procedural effect. Not sure if I wanna do that.

You can actually create this effect right now. Grab your original art, load it up into Gimp or Photoshop, create your glow, and then put it on your Thing as an FX_Overlay. You might want to set fxAbove to false, depending on how you want the glow to work.

Regarding animations, the answer is 'no,' caveat the amount of memory they consume of course.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 04, 2017, 10:42:46 AM
Quote
I assume you mean the glow would follow the shape of the object

No no... I know this would be hard to do, and useless since is very easy make custom glow texture

Quote
You can actually create this effect right now. Grab your original art, load it up into Gimp or Photoshop, create your glow, and then put it on your Thing as an FX_Overlay. You might want to set fxAbove to false, depending on how you want the glow to work.

I thought that FXOverlay was only for call an effect... not an effect itself... , I have to read your descriptions more carefully  :P
so:

Code: [Select]
<li Class="CR.CompProperties_FXOverlay">
<fxType>FX_Overlay</fxType>
<fxPath>FX/Glowone</fxPath>
<fxSize>1</fxSize>
<fxAbove>false</fxAbove>
                                <fxDependency>Fueled</fxDependency>
<fxOffset>(0,0,0)</fxOffset>
   

Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 04, 2017, 03:10:03 PM
Yeah, FX_Overlay is a basic static effect. Just display the pixels, and no more. Obviously you can put them over or under the Thing. Note also that the effects are rendered with a shaderType=Transparent, so alpha effects should work just fine.

p.s. FX_Overlay is the effect I started with. ;-P
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 07, 2017, 08:21:42 AM
Updated to 1.1:

-Fixed a performance defect from FX_Mote
-Added triggered FX
-Updated documentation to explain the new triggers
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 10, 2017, 08:43:45 AM
Hi, I can't get the signal "Worked" to works in a Building_WorkTable with an "animate" overlay,  log always return an error about the "fxSignal" something like "fxsignal is expected Line" (always indicate a position after </li>)
I have tried different solutions but nothing..

for example I have this working effect with a fueled dependency, as I said before I want to replace the fueled dependency with a worked signal, how to convert it properly? Also, maybe the WorkedAt dependency was perfect? I have never tried it but I've read in yours description that you have disabled this dependency, and it seems to me perfect for an effect that must be activated (and last) only when a colonist works in that building

Code: [Select]
  <li Class="CR.CompProperties_FXOverlay">
<fxType>FX_Animate</fxType>
<fxPath>FX/SatanFire</fxPath>
<fxSize>7</fxSize>
<fxTicks>8</fxTicks>
<fxDependency>Fueled</fxDependency>
<fxOffset>(0.0,0,-0.005)</fxOffset>
  </li>

Thanks     ;)
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 10, 2017, 09:39:23 AM
Look in the examples. The overlay Class= type is slightly different. The base class can't accept fxSignal, but the modified class can. BTW, I'm working a bug this weekend which makes the worked signal display a bit late.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 10, 2017, 09:55:39 AM
Well, as I said I tried different solutions but nothing
The new class overlay is CR.CompProperties_FXOverlayTriggered ? I tried even that
there must be some stupid mistake on my part
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 10, 2017, 10:44:37 AM
Post your xml when you used the triggered prop

Edit: note that the bug in "Worked" is it doesn't show the FX until the work is done. So if you got the tag to express, then perhaps it was working (working, but not doing the right thing) and you missed it.

I believe this may be a bug in my own code, and have a theory which I'll explore when I get the chance. If it's not my code, and it's an issue with the underlying NotifyUsed() function in the core, then fixing it may be quite a bit harder.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 10, 2017, 12:40:42 PM
Later I will try to do some tests, maybe even with different triggers and effects

P.s. in CompProperties_Refuelable there is <consumeFuelOnlyWhenUsed> a dependency like that will be perfect
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 10, 2017, 07:04:44 PM
Hi, I fixed the bug and upped the version. The bug was merely a problem with checking > instead of >=. Since the Worked event was being updated continuously while work was being performed, the current ticks and last ticks were always the same until worked stopped. Now I checked to see if they are >=, and then it works.

Here's my comp for the ElectricStove:

Code: [Select]
<li Class="CR.CompProperties_FXOverlayTriggered">
<fxType>FX_Overlay</fxType>
<fxPath>FX/HotStove</fxPath>
<fxSize>(3.5,1.5)</fxSize>
<fxTriggerDurationTicks>300</fxTriggerDurationTicks>
<fxSignalName>Worked</fxSignalName>
</li>

Note that FX/HotStove is not something disseminated with the FX package. It's for my (ongoing) texture mod. You can just change it out with FX/BlastFlame if you really want to see it happen, to prove it is working. Can't miss a big giant fireball ;-P
Title: Re: [A17] CompFX (Tool for Modders)
Post by: swefan on October 11, 2017, 03:52:42 AM
Yeah this works, and works even my comp just changed a line...
wasn't my fault  ::) I wrote as you wrote in the documentation provided with the tool:
Code: [Select]
<fxSignal>Worked<fxSignal> or, realized that the error was in this line
<fxSignal>Worked</fxSignal>
instead of
<fxSignalName>Worked</fxSignalName>

Anyway, the timing is perfect, good work!!





Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on October 11, 2017, 07:12:56 AM
Ah, oops. I was wondering if something like that may have happened. In the documentation, I just type it out. I'll go fix so noone else gets burned by that.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: tobe on October 31, 2017, 11:31:47 PM
Can I use it pawns? or only building can use it?
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on November 01, 2017, 06:16:14 AM
It should work on anything that can take a comp; the only pawns I've tried it on are Misc Robots. You can find me using them in my graphics overhaul mod. The hauler has a flashing red indicator light, and the cleaner has both a blue indicator, and a soft blue glow underneath the cleaner (and 'below' render).
Title: Re: [A17] CompFX (Tool for Modders)
Post by: kaptain_kavern on November 01, 2017, 02:12:38 PM
Thanks for releasing this. I really need to have a look on how it works later with some more time.

Anyhow, thanks a lot
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on November 02, 2017, 10:20:10 AM
It should be pretty easy. See Examples.xml.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: Harry_Dicks on January 28, 2018, 08:47:32 PM
I really need to figure this stuff out. I'm ready to add flames and glows to everything!
Title: Re: [A17] CompFX (Tool for Modders)
Post by: diannetea on March 14, 2018, 05:57:15 AM
Does this support changing the drawSize of the fx?  I ask only because I'm trying to put something under a stove, and due to the drawSize of the stove being larger it's hard to place the item properly underneath it.  I assume if the drawSize was the same for both of them it'd fit perfectly.

I also realize I can change the offset to position it, however this is very finicky and takes a lot of loading and unloading of RimWorld just to check if that .1 moved it to where it needs to be.  I've also sized it with the actual image of the stove, but due to the drawSize change the fx is smaller in game than it is supposed to be.


nevermind I found it >.>

Next problem:

Does this have any way to support sides?  So _front, _back, and _side FX for a thing?
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on March 14, 2018, 07:47:30 AM
It should work with Multis, yes. Down in the test graphics, you'll find some test overlays to help you with that. It supports the standard rotations within the game.

I believe the setting you want is "rotWithThing" (although I did not look this is up right now, but that's what I remember). This will make your effect move around when the thing rotates.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: diannetea on March 14, 2018, 08:37:10 AM
I checked and fxRotWithThing (looked in code) isn't actually in the Examples.xml provided.  It doesn't do what I'm looking for, however, I already have 3 graphics set up with proper naming, but it's only using the _back suffixed image.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on March 14, 2018, 09:06:14 AM
You are looking for FX that are themselves multis? I never implemented that. I can see why you would want to (for example, if you want to change the position of the graphic without rotating it), but alas there is no such functionality at the moment. Maybe I'll look into that this weekend. It wouldn't be that hard, I think.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: diannetea on March 14, 2018, 09:51:40 AM
Thanks, that would be great! :3
Title: Re: [A17] CompFX (Tool for Modders)
Post by: larSyn on March 19, 2018, 01:53:25 PM
Probably a stupid question...but, does this require us to have the whole mod installed or just have the .dll's in the assemblies folder?  Having a bit of trouble getting started with this tool.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: CannibarRechter on March 19, 2018, 02:31:40 PM
You download the mod into your Mods folder, and then activate the Mod in the UI.
Title: Re: [A17] CompFX (Tool for Modders)
Post by: larSyn on March 19, 2018, 02:46:02 PM
OK Thank you!  :)
Title: Re: [A17] CompFX (Tool for Modders)
Post by: diannetea on March 24, 2018, 09:00:20 AM
Did you have a chance to look into rotations?  :3


I was thinking of maybe doing an overlay for manhunter animals with red eyes, is that possible as well?  Thanks!