public static void DrawPulse( Thing thing, Material mat, Mesh mesh, Layer myLayer = Layer.over, OpacityWay opacityWay = OpacityWay.no, bool debug = false) { float myOpacity = UpdateOpacity(thing, opacityWay, 1, debug); Material material = FadedMaterialPool.FadedVersionOf(mat, myOpacity); Vector3 gfxPos = thing.DrawPos; gfxPos.y += (float)myLayer; Vector3 dotS = new Vector3(1f, 1f, 1f); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(gfxPos, Quaternion.AngleAxis(0f, Vector3.up), dotS); Graphics.DrawMesh(mesh, matrix, material, 0); if (debug) { Log.Warning( thing.LabelShort + "; opa: " + myOpacity + "; pos: " + gfxPos + "; col: " + mat.color ); } }
private static float UpdateOpacity(Thing thing, OpacityWay opacityWay = OpacityWay.no, float opacity = 1, bool debug = false) { float newOpacity = -1; float checkBackup = -1; switch (opacityWay) { case OpacityWay.no: newOpacity = 1; break; case OpacityWay.forced: newOpacity = opacity; // default break; case OpacityWay.pulse: newOpacity = PulseOpacity(thing); break; case OpacityWay.loop: newOpacity = LoopFactorOne(thing); break; } checkBackup = newOpacity; if (checkBackup != (newOpacity = Tools.LimitToRange(newOpacity, 0, 1))) { if (debug) { Log.Warning("dumb opacity(" + opacityWay + "):" + newOpacity + "(def=" + opacity + ")"); } } return(newOpacity); }