Exemplo n.º 1
0
        // Token: 0x06000088 RID: 136 RVA: 0x00005768 File Offset: 0x00003968
        public static void DoNotFoundGroupsOverlay(Building_RPThingMaker b, ThingDef def, int grp)
        {
            if (Find.CurrentMap == null || Find.CurrentMap != b.Map)
            {
                return;
            }

            var listRCP = RPThingMakerUtility.GetRCPList(def);
            var alerts  = new List <ThingDef>();

            if (listRCP.Count > 0)
            {
                foreach (var item in listRCP)
                {
                    if (item.mixgrp == grp)
                    {
                        alerts.AddDistinct(item.def);
                    }
                }
            }

            if (alerts.Count <= 0)
            {
                return;
            }

            var OutOfFuelMat = MaterialPool.MatFrom("UI/Overlays/OutOfFuel", ShaderDatabase.MetaOverlay);
            var i            = 0;

            foreach (var alert in alerts)
            {
                if (!alert.defName.StartsWith("Chunk") || alert.defName.StartsWith("Chunk") && i < 1)
                {
                    var mat     = MaterialPool.MatFrom(alert.uiIcon, ShaderDatabase.MetaOverlay, Color.white);
                    var BaseAlt = AltitudeLayer.WorldClipper.AltitudeFor();
                    if (mat != null)
                    {
                        var altInd  = 21;
                        var plane   = MeshPool.plane08;
                        var drawPos = b.TrueCenter();
                        drawPos.y  = BaseAlt + (0.046875f * altInd);
                        drawPos.x += i;
                        drawPos.z += grp - 2;
                        var num2 = ((float)Math.Sin(
                                        (Time.realtimeSinceStartup + (397f * (b.thingIDNumber % 571))) * 4f) + 1f) * 0.5f;
                        num2 = 0.3f + (num2 * 0.7f);
                        for (var j = 0; j < 2; j++)
                        {
                            var material = FadedMaterialPool.FadedVersionOf(j < 1 ? mat : OutOfFuelMat, num2);

                            if (material != null)
                            {
                                Graphics.DrawMesh(plane, drawPos, Quaternion.identity, material, 0);
                            }
                        }
                    }
                }

                i++;
            }
        }
Exemplo n.º 2
0
        // Token: 0x06000089 RID: 137 RVA: 0x000059A4 File Offset: 0x00003BA4
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (var gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }

            if (Faction != Faction.OfPlayer)
            {
                yield break;
            }

            string SelectDesc = "RPThingMaker.ThingSelectDesc".Translate();

            if (MakerThingDef == null)
            {
                string NoChem = "RPThingMaker.ThingSelect".Translate();
                yield return(new Command_Action
                {
                    defaultLabel = NoChem,
                    icon = ContentFinder <Texture2D> .Get(thingTexPath),
                    defaultDesc = SelectDesc,
                    action = RPMakerSelectThing
                });
            }
            else
            {
                var IconToUse   = RPThingMakerUtility.GetRPThingIcon(MakerThingDef);
                var LabelDetail = MakerThingDef.label.CapitalizeFirst();
                LabelDetail = string.Concat(LabelDetail, " [", NumProd, "] ");
                if (TotalProdWorkTicks > 0)
                {
                    LabelDetail = LabelDetail + " (" +
                                  (int)((TotalProdWorkTicks - ProdWorkTicks) / (float)TotalProdWorkTicks * 100f) +
                                  "%)";
                }

                yield return(new Command_Action
                {
                    defaultLabel = LabelDetail,
                    icon = IconToUse,
                    defaultDesc = SelectDesc,
                    action = RPMakerSelectThing
                });
            }

            string LabelProduce     = "RPThingMaker.Production".Translate();
            string LabelProduceDesc = "RPThingMaker.ProductionDesc".Translate();

            if (isProducing)
            {
                if (MakerThingDef != null)
                {
                    if (RPThingMakerUtility.RCPProdValues(MakerThingDef, out _, out var minProd, out var maxProd,
                                                          out _))
                    {
                        LabelProduce +=
                            "RPThingMaker.ProdLabelRange".Translate(minProd.ToString(), maxProd.ToString());
                    }
                    else
                    {
                        LabelProduce += "RPThingMaker.ProdLabelERR".Translate();
                    }
                }
                else
                {
                    LabelProduce += "RPThingMaker.ProdNoThing".Translate();
                }
            }
