Beispiel #1
0
 public static void DrawInteractionCell(ThingDef tDef, IntVec3 center, Rot4 placingRot)
 {
     if (tDef.hasInteractionCell)
     {
         IntVec3 c      = ThingUtility.InteractionCellWhenAt(tDef, center, placingRot, Find.CurrentMap);
         Vector3 vector = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays);
         if (c.InBounds(Find.CurrentMap))
         {
             Building edifice = c.GetEdifice(Find.CurrentMap);
             if (edifice != null && edifice.def.building != null && edifice.def.building.isSittable)
             {
                 return;
             }
         }
         if (tDef.interactionCellGraphic == null && tDef.interactionCellIcon != null)
         {
             ThingDef thingDef = tDef.interactionCellIcon;
             if (thingDef.blueprintDef != null)
             {
                 thingDef = thingDef.blueprintDef;
             }
             tDef.interactionCellGraphic = thingDef.graphic.GetColoredVersion(ShaderTypeDefOf.EdgeDetect.Shader, InteractionCellIntensity, Color.white);
         }
         if (tDef.interactionCellGraphic != null)
         {
             Rot4 rot = (!tDef.interactionCellIconReverse) ? placingRot : placingRot.Opposite;
             tDef.interactionCellGraphic.DrawFromDef(vector, rot, tDef.interactionCellIcon);
         }
         else
         {
             Graphics.DrawMesh(MeshPool.plane10, vector, Quaternion.identity, InteractionCellMaterial, 0);
         }
     }
 }
Beispiel #2
0
 public static void RenderCell(IntVec3 c, Material mat)
 {
     InitFrame();
     if (viewRect.Contains(c))
     {
         Vector3 position = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays);
         Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, mat, 0);
     }
 }
Beispiel #3
0
        public static Vector2 LabelDrawPosFor(IntVec3 center)
        {
            Vector3 position = center.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays);
            Vector2 result   = Find.Camera.WorldToScreenPoint(position) / Prefs.UIScale;

            result.y  = (float)UI.screenHeight - result.y;
            result.y -= 1f;
            return(result);
        }
