void RenderRubble(Vector3 drawLoc) { foreach (var r in rubbles) { var scale = Constants.MIN_SCALE + (Constants.MAX_SCALE - Constants.MIN_SCALE) * r.scale; var x = 0f + r.pX / 2f; var bottomExtend = Math.Abs(r.pX) / 6f; var y = -0.5f + Math.Max(bottomExtend, r.pY - r.drop) * (Constants.MAX_HEIGHT - scale / 2f) + (scale - Constants.MAX_SCALE) / 2f; var pos = drawLoc + new Vector3(x, 0, y); pos.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn + 1); var rot = Quaternion.Euler(0f, r.rot * 360f, 0f); GraphicToolbox.DrawScaledMesh(MeshPool.plane10, Constants.RUBBLE, pos, rot, scale, scale); } }
public override void Init(GraphicRequest req) { data = req.graphicData; path = req.path; color = req.color; colorTwo = req.colorTwo; drawSize = req.drawSize; hash = Gen.HashCombine(hash, path); hash = Gen.HashCombineStruct(hash, color); hash = Gen.HashCombineStruct(hash, colorTwo); var bodyColor = GraphicToolbox.RandomSkinColorString(); mats = new ColorData[] { GraphicsDatabase.GetColorData(req.path + "_back", bodyColor, true), GraphicsDatabase.GetColorData(req.path + "_side", bodyColor, true), GraphicsDatabase.GetColorData(req.path + "_front", bodyColor, true) } .Select(data => { var points = ZombieStains.maxStainPoints; while (points > 0) { var stain = ZombieStains.GetRandom(points, req.path.Contains("Naked")); data.ApplyStains(stain.Key, Rand.Bool, Rand.Bool); points -= stain.Value; hash = Gen.HashCombine(hash, stain); } var request = new MaterialRequest { mainTex = null, // will be calculated lazy from 'data' shader = req.shader, color = color, colorTwo = colorTwo, maskTex = null }; return(new PreparedMaterial(request, data)); }) .ToArray(); }
public static IEnumerator AssignNewGraphics(Zombie zombie) { zombie.Drawer.renderer.graphics.ResolveAllGraphics(); yield return(null); var headPath = FixGlowingEyeOffset(zombie); if (zombie.IsSuicideBomber) { zombie.lastBombTick = Find.TickManager.TicksAbs + Rand.Range(0, (int)zombie.bombTickingInterval); } if (ZombieSettings.Values.useCustomTextures) { var renderPrecedence = 0; var bodyPath = "Zombie/Naked_" + zombie.story.bodyType.ToString(); var color = zombie.isToxicSplasher ? "toxic" : (zombie.isMiner ? "miner" : GraphicToolbox.RandomSkinColorString()); yield return(null); var bodyRequest = new GraphicRequest(typeof(VariableGraphic), bodyPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence, new List <ShaderParameter>()); yield return(null); var maxStainPoints = ZombieStains.maxStainPoints; if (zombie.isMiner) { maxStainPoints *= 2; } var customBodyGraphic = new VariableGraphic { bodyColor = color }; yield return(null); customBodyGraphic.Init(VariableGraphic.minimal); yield return(null); for (var i = 0; i < 4; i++) { var j = 0; var it = customBodyGraphic.InitIterativ(bodyRequest, i, maxStainPoints); while (it.MoveNext()) { yield return(null); j++; } } zombie.Drawer.renderer.graphics.nakedGraphic = customBodyGraphic; var headRequest = new GraphicRequest(typeof(VariableGraphic), headPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence, new List <ShaderParameter>()); yield return(null); var customHeadGraphic = new VariableGraphic { bodyColor = color }; yield return(null); customHeadGraphic.Init(VariableGraphic.minimal); yield return(null); for (var i = 0; i < 4; i++) { var j = 0; var it = customHeadGraphic.InitIterativ(headRequest, i, maxStainPoints); while (it.MoveNext()) { yield return(null); j++; } } zombie.Drawer.renderer.graphics.headGraphic = customHeadGraphic; } yield return(null); }