Example #1
0
        private void DrawLinkableCornersAndEdges(Thing b)
        {
            if (b.def.graphicData == null)
            {
                return;
            }
            DamageGraphicData damageData = b.def.graphicData.damageData;

            if (damageData == null)
            {
                return;
            }
            float damageTexturesAltitude  = this.GetDamageTexturesAltitude(b);
            List <DamageOverlay> overlays = ThingsToxicDamageSectionLayerUtility.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.TopLeftCorner:
                    Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerTLMat, 0f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.TopRightCorner:
                    Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerTRMat, 90f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.BotLeftCorner:
                    Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerBLMat, 270f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.BotRightCorner:
                    Printer_Plane.PrintPlane(this, vector, Vector2.one, damageData.cornerBRMat, 180f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.LeftEdge:
                    Printer_Plane.PrintPlane(this, vector + new Vector3(0f, 0f, z2), Vector2.one, damageData.edgeLeftMat, 270f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.RightEdge:
                    Printer_Plane.PrintPlane(this, vector + new Vector3(0f, 0f, z), Vector2.one, damageData.edgeRightMat, 90f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.TopEdge:
                    Printer_Plane.PrintPlane(this, vector + new Vector3(x, 0f, 0f), Vector2.one, damageData.edgeTopMat, 0f, false, null, null, 0f, 0f);
                    break;

                case DamageOverlay.BotEdge:
                    Printer_Plane.PrintPlane(this, vector + new Vector3(x2, 0f, 0f), Vector2.one, damageData.edgeBotMat, 180f, false, null, null, 0f, 0f);
                    break;
                }
            }
        }
Example #2
0
        public static void GetCornerMats(out Material topLeft, out Material topRight, out Material botRight, out Material botLeft, Thing b)
        {
            if (b.def.graphicData == null || b.def.graphicData.damageData == null)
            {
                topLeft  = null;
                topRight = null;
                botRight = null;
                botLeft  = null;
                return;
            }
            DamageGraphicData damageData = b.def.graphicData.damageData;

            if (b.Rotation == Rot4.North)
            {
                topLeft  = damageData.cornerTLMat;
                topRight = damageData.cornerTRMat;
                botRight = damageData.cornerBRMat;
                botLeft  = damageData.cornerBLMat;
                return;
            }
            if (b.Rotation == Rot4.East)
            {
                topLeft  = damageData.cornerBLMat;
                topRight = damageData.cornerTLMat;
                botRight = damageData.cornerTRMat;
                botLeft  = damageData.cornerBRMat;
                return;
            }
            if (b.Rotation == Rot4.South)
            {
                topLeft  = damageData.cornerBRMat;
                topRight = damageData.cornerBLMat;
                botRight = damageData.cornerTLMat;
                botLeft  = damageData.cornerTRMat;
                return;
            }
            topLeft  = damageData.cornerTRMat;
            topRight = damageData.cornerBRMat;
            botRight = damageData.cornerBLMat;
            botLeft  = damageData.cornerTLMat;
        }
Example #3
0
 public DamageGraphicDataStats(DamageGraphicData d)
 {
     enabled   = d.enabled;
     rectN     = new RectStats(d.rectN);
     rectE     = new RectStats(d.rectE);
     rectS     = new RectStats(d.rectS);
     rectW     = new RectStats(d.rectW);
     rect      = new RectStats(d.rect);
     cornerTL  = d.cornerTL;
     cornerTR  = d.cornerTR;
     cornerBL  = d.cornerBL;
     cornerBR  = d.cornerBR;
     edgeLeft  = d.edgeLeft;
     edgeRight = d.edgeRight;
     edgeTop   = d.edgeTop;
     edgeBot   = d.edgeBot;
     if (d.scratches != null)
     {
         scratches = new List <string>();
         scratches.AddRange(d.scratches);
     }
 }
Example #4
0
 public void CopyFrom(AvaliGraphicData other)
 {
     this.texPath                   = other.texPath;
     this.graphicClass              = other.graphicClass;
     this.shaderType                = other.shaderType;
     this.color                     = other.color;
     this.colorTwo                  = other.colorTwo;
     this.colorThree                = other.colorThree;
     this.drawSize                  = other.drawSize;
     this.drawOffset                = other.drawOffset;
     this.drawOffsetNorth           = other.drawOffsetNorth;
     this.drawOffsetEast            = other.drawOffsetEast;
     this.drawOffsetSouth           = other.drawOffsetSouth;
     this.drawOffsetWest            = other.drawOffsetSouth;
     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;
     this.cachedGraphic             = (AvaliGraphic)null;
 }
Example #5
0
 public static List <DamageOverlay> GetAvailableOverlays(Thing b)
 {
     ThingsToxicDamageSectionLayerUtility.availableOverlays.Clear();
     if (ThingsToxicDamageSectionLayerUtility.GetScratchMats(b).Any <Material>())
     {
         int   num        = 3;
         Rect  damageRect = ThingsToxicDamageSectionLayerUtility.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++)
         {
             ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.Scratch);
         }
     }
     if (ThingsToxicDamageSectionLayerUtility.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 && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1) && ThingsToxicDamageSectionLayerUtility.SameAndDamagedAt(b, position.x + 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z + 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopEdge);
             }
             if (damageData.edgeRightMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && ThingsToxicDamageSectionLayerUtility.SameAndDamagedAt(b, position.x, position.z + 1) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z + 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.RightEdge);
             }
             if (damageData.edgeBotMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1) && ThingsToxicDamageSectionLayerUtility.SameAndDamagedAt(b, position.x + 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z - 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotEdge);
             }
             if (damageData.edgeLeftMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && ThingsToxicDamageSectionLayerUtility.SameAndDamagedAt(b, position.x, position.z + 1) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z + 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.LeftEdge);
             }
             if (damageData.cornerTLMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopLeftCorner);
             }
             if (damageData.cornerTRMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z + 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopRightCorner);
             }
             if (damageData.cornerBRMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x + 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotRightCorner);
             }
             if (damageData.cornerBLMat != null && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x - 1, position.z) && ThingsToxicDamageSectionLayerUtility.DifferentAt(b, position.x, position.z - 1))
             {
                 ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotLeftCorner);
             }
         }
     }
     else
     {
         Material x;
         Material x2;
         Material x3;
         Material x4;
         ThingsToxicDamageSectionLayerUtility.GetCornerMats(out x, out x2, out x3, out x4, b);
         if (x != null)
         {
             ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopLeftCorner);
         }
         if (x2 != null)
         {
             ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.TopRightCorner);
         }
         if (x4 != null)
         {
             ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotLeftCorner);
         }
         if (x3 != null)
         {
             ThingsToxicDamageSectionLayerUtility.availableOverlays.Add(DamageOverlay.BotRightCorner);
         }
     }
     return(ThingsToxicDamageSectionLayerUtility.availableOverlays);
 }
Example #6
0
        public static Rect GetDamageRect(Thing 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);
        }