コード例 #1
0
        // Token: 0x060000A9 RID: 169 RVA: 0x00008558 File Offset: 0x00006758
        public static List <MSRCPListItem> GetRCPList(ThingDef thingdef)
        {
            List <MSRCPListItem> list = new List <MSRCPListItem>();

            list.Clear();
            MSRCPListItem item = default;

            if (thingdef.defName == "Neutroamine")
            {
                item.def = DefDatabase <ThingDef> .GetNamed("MSGlycerol", true);

                item.mixgrp = 1;
                item.num    = 1;
                item.ratio  = 1f;
                list.Add(item);
                item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                item.mixgrp = 2;
                item.num    = 2;
                item.ratio  = 1f;
                list.Add(item);
            }
            else if (thingdef.defName == "MSGlycerol")
            {
                item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                item.mixgrp = 1;
                item.num    = 2;
                item.ratio  = 1f;
                list.Add(item);
                item.def = DefDatabase <ThingDef> .GetNamed("Beer", true);

                item.mixgrp = 2;
                item.num    = 1;
                item.ratio  = 1f;
                list.Add(item);
                item.def = DefDatabase <ThingDef> .GetNamed("MSEthanol", true);

                item.mixgrp = 2;
                item.num    = 1;
                item.ratio  = 1f;
                list.Add(item);
            }
            else
            {
                if (thingdef.defName == "MSLithiumSalts")
                {
                    item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                    item.mixgrp = 1;
                    item.num    = 5;
                    item.ratio  = 0.1f;
                    list.Add(item);
                    item.def = DefDatabase <ThingDef> .GetNamed("MSPhenol", true);

                    item.mixgrp = 2;
                    item.num    = 10;
                    item.ratio  = 0.2f;
                    list.Add(item);
                    item.def = DefDatabase <ThingDef> .GetNamed("MSSulphuricAcid", true);

                    item.mixgrp = 2;
                    item.num    = 10;
                    item.ratio  = 0.2f;
                    list.Add(item);
                    _ = new List <ThingDef>();
                    List <ThingDef> useChunkList;
                    if (MSDrugMixUtility.cachedChunkList.Count > 0)
                    {
                        useChunkList = MSDrugMixUtility.cachedChunkList;
                    }
                    else
                    {
                        useChunkList = MSDrugMixUtility.ChunkList();
                    }
                    if (useChunkList.Count <= 0)
                    {
                        return(list);
                    }
                    using (List <ThingDef> .Enumerator enumerator = useChunkList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ThingDef ChunkDef = enumerator.Current;
                            item.def    = ChunkDef;
                            item.mixed  = true;
                            item.mixgrp = 3;
                            item.num    = 1;
                            item.ratio  = 0.02f;
                            list.Add(item);
                        }
                        return(list);
                    }
                }
                if (thingdef.defName == "MSOpiumLatex")
                {
                    item.def = DefDatabase <ThingDef> .GetNamed("MSOPSeedPod", true);

                    item.mixgrp = 1;
                    item.num    = 2;
                    item.ratio  = 1f;
                    list.Add(item);
                }
                else if (thingdef.defName == "MSPhenol")
                {
                    item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                    item.mixgrp = 1;
                    item.num    = 3;
                    item.ratio  = 1f;
                    list.Add(item);
                }
                else
                {
                    if (thingdef.defName == "MSMercurySalts")
                    {
                        _ = new List <ThingDef>();
                        List <ThingDef> useChunkList2;
                        if (MSDrugMixUtility.cachedChunkList.Count > 0)
                        {
                            useChunkList2 = MSDrugMixUtility.cachedChunkList;
                        }
                        else
                        {
                            useChunkList2 = MSDrugMixUtility.ChunkList();
                        }
                        if (useChunkList2.Count <= 0)
                        {
                            return(list);
                        }
                        using (List <ThingDef> .Enumerator enumerator = useChunkList2.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                ThingDef ChunkDef2 = enumerator.Current;
                                item.def    = ChunkDef2;
                                item.mixgrp = 1;
                                item.num    = 1;
                                item.ratio  = 0.2f;
                                list.Add(item);
                            }
                            return(list);
                        }
                    }
                    if (thingdef.defName == "MSEthylMercury")
                    {
                        item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                        item.mixgrp = 1;
                        item.num    = 10;
                        item.ratio  = 1f;
                        list.Add(item);
                        item.def = DefDatabase <ThingDef> .GetNamed("MSMercurySalts", true);

                        item.mixed  = false;
                        item.mixgrp = 2;
                        item.num    = 5;
                        item.ratio  = 1f;
                        list.Add(item);
                    }
                    else
                    {
                        if (thingdef.defName == "MSSulphur")
                        {
                            _ = new List <ThingDef>();
                            List <ThingDef> useChunkList3;
                            if (MSDrugMixUtility.cachedChunkList.Count > 0)
                            {
                                useChunkList3 = MSDrugMixUtility.cachedChunkList;
                            }
                            else
                            {
                                useChunkList3 = MSDrugMixUtility.ChunkList();
                            }
                            if (useChunkList3.Count <= 0)
                            {
                                return(list);
                            }
                            using (List <ThingDef> .Enumerator enumerator = useChunkList3.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    ThingDef ChunkDef3 = enumerator.Current;
                                    item.def    = ChunkDef3;
                                    item.mixgrp = 1;
                                    item.num    = 1;
                                    item.ratio  = 0.02f;
                                    list.Add(item);
                                }
                                return(list);
                            }
                        }
                        if (thingdef.defName == "MSSulphuricAcid")
                        {
                            item.def = DefDatabase <ThingDef> .GetNamed("MSSulphur", true);

                            item.mixgrp = 1;
                            item.num    = 3;
                            item.ratio  = 1f;
                            list.Add(item);
                        }
                        else if (thingdef.defName == "MSEthanol")
                        {
                            item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                            item.mixgrp = 1;
                            item.num    = 2;
                            item.ratio  = 1f;
                            list.Add(item);
                            item.def = DefDatabase <ThingDef> .GetNamed("MSSulphuricAcid", true);

                            item.mixgrp = 2;
                            item.num    = 1;
                            item.ratio  = 1f;
                            list.Add(item);
                        }
                        else if (thingdef.defName == "MSHydrogenPeroxide")
                        {
                            item.def = DefDatabase <ThingDef> .GetNamed("Chemfuel", true);

                            item.mixgrp = 1;
                            item.num    = 1;
                            item.ratio  = 1f;
                            list.Add(item);
                            item.def = DefDatabase <ThingDef> .GetNamed("Neutroamine", true);

                            item.mixgrp = 2;
                            item.num    = 1;
                            item.ratio  = 0.2f;
                            list.Add(item);
                            item.def = DefDatabase <ThingDef> .GetNamed("MSSulphuricAcid", true);

                            item.mixgrp = 3;
                            item.num    = 1;
                            item.ratio  = 0.2f;
                            list.Add(item);
                        }
                        else if (thingdef.defName == "MSVincaAlkaloid")
                        {
                            item.def = DefDatabase <ThingDef> .GetNamed("MSPerrywinkleLeaves", true);

                            item.mixgrp = 1;
                            item.num    = 1;
                            item.ratio  = 5f;
                            list.Add(item);
                            item.def = DefDatabase <ThingDef> .GetNamed("MSPhenol", true);

                            item.mixgrp = 2;
                            item.num    = 1;
                            item.ratio  = 0.2f;
                            list.Add(item);
                        }
                        else if (thingdef.defName == "MSHydrochloricAcid")
                        {
                            _ = new List <ThingDef>();
                            List <ThingDef> useChunkList4;
                            if (MSDrugMixUtility.cachedChunkList.Count > 0)
                            {
                                useChunkList4 = MSDrugMixUtility.cachedChunkList;
                            }
                            else
                            {
                                useChunkList4 = MSDrugMixUtility.ChunkList();
                            }
                            if (useChunkList4.Count > 0)
                            {
                                foreach (ThingDef ChunkDef4 in useChunkList4)
                                {
                                    item.def    = ChunkDef4;
                                    item.mixed  = true;
                                    item.mixgrp = 1;
                                    item.num    = 1;
                                    item.ratio  = 0.1f;
                                    list.Add(item);
                                }
                            }
                            item.def = DefDatabase <ThingDef> .GetNamed("MSSulphuricAcid", true);

                            item.mixgrp = 2;
                            item.num    = 5;
                            item.ratio  = 1f;
                            list.Add(item);
                        }
                    }
                }
            }
            return(list);
        }
