How do animated buildings work? (-Trebuchet-)

Started by Grizzlyadamz, February 15, 2015, 07:00:45 PM

Previous topic - Next topic

Grizzlyadamz

I'd like to make a trebuchet with a firing animation.

Where would I look to dissect how a wind turbine works, and what software would I need?

skullywag

Ilspy and look at the rimworld dll files in the managed folder. Then look up building_windturbine or whatever it is called.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Haplo


Grizzlyadamz

Gotcha, thank you both.
I'll be back to ask questions once I've found the time to look at them!  :)

Orion

I have tried the solution from the .dll tutorial, and noticed it causes problems with the rest of the game (chopped off sounds / overspawning of particles, etc.) It also seems like the latest version of RimWorld is doing it differently: it just animates the blades of the turbine, instead of the whole graphic.
Did any of you guys figure out a good way to still have animation without negative effects? I've been plowing through the source code for hours now looking for a good example, but didn't have any luck yet.

Orion

Okay, I figured it out. The key was to prevent the original drawing mechanism and handling drawing myself:


        private Graphic nullGraphic;
        private Matrix4x4 drawMatrix = default(Matrix4x4);

        public override void SpawnSetup()
        {
            base.SpawnSetup();
            ...
            // Couldn't find a better way yet to just get an empty graphic
            nullGraphic = GraphicDatabase.Get<Graphic_Single>(def.graphicPath, def.shader, def.DrawSize, Color.clear);
            drawMatrix.SetTRS(DrawPos + Altitudes.AltIncVect, Gen.ToQuat(90), Vector3.one);
        }

        public override void Draw()
        {
            // Draw animation
            Graphics.DrawMesh(MeshPool.plane30, drawMatrix, animationFrameMaterial, 0);

            // Draw effects and such
            Comps_PostDraw();
        }

        // Prevent the original drawing mechanism
        public override Graphic Graphic { get { return nullGraphic; } }


Of course this all would have been super easy, if Graphic.DrawWorker was not internal and we could create our own implementations of Graphic :)

KnucklyDuck

Quote from: Orion on March 07, 2015, 11:45:42 AM
Of course this all would have been super easy, if Graphic.DrawWorker was not internal and we could create our own implementations of Graphic :)

I PMed Tynan about that.
Why do Java programmers have glasses?
.
.
Because they can't C#.

Tynan

It's a mistake on my part; I've made it public now.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Orion


mrofa

Grizzlyadamz you can check a8 version of clutter deployable turrets on a8 version of game, didnt have time to update it.
They use 22 frames for animation.
Either you can check the compression mod workbenches change from unpacking/packing animations, thrugh they are to a8 ;p
Need a time dispenser :D
Anyways this is not hard and game handels it preety good :)
All i do is clutter all around.