public void PrintForAirGrid( SectionLayer layer ) { foreach (var current in AllComps.Where( s => s is CompAir ).Cast< CompAir >()) { current.CompPrintForAirGrid( layer ); } }
public override void Print(SectionLayer layer, Thing parent) { var occupiedRect = parent.OccupiedRect(); foreach (var current in occupiedRect) { var center = current.ToVector3ShiftedWithAltitude( AltitudeLayer.WorldDataOverlay ); Printer_Plane.PrintPlane( layer, center, new Vector2( 1f, 1f ), LinkedDrawMatFrom( parent, current ), 0f ); } }
public static void PrintForGasGrid(this ThingWithComps building, SectionLayer layer) { IEnumerator<ThingComp> gasCompIterator = building.AllComps.Where( c => c is CompGas).GetEnumerator(); try { while(gasCompIterator.MoveNext()) { ((CompGas)gasCompIterator.Current).CompPrintForGasGrid(layer); } } finally { gasCompIterator.Dispose(); } }
public override void Print(SectionLayer layer, Thing parent) { for (int i = 0; i < 4; i++) { IntVec3 c = parent.Position + GenAdj.CardinalDirections[i]; if (c.InBounds()) { Building transmitter = c.GetGasTranmitter(); if (transmitter != null) { Material mat = LinkedDrawMatFrom(parent, c); Printer_Plane.PrintPlane( layer, c.ToVector3ShiftedWithAltitude(parent.def.Altitude), Vector2.one, mat, 0f, false, null, null); } } } }
public override void Print( SectionLayer layer, Thing parent ) { base.Print( layer, parent ); var compAir = parent.TryGetComp< CompAir >(); if ( compAir == null ) return; for ( var i = 0; i < 4; i++ ) { var neighCell = parent.Position + GenAdj.CardinalDirections[i]; if ( !neighCell.InBounds() ) { continue; } Material mat; if ( compAir.IsLayerOf( NetLayer.Lower ) ) { var lowerTransmitter = neighCell.GetAirTransmitter( NetLayer.Lower ); if ( lowerTransmitter != null && !lowerTransmitter.def.graphicData.Linked ) { mat = LinkedDrawMatFrom(parent, neighCell); Printer_Plane.PrintPlane(layer, neighCell.ToVector3ShiftedWithAltitude(parent.def.Altitude), Vector2.one, mat, 0f); } } else if ( compAir.IsLayerOf( NetLayer.Upper ) ) { var upperTransmitter = neighCell.GetAirTransmitter( NetLayer.Upper ); if ( upperTransmitter != null && !upperTransmitter.def.graphicData.Linked ) { mat = LinkedDrawMatFrom(parent, neighCell); Printer_Plane.PrintPlane(layer, neighCell.ToVector3ShiftedWithAltitude(parent.def.Altitude), Vector2.one, mat, 0f); } } } }
public override void Print(SectionLayer layer) { Vector3 trueCenter = this.TrueCenter(); Rand.PushState(); Rand.Seed = Position.GetHashCode(); //So our random generator makes the same numbers every time //Determine how many meshes to print int meshCount = Mathf.CeilToInt(growthInt * def.plant.maxMeshCount); if (meshCount < 1) { meshCount = 1; } //Determine plane size float size = def.plant.visualSizeRange.LerpThroughRange(growthInt); float graphicSize = def.graphicData.drawSize.x * size; //Plants don't support non-square drawSizes //Shuffle up the position indices and place meshes at them //We do this to get even mesh placement by placing them roughly on a grid Vector3 adjustedCenter = Vector3.zero; int meshesYielded = 0; var posIndexList = PlantPosIndices.GetPositionIndices(this); bool clampedBottomToCellBottom = false; for (int i = 0; i < posIndexList.Length; i++) { int posIndex = posIndexList[i]; //Determine center position if (def.plant.maxMeshCount == 1) { //Determine random local position variance const float PositionVariance = 0.05f; adjustedCenter = trueCenter + Gen.RandomHorizontalVector(PositionVariance); //Clamp bottom of plant to square bottom //So tall plants grow upward float squareBottom = Position.z; if (adjustedCenter.z - size / 2f < squareBottom) { adjustedCenter.z = squareBottom + size / 2f; clampedBottomToCellBottom = true; } } else { //Grid width is the square root of max mesh count int gridWidth = 1; switch (def.plant.maxMeshCount) { case 1: gridWidth = 1; break; case 4: gridWidth = 2; break; case 9: gridWidth = 3; break; case 16: gridWidth = 4; break; case 25: gridWidth = 5; break; default: Log.Error(def + " must have plant.MaxMeshCount that is a perfect square."); break; } float gridSpacing = 1f / gridWidth; //This works out to give half-spacings around the edges adjustedCenter = Position.ToVector3(); //unshifted adjustedCenter.y = def.Altitude; //Set altitude //Place this mesh at its randomized position on the submesh grid adjustedCenter.x += 0.5f * gridSpacing; adjustedCenter.z += 0.5f * gridSpacing; int xInd = posIndex / gridWidth; int zInd = posIndex % gridWidth; adjustedCenter.x += xInd * gridSpacing; adjustedCenter.z += zInd * gridSpacing; //Add a random offset float gridPosRandomness = gridSpacing * GridPosRandomnessFactor; adjustedCenter += Gen.RandomHorizontalVector(gridPosRandomness); } //Randomize horizontal flip bool flipped = Rand.Bool; //Randomize material var mat = Graphic.MatSingle; //Pulls a random material //Set wind exposure value at each vertex by setting vertex color PlantUtility.SetWindExposureColors(workingColors, this); var planeSize = new Vector2(graphicSize, graphicSize); Printer_Plane.PrintPlane(layer, adjustedCenter, planeSize, mat, flipUv: flipped, colors: workingColors, topVerticesAltitudeBias: TopVerticesAltitudeBias, // need to beat walls corner filler (so trees don't get cut by mountains) uvzPayload: Gen.HashOffset(this) % 1024); meshesYielded++; if (meshesYielded >= meshCount) { break; } } if (def.graphicData.shadowData != null) { //Start with a standard shadow center var shadowCenter = trueCenter + def.graphicData.shadowData.offset * size; //Clamp center of shadow to cell bottom if (clampedBottomToCellBottom) { shadowCenter.z = Position.ToVector3Shifted().z + def.graphicData.shadowData.offset.z; } shadowCenter.y -= Altitudes.AltInc; var shadowVolume = def.graphicData.shadowData.volume * size; Printer_Shadow.PrintShadow(layer, shadowCenter, shadowVolume, Rot4.North); } Rand.PopState(); }
public static string GetLabel(SectionLayer __instance) => __instance.GetType().FullName;
public override void Print(SectionLayer layer) { //this.Graphic.Print(layer, this); Printer_Plane.PrintPlane(layer, GenThing.TrueCenter(Position, Rot4.South, def.size, 11.7f), Graphic.drawSize, Graphic.MatSingle, 0, false, null, null, 0.01f, 0f); }
public override void CompPrintForAutomationGrid(SectionLayer layer) { AutomationNetOverlayMats.GetOverlayGraphic((Building)this.parent).Print(layer, this.parent); }
public override void PrintOnto(SectionLayer layer) { Vector3 a = this.TrueCenter(); Rand.Seed = base.Position.GetHashCode(); float num; if (this.def.plant.maxMeshCount == 1) { num = 0.05f; } else { num = 0.5f; } int num2 = Mathf.CeilToInt(this.growthPercent * (float)this.def.plant.maxMeshCount); if (num2 < 1) { num2 = 1; } int num3 = 1; int maxMeshCount = this.def.plant.maxMeshCount; switch (maxMeshCount) { case 1: num3 = 1; goto IL_F3; case 2: case 3: num3 = 5; goto IL_F3; case 4: num3 = 2; goto IL_F3; } goto IL_96; IL_96: if (maxMeshCount == 9) { num3 = 3; goto IL_F3; } if (maxMeshCount == 16) { num3 = 4; goto IL_F3; } if (maxMeshCount != 25) { Log.Error(this.def + " must have plant.MaxMeshCount that is a perfect square."); goto IL_F3; } IL_F3: float num4 = 1f / (float)num3; Vector3 vector = Vector3.zero; Vector2 zero = Vector2.zero; int num5 = 0; int count = this.posIndexList.Count; for (int i = 0; i < count; i++) { int num6 = this.posIndexList[i]; float num7 = this.def.plant.visualSizeRange.LerpThroughRange(this.growthPercent); if (this.def.plant.maxMeshCount == 1) { vector = a + new Vector3(Rand.Range(-num, num), 0f, Rand.Range(-num, num)); float num8 = Mathf.Floor(a.z); if (vector.z - num7 / 2f < num8) { vector.z = num8 + num7 / 2f; } } else { vector = base.Position.ToVector3(); vector.y = this.def.altitude; vector.x += 0.5f * num4; vector.z += 0.5f * num4; int num9 = num6 / num3; int num10 = num6 % num3; vector.x += (float)num9 * num4; vector.z += (float)num10 * num4; float num11 = num4 * 0.3f; vector += new Vector3(Rand.Range(-num11, num11), 0f, Rand.Range(-num11, num11)); } bool flag = Rand.Value < 0.5f; Material mat = this.def.folderDrawMats.RandomListElement<Material>(); this.workingColors[1].a = (this.workingColors[2].a = (byte)(255f * this.def.plant.topWindExposure)); this.workingColors[0].a = (this.workingColors[3].a = 0); if (this.def.overdraw) { num7 += 2f; } zero = new Vector2(num7, num7); bool flipUv = flag; Printer_Plane.PrintPlane(layer, vector, zero, mat, 0f, flipUv, null, this.workingColors); num5++; if (num5 >= num2) { break; } } if (this.def.sunShadowInfo != null) { float num12; if (zero.y < 1f) { num12 = 0.6f; } else { num12 = 0.81f; } Vector3 center = vector; center.z -= zero.y / 2f * num12; center.y -= 0.04f; Printer_Shadow.PrintShadow(layer, center, this.def.sunShadowInfo); } }
public override void Print(SectionLayer layer, Thing thing) { Material mat = this.LinkedDrawMatFrom(thing, thing.Position); Printer_Plane.PrintPlane(layer, thing.TrueCenter(), this.drawSize, mat); }
public void PrintForPowerGrid( SectionLayer layer ) { //Transmitter stuff if (TransmitsPower) { foreach( IntVec3 sq in GenAdj.SquaresOccupiedBy(this) ) { //Transmission lines LinkDrawers.transmitterOverlay.PrintOnto(layer, this, sq); } } //The connector base (small blue circle) if( def.ConnectToPower ) { PowerNetGraphics.PrintOverlayConnectorBaseFor( layer, this ); } //The connector wire if( connectedToTransmitter != null ) { PowerNetGraphics.PrintWirePieceConnecting( layer, this, connectedToTransmitter, true ); } }
public void Print(SectionLayer layer, Vector3 drawPos, Rot4 rot) { //var info = new GraphicDrawInfo(Graphic, drawPos, rot, ((FXThingDef)parent.def).extraData, parent.def); Printer_Plane.PrintPlane(layer, new Vector3(drawPos.x, altitude, drawPos.z), data.data.drawSize, Graphic.MatAt(rot)); }
public void CompPrintForGasGrid(SectionLayer layer) { if (this.TransmitsGasNow || base.parent.def.ConnectToGas()) { GasOverlayMats.LinkedOverlayGraphic.Print(layer, base.parent); } }
public override void Print(SectionLayer layer, Thing thing) { Material mat = this.LinkedDrawMatFrom(thing, thing.Position); Printer_Plane.PrintPlane(layer, thing.TrueCenter(), new Vector2(1f, 1f), mat, 0.0f, false, (Vector2[])null, (Color32[])null, 0.01f, 0.0f); }
protected void PrintEndpoint(SectionLayer layer) { Resources.Graphics.DetWireOverlayEndpoint.Print(layer, parent); }
protected void PrintConnection(SectionLayer layer) { Resources.Graphics.DetWireOverlayAtlas.Print(layer, parent); }
public abstract void PrintForDetonationGrid(SectionLayer layer);
public override void Print(SectionLayer layer, Thing parent) { Printer_Plane.PrintPlane(layer, parent.TrueCenter(), Vector2.one, this.LinkedDrawMatFrom(parent, parent.Position), 0f, false, null, null, 0.01f); }
public override void PrintOnto( SectionLayer layer ) { //Yield power wires connecting me to my transmitter if( connectedToTransmitter != null ) PowerNetGraphics.PrintWirePieceConnecting( layer, this, connectedToTransmitter, false); base.PrintOnto(layer); }
public void CompPrintForAirGrid(SectionLayer layer) { AirOverlayMat.GetLayeredOverlayGraphic(this).Print(layer, parent); }
public void BasePrint(Graphic_LinkedCornerFiller graphic, SectionLayer layer, Thing thing) { Material mat = LinkedDrawMatFrom(graphic, thing, thing.Position); Printer_Plane.PrintPlane(layer, thing.TrueCenter(), new Vector2(1f, 1f), mat); }
public override void Print(SectionLayer layer) { return; }
public override void PrintOnto(SectionLayer layer) { Profiler.BeginSample("Plant.EmitMeshPieces " + this); Vector3 trueCenter = this.TrueCenter(); Profiler.BeginSample("Meshes"); Random.seed = Position.GetHashCode(); //So our random generator makes the same numbers every time //Determine random local position variance float positionVariance; if (def.plant.maxMeshCount == 1) { positionVariance = 0.05f; } else { positionVariance = 0.50f; } //Determine how many meshes to print int meshCount = Mathf.CeilToInt(growthPercent * def.plant.maxMeshCount); if (meshCount < 1) { meshCount = 1; } //Grid width is the square root of max mesh count int gridWidth = 1; switch (def.plant.maxMeshCount) { case 1: gridWidth = 1; break; case 4: gridWidth = 2; break; case 9: gridWidth = 3; break; case 16: gridWidth = 4; break; case 25: gridWidth = 5; break; default: Log.Error(def + " must have plant.MaxMeshCount that is a perfect square."); break; } float gridSpacing = 1f / gridWidth; //This works out to give half-spacings around the edges //Shuffle up the position indices and place meshes at them //We do this to get even mesh placement by placing them roughly on a grid Vector3 adjustedCenter = Vector3.zero; Vector2 planeSize = Vector2.zero; int meshesYielded = 0; int posCount = posIndexList.Count; for (int i = 0; i < posCount; i++) { int posIndex = posIndexList[i]; //Determine plane size float size = def.plant.visualSizeRange.LerpThroughRange(growthPercent); //Determine center position if (def.plant.maxMeshCount == 1) { adjustedCenter = trueCenter + new Vector3(Random.Range(-positionVariance, positionVariance), 0, Random.Range(-positionVariance, positionVariance)); //Clamp bottom of plant to square bottom //So tall plants grow upward float squareBottom = Mathf.Floor(trueCenter.z); if ((adjustedCenter.z - (size / 2f)) < squareBottom) { adjustedCenter.z = squareBottom + (size / 2f); } } else { adjustedCenter = Position.ToVector3(); //unshifted adjustedCenter.y = def.altitude; //Set altitude //Place this mesh at its randomized position on the submesh grid adjustedCenter.x += 0.5f * gridSpacing; adjustedCenter.z += 0.5f * gridSpacing; int xInd = posIndex / gridWidth; int zInd = posIndex % gridWidth; adjustedCenter.x += xInd * gridSpacing; adjustedCenter.z += zInd * gridSpacing; //Add a random offset float gridPosRandomness = gridSpacing * GridPosRandomnessFactor; adjustedCenter += new Vector3(Random.Range(-gridPosRandomness, gridPosRandomness), 0, Random.Range(-gridPosRandomness, gridPosRandomness)); } //Randomize horizontal flip bool flipped = Random.value < 0.5f; //Randomize material Material mat = def.folderDrawMats.RandomListElement(); //Set wind exposure value at each vertex by setting vertex color workingColors[1].a = workingColors[2].a = (byte)(255 * def.plant.topWindExposure); workingColors[0].a = workingColors[3].a = 0; if (def.overdraw) { size += 2f; } planeSize = new Vector2(size, size); Printer_Plane.PrintPlane(layer, adjustedCenter, planeSize, mat, flipUv: flipped, colors: workingColors); meshesYielded++; if (meshesYielded >= meshCount) { break; } } Profiler.EndSample(); Profiler.BeginSample("Shadow"); if (def.sunShadowInfo != null) { //Brutal shadow positioning hack float shadowOffsetFactor = 0.85f; if (planeSize.y < 1) { shadowOffsetFactor = 0.6f; //for bushes } else { shadowOffsetFactor = 0.81f; //for cacti } Vector3 sunShadowLoc = adjustedCenter; sunShadowLoc.z -= (planeSize.y / 2f) * shadowOffsetFactor; sunShadowLoc.y -= Altitudes.AltInc; Printer_Shadow.PrintShadow(layer, sunShadowLoc, def.sunShadowInfo); } Profiler.EndSample(); Profiler.EndSample(); }
static bool ShouldKeep(SectionLayer layer) { return(layer.GetType().Assembly == typeof(Game).Assembly); }
public override void PrintForDetonationGrid(SectionLayer layer) { PrintEndpoint(layer); }
public override void PrintForDetonationGrid(SectionLayer layer) { PrintConnection(layer); }
public override void Print(SectionLayer layer) { Vector3 a = this.TrueCenter(); Rand.PushState(); Rand.Seed = base.Position.GetHashCode(); int num = Mathf.CeilToInt(this.growthInt * (float)this.def.plant.maxMeshCount); if (num < 1) { num = 1; } float num2 = this.def.plant.visualSizeRange.LerpThroughRange(this.growthInt); float num3 = this.def.graphicData.drawSize.x * num2; Vector3 vector = Vector3.zero; int num4 = 0; int[] positionIndices = PlantPosIndices.GetPositionIndices(this); bool flag = false; for (int i = 0; i < positionIndices.Length; i++) { int num5 = positionIndices[i]; if (this.def.plant.maxMeshCount == 1) { vector = a + Gen.RandomHorizontalVector(0.05f); float num6 = (float)base.Position.z; if (vector.z - num2 / 2f < num6) { vector.z = num6 + num2 / 2f; flag = true; } } else { int num7 = 1; int maxMeshCount = this.def.plant.maxMeshCount; switch (maxMeshCount) { case 1: num7 = 1; goto IL_19E; case 2: case 3: IL_13C: if (maxMeshCount == 9) { num7 = 3; goto IL_19E; } if (maxMeshCount == 16) { num7 = 4; goto IL_19E; } if (maxMeshCount != 25) { Log.Error(this.def + " must have plant.MaxMeshCount that is a perfect square."); goto IL_19E; } num7 = 5; goto IL_19E; case 4: num7 = 2; goto IL_19E; } goto IL_13C; IL_19E: float num8 = 1f / (float)num7; vector = base.Position.ToVector3(); vector.y = this.def.Altitude; vector.x += 0.5f * num8; vector.z += 0.5f * num8; int num9 = num5 / num7; int num10 = num5 % num7; vector.x += (float)num9 * num8; vector.z += (float)num10 * num8; float max = num8 * 0.3f; vector += Gen.RandomHorizontalVector(max); } bool @bool = Rand.Bool; Material matSingle = this.Graphic.MatSingle; GenPlant.SetWindExposureColors(Plant.workingColors, this); Vector2 vector2 = new Vector2(num3, num3); Vector3 center = vector; Vector2 size = vector2; Material mat = matSingle; bool flipUv = @bool; Printer_Plane.PrintPlane(layer, center, size, mat, 0f, flipUv, null, Plant.workingColors, 0.1f); num4++; if (num4 >= num) { break; } } if (this.def.graphicData.shadowData != null) { Vector3 center2 = a + this.def.graphicData.shadowData.offset * num2; if (flag) { center2.z = base.Position.ToVector3Shifted().z + this.def.graphicData.shadowData.offset.z; } center2.y -= 0.046875f; Vector3 volume = this.def.graphicData.shadowData.volume * num2; Printer_Shadow.PrintShadow(layer, center2, volume, Rot4.North); } Rand.PopState(); }
public void Print(Plant plant, SectionLayer layer, Graphic newGraphic, int curLevel, int baseLevel) { Vector3 a = plant.TrueCenter(); Rand.PushState(); Rand.Seed = plant.Position.GetHashCode(); int num = Mathf.CeilToInt(plant.growthInt * (float)plant.def.plant.maxMeshCount); if (num < 1) { num = 1; } float num2 = plant.def.plant.visualSizeRange.LerpThroughRange(plant.growthInt); float num3 = plant.def.graphicData.drawSize.x * num2; Vector3 center = Vector3.zero; int num4 = 0; int[] positionIndices = PlantPosIndices.GetPositionIndices(plant); bool flag = false; foreach (int num5 in positionIndices) { if (plant.def.plant.maxMeshCount == 1) { center = a + Gen.RandomHorizontalVector(0.05f); float num6 = plant.Position.z; if (center.z - num2 / 2f < num6) { center.z = num6 + num2 / 2f; flag = true; } } else { int num7 = 1; switch (plant.def.plant.maxMeshCount) { case 1: num7 = 1; break; case 4: num7 = 2; break; case 9: num7 = 3; break; case 16: num7 = 4; break; case 25: num7 = 5; break; default: Log.Error(string.Concat(plant.def, " must have plant.MaxMeshCount that is a perfect square.")); break; } float num8 = 1f / (float)num7; center = plant.Position.ToVector3(); center.y = plant.def.Altitude; center.x += 0.5f * num8; center.z += 0.5f * num8; int num9 = num5 / num7; int num10 = num5 % num7; center.x += (float)num9 * num8; center.z += (float)num10 * num8; float max = num8 * 0.3f; center += Gen.RandomHorizontalVector(max); } bool @bool = Rand.Bool; Material matSingle = newGraphic.MatSingle; PlantUtility.SetWindExposureColors(Plant.workingColors, plant); center.z -= (curLevel - baseLevel) / 2f; center.y -= (curLevel - baseLevel) / 2f; num3 *= 1f - (((float)(curLevel) - (float)baseLevel) / 5f); Printer_Plane.PrintPlane(size: new Vector2(num3, num3), layer: layer, center: center, mat: matSingle, rot: 0f, flipUv: @bool, uvs: null, colors: Plant.workingColors, topVerticesAltitudeBias: 0.1f, uvzPayload: plant.HashOffset() % 1024); num4++; if (num4 >= num) { break; } } if (plant.def.graphicData.shadowData != null) { Vector3 center2 = a + plant.def.graphicData.shadowData.offset * num2; if (flag) { center2.z = plant.Position.ToVector3Shifted().z + plant.def.graphicData.shadowData.offset.z; } center2.y -= 3f / 70f; Vector3 volume = plant.def.graphicData.shadowData.volume * num2; Printer_Shadow.PrintShadow(layer, center2, volume, Rot4.North); } Rand.PopState(); }
public override void PrintOnto( SectionLayer layer ) { Profiler.BeginSample("Plant.EmitMeshPieces " + this); Vector3 trueCenter = this.TrueCenter(); Profiler.BeginSample("Meshes"); Random.seed = Position.GetHashCode();//So our random generator makes the same numbers every time //Determine random local position variance float positionVariance; if( def.plant.maxMeshCount == 1 ) positionVariance = 0.05f; else positionVariance = 0.50f; //Determine how many meshes to print int meshCount = Mathf.CeilToInt( growthPercent * def.plant.maxMeshCount ); if( meshCount < 1 ) meshCount = 1; //Grid width is the square root of max mesh count int gridWidth = 1; switch( def.plant.maxMeshCount ) { case 1: gridWidth = 1; break; case 4: gridWidth = 2; break; case 9: gridWidth = 3; break; case 16: gridWidth = 4; break; case 25: gridWidth = 5; break; default: Log.Error(def + " must have plant.MaxMeshCount that is a perfect square."); break; } float gridSpacing = 1f/gridWidth; //This works out to give half-spacings around the edges //Shuffle up the position indices and place meshes at them //We do this to get even mesh placement by placing them roughly on a grid Vector3 adjustedCenter = Vector3.zero; Vector2 planeSize = Vector2.zero; int meshesYielded = 0; int posCount = posIndexList.Count; for(int i=0; i<posCount; i++ ) { int posIndex = posIndexList[i]; //Determine plane size float size = def.plant.visualSizeRange.LerpThroughRange(growthPercent); //Determine center position if( def.plant.maxMeshCount == 1 ) { adjustedCenter = trueCenter + new Vector3(Random.Range(-positionVariance, positionVariance), 0, Random.Range(-positionVariance, positionVariance) ); //Clamp bottom of plant to square bottom //So tall plants grow upward float squareBottom = Mathf.Floor(trueCenter.z); if( (adjustedCenter.z - (size/2f)) < squareBottom ) adjustedCenter.z = squareBottom + (size/2f); } else { adjustedCenter = Position.ToVector3(); //unshifted adjustedCenter.y = def.altitude;//Set altitude //Place this mesh at its randomized position on the submesh grid adjustedCenter.x += 0.5f * gridSpacing; adjustedCenter.z += 0.5f * gridSpacing; int xInd = posIndex / gridWidth; int zInd = posIndex % gridWidth; adjustedCenter.x += xInd * gridSpacing; adjustedCenter.z += zInd * gridSpacing; //Add a random offset float gridPosRandomness = gridSpacing * GridPosRandomnessFactor; adjustedCenter += new Vector3(Random.Range(-gridPosRandomness, gridPosRandomness), 0, Random.Range(-gridPosRandomness, gridPosRandomness) ); } //Randomize horizontal flip bool flipped = Random.value < 0.5f; //Randomize material Material mat = def.folderDrawMats.RandomListElement(); //Set wind exposure value at each vertex by setting vertex color workingColors[1].a = workingColors[2].a = (byte)(255 * def.plant.topWindExposure); workingColors[0].a = workingColors[3].a = 0; if( def.overdraw ) size += 2f; planeSize = new Vector2( size,size ); Printer_Plane.PrintPlane( layer, adjustedCenter, planeSize, mat, flipUv: flipped, colors: workingColors ); meshesYielded++; if( meshesYielded >= meshCount ) break; } Profiler.EndSample(); Profiler.BeginSample("Shadow"); if( def.sunShadowInfo != null) { //Brutal shadow positioning hack float shadowOffsetFactor = 0.85f; if( planeSize.y < 1 ) shadowOffsetFactor = 0.6f; //for bushes else shadowOffsetFactor = 0.81f; //for cacti Vector3 sunShadowLoc = adjustedCenter; sunShadowLoc.z -= (planeSize.y/2f) * shadowOffsetFactor; sunShadowLoc.y -= Altitudes.AltInc; Printer_Shadow.PrintShadow( layer, sunShadowLoc, def.sunShadowInfo ); } Profiler.EndSample(); Profiler.EndSample(); }
public void BasePrint(Thing thing, SectionLayer layer, Graphic newGraphic) { newGraphic.Print(layer, thing); }
public override void PrintForDetonationGrid(SectionLayer layer) { Resources.Graphics.DetWireOverlayCrossing.Print(layer, parent); }
public void CompPrintForAirGrid( SectionLayer layer ) { AirOverlayMat.GetLayeredOverlayGraphic( this ).Print( layer, parent ); }
public override void PostPrintOnto(SectionLayer layer) { if (parent.def.graphicData.shadowData != null) { // shadow offset is not calculated in PrintShadow by default for some reason var shadow = parent.def.graphicData.shadowData; var offset = parent.TrueCenter() + parent.def.graphicData.shadowData.offset; var subMesh = layer.GetSubMesh(MatBases.SunShadowFade); var item = new Color32(255, 0, 0, (byte)(255f * shadow.BaseY)); float num, num2; if (parent.Rotation == Rot4.North || parent.Rotation == Rot4.South) { num = shadow.BaseX/2f; num2 = shadow.BaseZ/2f; } else { num = shadow.BaseZ/2f; num2 = shadow.BaseX/2f; } var x = offset.x; var z = offset.z; var count = subMesh.verts.Count; subMesh.verts.Add(new Vector3(x - num, 1f, z - num2)); subMesh.verts.Add(new Vector3(x - num, 1f, z + num2)); subMesh.verts.Add(new Vector3(x + num, 1f, z + num2)); subMesh.verts.Add(new Vector3(x + num, 1f, z - num2)); subMesh.colors.Add(LowVertexColor); subMesh.colors.Add(LowVertexColor); subMesh.colors.Add(LowVertexColor); subMesh.colors.Add(LowVertexColor); subMesh.tris.Add(count); subMesh.tris.Add(count + 1); subMesh.tris.Add(count + 2); subMesh.tris.Add(count); subMesh.tris.Add(count + 2); subMesh.tris.Add(count + 3); var count2 = subMesh.verts.Count; subMesh.verts.Add(new Vector3(x - num, 1f, z - num2)); subMesh.verts.Add(new Vector3(x - num, 1f, z + num2)); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count); subMesh.tris.Add(count2); subMesh.tris.Add(count2 + 1); subMesh.tris.Add(count); subMesh.tris.Add(count2 + 1); subMesh.tris.Add(count + 1); var count3 = subMesh.verts.Count; subMesh.verts.Add(new Vector3(x + num, 1f, z + num2)); subMesh.verts.Add(new Vector3(x + num, 1f, z - num2)); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count + 2); subMesh.tris.Add(count3); subMesh.tris.Add(count3 + 1); subMesh.tris.Add(count3 + 1); subMesh.tris.Add(count + 3); subMesh.tris.Add(count + 2); var count4 = subMesh.verts.Count; subMesh.verts.Add(new Vector3(x - num, 1f, z - num2)); subMesh.verts.Add(new Vector3(x + num, 1f, z - num2)); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count); subMesh.tris.Add(count + 3); subMesh.tris.Add(count4); subMesh.tris.Add(count + 3); subMesh.tris.Add(count4 + 1); subMesh.tris.Add(count4); } }