Exemplo n.º 3
0
        // Token: 0x06000087 RID: 135 RVA: 0x00005260 File Offset: 0x00003460
        public bool ValidateRecipe(ThingDef t, out bool CanUseMax, out List <RCPItemCanUse> FinalList, out int MinProd,
                                   out int MaxProd, out int Ticks)
        {
            CanUseMax = true;
            FinalList = null;
            MinProd   = 0;
            MaxProd   = 0;
            Ticks     = 0;
            if (debug && Find.TickManager.TicksGame % 100 == 0)
            {
                Log.Message("ValRep: " + t.defName);
            }

            if (!RPThingMakerUtility.RCPProdValues(t, out var ticks, out var minProd, out var maxProd, out var Res))
            {
                return(false);
            }

            Ticks   = ticks;
            MinProd = minProd;
            MaxProd = maxProd;
            if (debug)
            {
                Log.Message(
                    string.Concat("RCPVals: Ticks: ", ticks.ToString(), " minProd: ", minProd.ToString(), " maxProd: ",
                                  maxProd.ToString(), " Res: ", Res));
            }

            if (!ResearchProjectDef.Named(Res).IsFinished || minProd <= 0 || maxProd <= 0 || ticks <= 0)
            {
                if (!ResearchProjectDef.Named(Res).IsFinished)
                {
                    Log.Message("RPThingMaker.ErrorRes".Translate(MakerThingDef.label));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }
                else
                {
                    Log.Message(
                        "RPThingMaker.ErrorRCP".Translate(MakerThingDef.label, ticks.ToString(), minProd.ToString(),
                                                          maxProd.ToString()));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }

                return(false);
            }

            var listRCP = RPThingMakerUtility.GetRCPList(t);

            if (listRCP.Count <= 0)
            {
                if (debug)
                {
                    Log.Message("RCP is False.");
                }

                return(false);
            }

            if (debug)
            {
                Log.Message("RCP Listings: " + listRCP.Count);
            }

            var RCPListPotentials = new List <RCPItemCanUse>();
            var RCPGroups         = new List <int>();

            foreach (var rprcpListItem in listRCP)
            {
                var MaterialsMin    = 0;
                var MaterialsMax    = 0;
                var RCPItem         = rprcpListItem;
                var RCPMinNumNeeded = (int)Math.Round(RCPItem.num * minProd * RCPItem.ratio);
                var RCPMaxNumNeeded = (int)Math.Round(RCPItem.num * maxProd * RCPItem.ratio);
                if (HasEnoughMaterialInHoppers(RCPItem.def, RCPMinNumNeeded, true))
                {
                    MaterialsMin = RCPMinNumNeeded;
                }

                if (HasEnoughMaterialInHoppers(RCPItem.def, RCPMaxNumNeeded, false))
                {
                    MaterialsMax = RCPMaxNumNeeded;
                }

                if (MaterialsMin > 0 || MaterialsMax > 0)
                {
                    RCPListPotentials.Add(new RCPItemCanUse
                    {
                        def = RCPItem.def,
                        Min = MaterialsMin,
                        Max = MaterialsMax,
                        Grp = RCPItem.mixgrp
                    });
                }

                if (!RCPGroups.Contains(RCPItem.mixgrp))
                {
                    RCPGroups.Add(RCPItem.mixgrp);
                }
            }

            if (debug)
            {
                Log.Message(
                    "InnerRecipe List: Groups: " + RCPGroups.Count + " , Potentials: " + RCPListPotentials.Count);
            }

            FinalList = new List <RCPItemCanUse>();
            var NotAllGroups = false;

            if (RCPGroups.Count > 0)
            {
                foreach (var grp in RCPGroups)
                {
                    var foundGroup = false;
                    if (RCPListPotentials.Count > 0)
                    {
                        var bestthingsofar = default(RCPItemCanUse);
                        var best           = false;
                        var bestmax        = false;
                        foreach (var itemchk in RCPListPotentials)
                        {
                            if (itemchk.Grp != grp)
                            {
                                continue;
                            }

                            foundGroup = true;
                            if (itemchk.Min <= 0)
                            {
                                continue;
                            }

                            if (itemchk.Max > 0)
                            {
                                if (bestmax)
                                {
                                    continue;
                                }

                                bestthingsofar.def = itemchk.def;
                                bestthingsofar.Min = itemchk.Min;
                                bestthingsofar.Max = itemchk.Max;
                                bestthingsofar.Grp = itemchk.Grp;
                                best    = true;
                                bestmax = true;
                            }
                            else if (!best)
                            {
                                bestthingsofar.def = itemchk.def;
                                bestthingsofar.Min = itemchk.Min;
                                bestthingsofar.Max = itemchk.Max;
                                bestthingsofar.Grp = itemchk.Grp;
                                best = true;
                            }
                        }

                        if (!bestmax)
                        {
                            bestthingsofar.Max = 0;
                        }

                        FinalList.Add(bestthingsofar);
                    }

                    if (foundGroup)
                    {
                        continue;
                    }

                    NotAllGroups = true;
                    DoNotFoundGroupsOverlay(this, t, grp);
                }
            }

            if (FinalList.Count > 0)
            {
                for (var l = 0; l < FinalList.Count; l++)
                {
                    if (FinalList[l].Max == 0)
                    {
                        CanUseMax = false;
                    }
                }
            }

            if (NotAllGroups)
            {
                if (debug)
                {
                    Log.Message("RCP is False. Not all inputs found");
                }

                return(false);
            }

            if (debug)
            {
                Log.Message("RCP is True. with (" + FinalList.Count + ") final list items");
            }

            return(true);
        }