[MOD] (Alpha 9) OmniCorp - Area effect vanilla style shields-plus armour shield

Started by skullywag, January 28, 2015, 04:42:28 PM

Previous topic - Next topic

daveboy2000

Quote from: skullywag on March 02, 2015, 02:36:42 PM
Updated OmniShield to have a spinning top piece that spins with the shield. Instead of a static graphic.
Quick modding question: How'd you achieve that?

skullywag

It uses the turret class which contains a draw turret method but the code to handle the spinning is simple enough, i ended up actually making it match the personal shield way of spinning simple for ease (the vanilla bubble "spins")


private static readonly Material ShieldRotator = MaterialPool.MatFrom("Things/Building/Security/OmniShield_top", ShaderDatabase.Transparent);
public void DrawTurret()
        {
            if (this.powerComp.PowerOn)
            {;
                float angle = (float)Rand.Range(0, 360);
                Vector3 s = new Vector3(1f, 1f, 1f);
                s.y = Altitudes.AltitudeFor(AltitudeLayer.VisEffects);
                Matrix4x4 matrix = default(Matrix4x4);
                matrix.SetTRS(this.DrawPos + Altitudes.AltIncVect, Quaternion.AngleAxis(angle, Vector3.up), s);
                Graphics.DrawMesh(MeshPool.plane10, matrix, Building_OmniShield.ShieldRotator, 0);
            }
            else
            {
                Matrix4x4 matrix = default(Matrix4x4);
                Vector3 s = new Vector3(1f, 1f, 1f);
                s.y = Altitudes.AltitudeFor(AltitudeLayer.MoteLow);
                matrix.SetTRS(this.DrawPos + Altitudes.AltIncVect + Altitudes.AltIncVect, Rotation.AsQuat, Vector3.one);
                Graphics.DrawMesh(MeshPool.plane10, matrix, Building_OmniShield.ShieldRotator, 0);
            }
        }
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

daveboy2000

Quote from: skullywag on April 18, 2015, 02:27:40 PM
It uses the turret class which contains a draw turret method but the code to handle the spinning is simple enough, i ended up actually making it match the personal shield way of spinning simple for ease (the vanilla bubble "spins")


private static readonly Material ShieldRotator = MaterialPool.MatFrom("Things/Building/Security/OmniShield_top", ShaderDatabase.Transparent);
public void DrawTurret()
        {
            if (this.powerComp.PowerOn)
            {;
                float angle = (float)Rand.Range(0, 360);
                Vector3 s = new Vector3(1f, 1f, 1f);
                s.y = Altitudes.AltitudeFor(AltitudeLayer.VisEffects);
                Matrix4x4 matrix = default(Matrix4x4);
                matrix.SetTRS(this.DrawPos + Altitudes.AltIncVect, Quaternion.AngleAxis(angle, Vector3.up), s);
                Graphics.DrawMesh(MeshPool.plane10, matrix, Building_OmniShield.ShieldRotator, 0);
            }
            else
            {
                Matrix4x4 matrix = default(Matrix4x4);
                Vector3 s = new Vector3(1f, 1f, 1f);
                s.y = Altitudes.AltitudeFor(AltitudeLayer.MoteLow);
                matrix.SetTRS(this.DrawPos + Altitudes.AltIncVect + Altitudes.AltIncVect, Rotation.AsQuat, Vector3.one);
                Graphics.DrawMesh(MeshPool.plane10, matrix, Building_OmniShield.ShieldRotator, 0);
            }
        }


Thanks for sharing!

skullywag

Just so you know all my source is added with my mods, you just need visual studio to see it all.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

daveboy2000

Quote from: skullywag on April 18, 2015, 04:12:40 PM
Just so you know all my source is added with my mods, you just need visual studio to see it all.
Yeah my visual studio trail ran out, so I'll need to see if I can find an open-source .dll reader

skullywag

Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

daveboy2000


skullywag

Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?