Beispiel #4
0
        public static void DrawFieldEdges(List <IntVec3> cells, Color color)
        {
            Map             currentMap = Find.CurrentMap;
            MaterialRequest req        = default(MaterialRequest);

            req.shader      = ShaderDatabase.Transparent;
            req.color       = color;
            req.BaseTexPath = "UI/Overlays/TargetHighlight_Side";
            Material material = MaterialPool.MatFrom(req);

            material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp;
            if (fieldGrid == null)
            {
                fieldGrid = new BoolGrid(currentMap);
            }
            else
            {
                fieldGrid.ClearAndResizeTo(currentMap);
            }
            IntVec3 size  = currentMap.Size;
            int     x     = size.x;
            IntVec3 size2 = currentMap.Size;
            int     z     = size2.z;
            int     count = cells.Count;

            for (int i = 0; i < count; i++)
            {
                if (cells[i].InBounds(currentMap))
                {
                    BoolGrid boolGrid = fieldGrid;
                    IntVec3  intVec   = cells[i];
                    int      x2       = intVec.x;
                    IntVec3  intVec2  = cells[i];
                    boolGrid[x2, intVec2.z] = true;
                }
            }
            for (int j = 0; j < count; j++)
            {
                IntVec3 c = cells[j];
                if (c.InBounds(currentMap))
                {
                    rotNeeded[0] = (c.z < z - 1 && !fieldGrid[c.x, c.z + 1]);
                    rotNeeded[1] = (c.x < x - 1 && !fieldGrid[c.x + 1, c.z]);
                    rotNeeded[2] = (c.z > 0 && !fieldGrid[c.x, c.z - 1]);
                    rotNeeded[3] = (c.x > 0 && !fieldGrid[c.x - 1, c.z]);
                    for (int k = 0; k < 4; k++)
                    {
                        if (rotNeeded[k])
                        {
                            Graphics.DrawMesh(MeshPool.plane10, c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), new Rot4(k).AsQuat, material, 0);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public static void DrawFieldEdges(List <IntVec3> cells, Color color)
        {
            Map      visibleMap = Find.VisibleMap;
            Material material   = MaterialPool.MatFrom(new MaterialRequest
            {
                shader      = ShaderDatabase.Transparent,
                color       = color,
                BaseTexPath = "UI/Overlays/TargetHighlight_Side"
            });

            material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp;
            if (GenDraw.fieldGrid == null)
            {
                GenDraw.fieldGrid = new BoolGrid(visibleMap);
            }
            else
            {
                GenDraw.fieldGrid.ClearAndResizeTo(visibleMap);
            }
            int x     = visibleMap.Size.x;
            int z     = visibleMap.Size.z;
            int count = cells.Count;

            for (int i = 0; i < count; i++)
            {
                if (cells[i].InBounds(visibleMap))
                {
                    GenDraw.fieldGrid[cells[i].x, cells[i].z] = true;
                }
            }
            for (int j = 0; j < count; j++)
            {
                IntVec3 c = cells[j];
                if (c.InBounds(visibleMap))
                {
                    GenDraw.rotNeeded[0] = (c.z < z - 1 && !GenDraw.fieldGrid[c.x, c.z + 1]);
                    GenDraw.rotNeeded[1] = (c.x < x - 1 && !GenDraw.fieldGrid[c.x + 1, c.z]);
                    GenDraw.rotNeeded[2] = (c.z > 0 && !GenDraw.fieldGrid[c.x, c.z - 1]);
                    GenDraw.rotNeeded[3] = (c.x > 0 && !GenDraw.fieldGrid[c.x - 1, c.z]);
                    for (int k = 0; k < 4; k++)
                    {
                        if (GenDraw.rotNeeded[k])
                        {
                            Mesh    arg_219_0 = MeshPool.plane10;
                            Vector3 arg_219_1 = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays);
                            Rot4    rot       = new Rot4(k);
                            Graphics.DrawMesh(arg_219_0, arg_219_1, rot.AsQuat, material, 0);
                        }
                    }
                }
            }
        }
Beispiel #6
0
 public void DebugDrawDestinations()
 {
     foreach (PawnDestinationReservationManager.PawnDestinationReservation current in this.reservedDestinations[Faction.OfPlayer].list)
     {
         if (!(current.claimant.Position == current.target))
         {
             IntVec3   target = current.target;
             Vector3   s      = new Vector3(1f, 1f, 1f);
             Matrix4x4 matrix = default(Matrix4x4);
             matrix.SetTRS(target.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), Quaternion.identity, s);
             Graphics.DrawMesh(MeshPool.plane10, matrix, PawnDestinationReservationManager.DestinationMat, 0);
             if (Find.Selector.IsSelected(current.claimant))
             {
                 Graphics.DrawMesh(MeshPool.plane10, matrix, PawnDestinationReservationManager.DestinationSelectionMat, 0);
             }
         }
     }
 }
 public void DebugDrawReservations()
 {
     foreach (KeyValuePair <Faction, PawnDestinationSet> reservedDestination in reservedDestinations)
     {
         foreach (PawnDestinationReservation item in reservedDestination.Value.list)
         {
             IntVec3 target = item.target;
             MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
             materialPropertyBlock.SetColor("_Color", reservedDestination.Key.Color);
             Vector3   s      = new Vector3(1f, 1f, 1f);
             Matrix4x4 matrix = default(Matrix4x4);
             matrix.SetTRS(target.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), Quaternion.identity, s);
             Graphics.DrawMesh(MeshPool.plane10, matrix, DestinationMat, 0, Camera.main, 0, materialPropertyBlock);
             if (Find.Selector.IsSelected(item.claimant))
             {
                 Graphics.DrawMesh(MeshPool.plane10, matrix, DestinationSelectionMat, 0);
             }
         }
     }
 }
Beispiel #8
0
        private static void DrawTargetingHighlight_Cell(IntVec3 c)
        {
            Vector3 position = c.ToVector3ShiftedWithAltitude(AltitudeLayer.Building);

            Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, GenDraw.CurTargetingMat, 0);
        }
Beispiel #9
0
        public static void DrawTargetHighlightWithLayer(IntVec3 c, AltitudeLayer layer)
        {
            Vector3 position = c.ToVector3ShiftedWithAltitude(layer);

            Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, CurTargetingMat, 0);
        }
Beispiel #10
0
        public static Vector3 TrueCenter(IntVec3 loc, Rot4 rotation, IntVec2 thingSize, float altitude)
        {
            Vector3 result = loc.ToVector3ShiftedWithAltitude(altitude);

            if (thingSize.x != 1 || thingSize.z != 1)
            {
                if (rotation.IsHorizontal)
                {
                    int x = thingSize.x;
                    thingSize.x = thingSize.z;
                    thingSize.z = x;
                }
                switch (rotation.AsInt)
                {
                case 0:
                    if (thingSize.x % 2 == 0)
                    {
                        result.x += 0.5f;
                    }
                    if (thingSize.z % 2 == 0)
                    {
                        result.z += 0.5f;
                    }
                    break;

                case 1:
                    if (thingSize.x % 2 == 0)
                    {
                        result.x += 0.5f;
                    }
                    if (thingSize.z % 2 == 0)
                    {
                        result.z -= 0.5f;
                    }
                    break;

                case 2:
                    if (thingSize.x % 2 == 0)
                    {
                        result.x -= 0.5f;
                    }
                    if (thingSize.z % 2 == 0)
                    {
                        result.z -= 0.5f;
                    }
                    break;

                case 3:
                    if (thingSize.x % 2 == 0)
                    {
                        result.x -= 0.5f;
                    }
                    if (thingSize.z % 2 == 0)
                    {
                        result.z += 0.5f;
                    }
                    break;
                }
            }
            return(result);
        }