private void DrawLinkableCornersAndEdges(Building b) { if (b.def.graphicData == null) { return; } DamageGraphicData damageData = b.def.graphicData.damageData; if (damageData == null) { return; } float damageTexturesAltitude = GetDamageTexturesAltitude(b); List <DamageOverlay> overlays = BuildingsDamageSectionLayerUtility.GetOverlays(b); IntVec3 position = b.Position; Vector3 vector = new Vector3((float)position.x + 0.5f, damageTexturesAltitude, (float)position.z + 0.5f); float x = Rand.Range(0.4f, 0.6f); float z = Rand.Range(0.4f, 0.6f); float x2 = Rand.Range(0.4f, 0.6f); float z2 = Rand.Range(0.4f, 0.6f); for (int i = 0; i < overlays.Count; i++) { switch (overlays[i]) { case DamageOverlay.TopEdge: Printer_Plane.PrintPlane(this, vector + new Vector3(x, 0f, 0f), Vector2.one, damageData.edgeTopMat, 0f, flipUv: false, null, null, 0f); break; case DamageOverlay.RightEdge: Printer_Plane.PrintPlane(this, vector + new Vector3(0f, 0f, z), Vector2.one, damageData.edgeRightMat, 90f, flipUv: false, null, null, 0f); break; case DamageOverlay.BotEdge: Printer_Plane.PrintPlane(this, vector + new Vector3(x2, 0f, 0f), Vector2.one, damageData.edgeBotMat, 180f, flipUv: false, null, null, 0f); break; case DamageOverlay.LeftEdge: Printer_Plane.PrintPlane(this, vector + new Vector3(0f, 0f, z2), Vector2.one, damageData.edgeLeftMat, 270f, flipUv: false, null, null, 0f); break; case DamageOverlay.TopLeftCorner: Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerTLMat, 0f, flipUv: false, null, null, 0f); break; case DamageOverlay.TopRightCorner: Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerTRMat, 90f, flipUv: false, null, null, 0f); break; case DamageOverlay.BotRightCorner: Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerBRMat, 180f, flipUv: false, null, null, 0f); break; case DamageOverlay.BotLeftCorner: Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerBLMat, 270f, flipUv: false, null, null, 0f); break; } } }
public void CopyFrom(GraphicData other) { this.texPath = other.texPath; this.graphicClass = other.graphicClass; this.shaderType = other.shaderType; this.color = other.color; this.colorTwo = other.colorTwo; this.drawSize = other.drawSize; this.onGroundRandomRotateAngle = other.onGroundRandomRotateAngle; this.drawRotated = other.drawRotated; this.allowFlip = other.allowFlip; this.flipExtraRotation = other.flipExtraRotation; this.shadowData = other.shadowData; this.damageData = other.damageData; this.linkType = other.linkType; this.linkFlags = other.linkFlags; }
public static void GetCornerMats(out Material topLeft, out Material topRight, out Material botRight, out Material botLeft, Building b) { if (b.def.graphicData == null || b.def.graphicData.damageData == null) { topLeft = null; topRight = null; botRight = null; botLeft = null; } else { DamageGraphicData damageData = b.def.graphicData.damageData; if (b.Rotation == Rot4.North) { topLeft = damageData.cornerTLMat; topRight = damageData.cornerTRMat; botRight = damageData.cornerBRMat; botLeft = damageData.cornerBLMat; } else if (b.Rotation == Rot4.East) { topLeft = damageData.cornerBLMat; topRight = damageData.cornerTLMat; botRight = damageData.cornerTRMat; botLeft = damageData.cornerBRMat; } else if (b.Rotation == Rot4.South) { topLeft = damageData.cornerBRMat; topRight = damageData.cornerBLMat; botRight = damageData.cornerTLMat; botLeft = damageData.cornerTRMat; } else { topLeft = damageData.cornerTRMat; topRight = damageData.cornerBRMat; botRight = damageData.cornerBLMat; botLeft = damageData.cornerTLMat; } } }
public void CopyFrom(GraphicData other) { texPath = other.texPath; graphicClass = other.graphicClass; shaderType = other.shaderType; color = other.color; colorTwo = other.colorTwo; drawSize = other.drawSize; drawOffset = other.drawOffset; drawOffsetNorth = other.drawOffsetNorth; drawOffsetEast = other.drawOffsetEast; drawOffsetSouth = other.drawOffsetSouth; drawOffsetWest = other.drawOffsetSouth; onGroundRandomRotateAngle = other.onGroundRandomRotateAngle; drawRotated = other.drawRotated; allowFlip = other.allowFlip; flipExtraRotation = other.flipExtraRotation; shadowData = other.shadowData; damageData = other.damageData; linkType = other.linkType; linkFlags = other.linkFlags; cachedGraphic = null; }
public static List <DamageOverlay> GetAvailableOverlays(Building b) { availableOverlays.Clear(); if (GetScratchMats(b).Any()) { int num = 3; Rect damageRect = GetDamageRect(b); float num2 = damageRect.width * damageRect.height; if (num2 > 4f) { num += Mathf.RoundToInt((num2 - 4f) * 0.54f); } for (int i = 0; i < num; i++) { availableOverlays.Add(DamageOverlay.Scratch); } } if (UsesLinkableCornersAndEdges(b)) { if (b.def.graphicData != null && b.def.graphicData.damageData != null) { IntVec3 position = b.Position; DamageGraphicData damageData = b.def.graphicData.damageData; if (damageData.edgeTopMat != null && DifferentAt(b, position.x, position.z + 1) && SameAndDamagedAt(b, position.x + 1, position.z) && DifferentAt(b, position.x + 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopEdge); } if (damageData.edgeRightMat != null && DifferentAt(b, position.x + 1, position.z) && SameAndDamagedAt(b, position.x, position.z + 1) && DifferentAt(b, position.x + 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.RightEdge); } if (damageData.edgeBotMat != null && DifferentAt(b, position.x, position.z - 1) && SameAndDamagedAt(b, position.x + 1, position.z) && DifferentAt(b, position.x + 1, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotEdge); } if (damageData.edgeLeftMat != null && DifferentAt(b, position.x - 1, position.z) && SameAndDamagedAt(b, position.x, position.z + 1) && DifferentAt(b, position.x - 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.LeftEdge); } if (damageData.cornerTLMat != null && DifferentAt(b, position.x - 1, position.z) && DifferentAt(b, position.x, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (damageData.cornerTRMat != null && DifferentAt(b, position.x + 1, position.z) && DifferentAt(b, position.x, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopRightCorner); } if (damageData.cornerBRMat != null && DifferentAt(b, position.x + 1, position.z) && DifferentAt(b, position.x, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotRightCorner); } if (damageData.cornerBLMat != null && DifferentAt(b, position.x - 1, position.z) && DifferentAt(b, position.x, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotLeftCorner); } } } else { GetCornerMats(out Material topLeft, out Material topRight, out Material botRight, out Material botLeft, b); if (topLeft != null) { availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (topRight != null) { availableOverlays.Add(DamageOverlay.TopRightCorner); } if (botLeft != null) { availableOverlays.Add(DamageOverlay.BotLeftCorner); } if (botRight != null) { availableOverlays.Add(DamageOverlay.BotRightCorner); } } return(availableOverlays); }
public static Rect GetDamageRect(Building b) { DamageGraphicData damageGraphicData = null; if (b.def.graphicData != null) { damageGraphicData = b.def.graphicData.damageData; } CellRect cellRect = b.OccupiedRect(); Rect result = new Rect((float)cellRect.minX, (float)cellRect.minZ, (float)cellRect.Width, (float)cellRect.Height); if (damageGraphicData != null) { if (b.Rotation == Rot4.North && damageGraphicData.rectN != default(Rect)) { result.position += damageGraphicData.rectN.position; result.size = damageGraphicData.rectN.size; } else if (b.Rotation == Rot4.East && damageGraphicData.rectE != default(Rect)) { result.position += damageGraphicData.rectE.position; result.size = damageGraphicData.rectE.size; } else if (b.Rotation == Rot4.South && damageGraphicData.rectS != default(Rect)) { result.position += damageGraphicData.rectS.position; result.size = damageGraphicData.rectS.size; } else if (b.Rotation == Rot4.West && damageGraphicData.rectW != default(Rect)) { result.position += damageGraphicData.rectW.position; result.size = damageGraphicData.rectW.size; } else if (damageGraphicData.rect != default(Rect)) { Rect rect = damageGraphicData.rect; if (b.Rotation == Rot4.North) { result.x += rect.x; result.y += rect.y; result.width = rect.width; result.height = rect.height; } else if (b.Rotation == Rot4.South) { result.x += (float)cellRect.Width - rect.x - rect.width; result.y += (float)cellRect.Height - rect.y - rect.height; result.width = rect.width; result.height = rect.height; } else if (b.Rotation == Rot4.West) { result.x += (float)cellRect.Width - rect.y - rect.height; result.y += rect.x; result.width = rect.height; result.height = rect.width; } else if (b.Rotation == Rot4.East) { result.x += rect.y; result.y += (float)cellRect.Height - rect.x - rect.width; result.width = rect.height; result.height = rect.width; } } } return(result); }
public static List <DamageOverlay> GetAvailableOverlays(Building b) { BuildingsDamageSectionLayerUtility.availableOverlays.Clear(); if (BuildingsDamageSectionLayerUtility.GetScratchMats(b).Any <Material>()) { int num = 3; Rect damageRect = BuildingsDamageSectionLayerUtility.GetDamageRect(b); float num2 = damageRect.width * damageRect.height; if (num2 > 4f) { num += Mathf.RoundToInt((num2 - 4f) * 0.54f); } for (int i = 0; i < num; i++) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.Scratch); } } if (BuildingsDamageSectionLayerUtility.UsesLinkableCornersAndEdges(b)) { if (b.def.graphicData != null && b.def.graphicData.damageData != null) { IntVec3 position = b.Position; DamageGraphicData damageData = b.def.graphicData.damageData; if (damageData.edgeTopMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1) && BuildingsDamageSectionLayerUtility.SameAndDamagedAt(b, position.x + 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z + 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopEdge); } if (damageData.edgeRightMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && BuildingsDamageSectionLayerUtility.SameAndDamagedAt(b, position.x, position.z + 1) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z + 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.RightEdge); } if (damageData.edgeBotMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1) && BuildingsDamageSectionLayerUtility.SameAndDamagedAt(b, position.x + 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z - 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotEdge); } if (damageData.edgeLeftMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && BuildingsDamageSectionLayerUtility.SameAndDamagedAt(b, position.x, position.z + 1) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z + 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.LeftEdge); } if (damageData.cornerTLMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (damageData.cornerTRMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopRightCorner); } if (damageData.cornerBRMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotRightCorner); } if (damageData.cornerBLMat != null && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && BuildingsDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1)) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotLeftCorner); } } } else { Material x; Material x2; Material x3; Material x4; BuildingsDamageSectionLayerUtility.GetCornerMats(out x, out x2, out x3, out x4, b); if (x != null) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (x2 != null) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopRightCorner); } if (x4 != null) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotLeftCorner); } if (x3 != null) { BuildingsDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotRightCorner); } } return(BuildingsDamageSectionLayerUtility.availableOverlays); }
private void DrawFullThingCorners(Building b) { if (b.def.graphicData != null) { DamageGraphicData damageData = b.def.graphicData.damageData; if (damageData != null) { Rect damageRect = BuildingsDamageSectionLayerUtility.GetDamageRect(b); float damageTexturesAltitude = GetDamageTexturesAltitude(b); float num = Mathf.Min(Mathf.Min(damageRect.width, damageRect.height), 1.5f); BuildingsDamageSectionLayerUtility.GetCornerMats(out Material topLeft, out Material topRight, out Material botRight, out Material botLeft, b); float num2 = num * Rand.Range(0.9f, 1f); float num3 = num * Rand.Range(0.9f, 1f); float num4 = num * Rand.Range(0.9f, 1f); float num5 = num * Rand.Range(0.9f, 1f); List <DamageOverlay> overlays = BuildingsDamageSectionLayerUtility.GetOverlays(b); for (int i = 0; i < overlays.Count; i++) { switch (overlays[i]) { case DamageOverlay.TopLeftCorner: { Rect rect4 = new Rect(damageRect.xMin, damageRect.yMax - num2, num2, num2); Vector2 center7 = rect4.center; float x4 = center7.x; float y4 = damageTexturesAltitude; Vector2 center8 = rect4.center; Printer_Plane.PrintPlane(this, new Vector3(x4, y4, center8.y), rect4.size, topLeft, 0f, flipUv: false, null, null, 0f); break; } case DamageOverlay.TopRightCorner: { Rect rect3 = new Rect(damageRect.xMax - num3, damageRect.yMax - num3, num3, num3); Vector2 center5 = rect3.center; float x3 = center5.x; float y3 = damageTexturesAltitude; Vector2 center6 = rect3.center; Printer_Plane.PrintPlane(this, new Vector3(x3, y3, center6.y), rect3.size, topRight, 90f, flipUv: false, null, null, 0f); break; } case DamageOverlay.BotRightCorner: { Rect rect2 = new Rect(damageRect.xMax - num4, damageRect.yMin, num4, num4); Vector2 center3 = rect2.center; float x2 = center3.x; float y2 = damageTexturesAltitude; Vector2 center4 = rect2.center; Printer_Plane.PrintPlane(this, new Vector3(x2, y2, center4.y), rect2.size, botRight, 180f, flipUv: false, null, null, 0f); break; } case DamageOverlay.BotLeftCorner: { Rect rect = new Rect(damageRect.xMin, damageRect.yMin, num5, num5); Vector2 center = rect.center; float x = center.x; float y = damageTexturesAltitude; Vector2 center2 = rect.center; Printer_Plane.PrintPlane(this, new Vector3(x, y, center2.y), rect.size, botLeft, 270f, flipUv: false, null, null, 0f); break; } } } } } }