コード例 #2
0
        // Token: 0x0600008E RID: 142 RVA: 0x00007A9C File Offset: 0x00005C9C
        private static void DoNotFoundGroupsOverlay(Building_MSDrugMix b, ThingDef def, int grp)
        {
            if (Find.CurrentMap == null || Find.CurrentMap != b.Map)
            {
                return;
            }

            var listRCP = MSDrugMixUtility.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++;
            }
        }
コード例 #3
0
        // Token: 0x0600008F RID: 143 RVA: 0x00007CD8 File Offset: 0x00005ED8
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (var gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }

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

            string SelectDesc = "MSDrugMix.ChemSelectDesc".Translate();

            if (MixerThingDef == null)
            {
                string NoChem = "MSDrugMix.ChemSelect".Translate();
                yield return(new Command_Action
                {
                    defaultLabel = NoChem,
                    icon = ContentFinder <Texture2D> .Get(chemicalTexPath),
                    defaultDesc = SelectDesc,
                    action = MSMixerSelectChem
                });
            }
            else
            {
                var IconToUse   = MSDrugMixUtility.GetMSMixIcon(MixerThingDef);
                var LabelDetail = MixerThingDef.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 = MSMixerSelectChem
                });
            }

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

            if (isProducing)
            {
                if (MixerThingDef != null)
                {
                    if (MSDrugMixUtility.RCPProdValues(MixerThingDef, out _, out var minProd,
                                                       out var maxProd, out _))
                    {
                        LabelProduce +=
                            "MSDrugMix.ProdLabelRange".Translate(minProd.ToString(), maxProd.ToString());
                    }
                    else
                    {
                        LabelProduce += "MSDrugMix.ProdLabelERR".Translate();
                    }
                }
                else
                {
                    LabelProduce += "MSDrugMix.ProdNoChem".Translate();
                }
            }
コード例 #4
0
        // Token: 0x0600008D RID: 141 RVA: 0x00007594 File Offset: 0x00005794
        private 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 (!MSDrugMixUtility.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("MSDrugMix.ErrorRes".Translate(MixerThingDef.label));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }
                else
                {
                    Log.Message("MSDrugMix.ErrorRCP".Translate(MixerThingDef.label, ticks.ToString(),
                                                               minProd.ToString(), maxProd.ToString()));
                    isProducing        = false;
                    NumProd            = 0;
                    ProdWorkTicks      = 0;
                    TotalProdWorkTicks = 0;
                }

                return(false);
            }

            var listRCP = MSDrugMixUtility.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 listItem in listRCP)
            {
                var MaterialsMin    = 0;
                var MaterialsMax    = 0;
                var RCPItem         = listItem;
                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)
                    {
                        RCPItemCanUse bestthingsofar = default;
                        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);
        }