예제 #1
0
        private ESItem GetWeapon(ThingDef _WeaponType, ThingDef _Stuff)
        {
            ESItem ESI = null;
            float  floStuffBasePrice = _Stuff.BaseMarketValue;

            if (_WeaponType.stuffCategories != null && _Stuff.stuffProps.CanMake(_WeaponType))
            {
                float price = _WeaponType.BaseMarketValue + ((float)_WeaponType.costStuffCount * floStuffBasePrice);
                //Log.Message(_Stuff.defName);
                ESI = new ESItem(_WeaponType.defName, 1, price, 1, _Stuff.defName);
            }
            else if (_WeaponType.costList != null)
            {
                foreach (ThingCountClass tcc in _WeaponType.costList)
                {
                    if (_Stuff.defName == tcc.thingDef.defName)
                    {
                        float price = _WeaponType.BaseMarketValue + ((float)tcc.count * floStuffBasePrice);
                        ESI = new ESItem(_WeaponType.defName, 1, price);
                    }
                    else
                    {
                        //Log.Message(string.Concat("ESWeapons.GetWeapon: ", _Stuff.defName, " can NOT make ", _WeaponType.defName, " AND is not on it's costList."));
                        ESI = null;
                    }
                }
            }
            else
            {
                //Log.Message(string.Concat("ESWeapons.GetWeapon: ", _Stuff.defName, " can NOT make ", _WeaponType.defName));
                ESI = null;
            }

            return(ESI);
        }
예제 #2
0
        private ESItem[] GetItems(ThingDef _ItemType, BiomeDef _biome)
        {
            // Variables
            ESItem[] aESI         = new ESItem[0];
            string   strThingDef  = _ItemType.defName;
            float    floBasePrice = _ItemType.BaseMarketValue;
            int      intAmount    = 0;

            switch (strThingDef)
            {
            case "HerbalMedicine":
                intAmount    = 3;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            case "Beer":
                intAmount    = 3;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            case "Ambrosia":
                intAmount    = 1;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            default:
                intAmount    = 1;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;
            }

            aESI = aESI.Concat(new ESItem[] { new ESItem(_ItemType.defName, intAmount, floBasePrice * intAmount) }).ToArray();

            return(aESI);
        }
예제 #3
0
        public void UnequipESItem(ref ESItem _item)
        {
            floTotalItemsPrice -= SubtractPrice(_item);
            ESItem esi;

            if (_item.stuff == null)
            {
                esi = new ESItem(_item.thingDef.ToString(), _item.thingAmount, _item.basePrice)
                {
                    price = _item.price
                };
            }
            else
            {
                esi = new ESItem(_item.thingDef.ToString(), _item.thingAmount, _item.basePrice, 1, _item.stuff.ToString())
                {
                    price = _item.price
                };
            }

            ESItem esiCur = ESStartingItems.aStartingItems.FirstOrDefault(x => x.thing.Label == esi.thing.Label);

            esiCur.DecrementItem(esi);

            _item.price = SubtractPrice(_item);

            if (esiCur.thingAmountTotal <= 0)
            {
                List <ESItem> lstESItem = ESStartingItems.aStartingItems.ToList();
                lstESItem.RemoveAt(ESStartingItems.aStartingItems.FirstIndexOf(x => x.thing.Label == esi.thing.Label));
                ESStartingItems.aStartingItems = lstESItem.ToArray();
            }
        }
예제 #4
0
        public void EquipESItem(ESItem _item)
        {
            floTotalItemsPrice += GetPrice(_item);

            ESItem esi;

            if (_item.stuff == null)
            {
                esi = new ESItem(_item.thingDef.ToString(), _item.thingAmount, _item.basePrice);
            }
            else
            {
                esi = new ESItem(_item.thingDef.ToString(), _item.thingAmount, _item.basePrice, 1, _item.stuff.ToString());
            }

            if (ESStartingItems.aStartingItems.Any(x => x.thing.Label == esi.thing.Label))
            {
                ESStartingItems.aStartingItems.FirstOrDefault(x => x.thingDef == esi.thingDef).IncrementItem(esi.thingAmount, esi.itemAmount, GetPrice(esi), GetPrice(esi));
            }
            else
            {
                ESItem[] aesi = { esi };
                ESStartingItems.aStartingItems = ESStartingItems.aStartingItems.Concat(aesi).ToArray();
            }
        }
예제 #5
0
        private void DoEquipButton()
        {
            // Shape the button
            Rect rectEqiupButton = new Rect(rectCard.width * .4f, rectCard.height * .1f, rectCard.width * .2f, rectCard.height * .1f);

            // Draw the button
            if (Widgets.ButtonText(KrozzyUtilities.RectAddition(rectEqiupButton, rectCard), "Equip", true, true, true))
            {
                // Method to add the item to the starting items list
                ES.EquipESItem(esItemCurSelectedToEquip);

                if (esItemCurSelectedToUnequip == null)
                {
                    esItemCurSelectedToUnequip = ESStartingItems.aStartingItems[intCurSelectedToUnequip];
                }
            }
        }
예제 #6
0
        private ESItem[] GetWeapons(ThingDef _WeaponType)
        {
            // Variables
            ESItem[] aESI        = new ESItem[0];
            string   strThingDef = _WeaponType.defName;

            foreach (ThingDef td in aWeaponStuff)
            {
                ESItem ESI = GetWeapon(_WeaponType, td);
                if (ESI != null)
                {
                    aESI = aESI.Concat(new ESItem[] { ESI }).ToArray();
                }
            }


            return(aESI);
        }
예제 #7
0
        public float SubtractPrice(ESItem _item)
        {
            float floPrice      = _item.basePrice;
            int   intItemCount  = 0;
            int   intThingCount = 0;

            if (ESStartingItems.aStartingItems.Any(x => x.thing.Label == _item.thing.Label))
            {
                intItemCount  = ESStartingItems.aStartingItems.FirstOrDefault(x => x.thing.Label == _item.thing.Label).itemAmount - 1;
                intThingCount = ESStartingItems.aStartingItems.FirstOrDefault(x => x.thing.Label == _item.thing.Label).thingAmount;
            }

            for (int i = 0; i < intItemCount; i++)
            {
                floPrice = floPrice * floMultiTax;
            }

            return(floPrice);
        }
예제 #8
0
        private ESItem[] GetItems(ThingDef _ItemType, BiomeDef _biome)
        {
            // Variables
            ESItem[] aESI         = new ESItem[0];
            string   strThingDef  = _ItemType.defName;
            float    floBasePrice = _ItemType.BaseMarketValue;
            int      intAmount    = 0;

            switch (strThingDef)
            {
            case "WoodLog":
                intAmount    = 10;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            case "RawHops":
                intAmount    = 10;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            case "PsychoidLeaves":
                intAmount    = 10;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            case "SmokeleafLeaves":
                intAmount    = 10;
                floBasePrice = floBasePrice * GetPlantPriceInflate(_biome);
                break;

            default:
                intAmount = 10;
                break;
            }

            aESI = aESI.Concat(new ESItem[] { new ESItem(_ItemType.defName, intAmount, floBasePrice * intAmount) }).ToArray();

            return(aESI);
        }
예제 #9
0
        private ESItem[] GetItems(ThingDef _ItemType)
        {
            // Variables
            ESItem[] aESI         = new ESItem[0];
            string   strThingDef  = _ItemType.defName;
            float    floBasePrice = _ItemType.BaseMarketValue;

            int intAmount = 0;

            switch (strThingDef)
            {
            case "Wort":
                intAmount = 5;
                break;

            default:
                intAmount = 1;
                break;
            }

            aESI = aESI.Concat(new ESItem[] { new ESItem(_ItemType.defName, intAmount, floBasePrice * intAmount) }).ToArray();

            return(aESI);
        }
예제 #10
0
        private void DoStartingItems()
        {
            // Calculate variables
            float floMenuHeight = rectCard.height * .8f;

            ESItem[] esiStartingItems = ESStartingItems.aStartingItems;

            // Shape the menu section
            Rect rectMenuSection = new Rect(rectCard.width * .625f, rectCard.height * .1f, rectCard.width * .3f, floMenuHeight);
            Rect rectOut         = KrozzyUtilities.RectAddition(rectMenuSection, rectCard);

            // Draw the menu section
            GUI.DrawTexture(rectOut, ProTBin.texVellum, ScaleMode.ScaleAndCrop);
            GUI.color = cintBorder.ToColor;
            Widgets.DrawBox(rectOut, 1);
            GUI.color = Color.white; // set GUI color back to default

            // Shape item sheet
            float floViewWidth           = rectMenuSection.width - 16f; // Scrollbar has 16f hard number
            float floColumnTexWidth      = floViewWidth * .1f;
            float floColumnNameWidth     = floViewWidth * .6f;
            float floColumnQuantityWidth = floViewWidth * .12f;
            float floColumnCostWidth     = floViewWidth * .18f;

            Text.Font = GameFont.Small; // Make sure the font is default for size calculation
            float TotalHeight = 0f;

            // Create strings for headers
            string strItemNameHeader   = "Item";
            string strItemAmountHeader = "#";
            string strItemPriceHeader  = "Cost";

            // Calculate header heights
            float floHeaderHeight = Text.CalcHeight(strItemNameHeader, floColumnNameWidth);

            // Shape the headers
            Rect rectItemNameHeader   = new Rect(rectOut.x + floColumnTexWidth, rectOut.y, floColumnNameWidth, floHeaderHeight);
            Rect rectItemAmountHeader = new Rect(rectOut.x + floColumnTexWidth + floColumnNameWidth, rectOut.y, floColumnQuantityWidth, floHeaderHeight);
            Rect rectItemPriceHeader  = new Rect(rectOut.x + floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, rectOut.y, floColumnCostWidth, floHeaderHeight);

            // Draw the headers
            GUI.Label(rectItemNameHeader, strItemNameHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));
            GUI.Label(rectItemAmountHeader, strItemAmountHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));
            GUI.Label(rectItemPriceHeader, strItemPriceHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));

            // Draw the buttons
            if (Widgets.ButtonInvisible(rectItemNameHeader))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.DefName);
            }
            if (Widgets.ButtonInvisible(rectItemAmountHeader))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.ThingAmount);
            }
            if (Widgets.ButtonInvisible(rectItemPriceHeader))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.StartingItems, ProEquipmentShop.ESSortType.Price);
            }

            // Reshape the rectOut
            rectOut = new Rect(rectOut.x, rectOut.y + floHeaderHeight, rectOut.width, rectOut.height - floHeaderHeight);

            // Calculate total height of items
            foreach (ESItem item in esiStartingItems)
            {
                TotalHeight += Text.CalcHeight(item.strNameLabel, floColumnNameWidth);
            }

            // If the total height of items in more than the menu section height, make scroll view fit inside the menu
            // Else make the scroll view wide enough so the highlighted item is not clipped
            Rect rectView = new Rect();

            if (TotalHeight > rectOut.height)
            {
                rectView = new Rect(rectOut.x, rectOut.y, floViewWidth, TotalHeight);
            }
            else
            {
                rectView = new Rect(rectOut.x, rectOut.y, rectOut.width, TotalHeight);
            }

            // Shape the group and shape the tooltip so that it does not scroll inside the scroll view
            Rect rectGroup            = KrozzyUtilities.RectAddition(rectView, rectCard);
            Rect rectScrollingTooltip = KrozzyUtilities.RectAddition(rectOut, rectCard);


            // Begin scroll view and group
            Widgets.BeginScrollView(rectOut, ref v2FoodsScrollPosition2, KrozzyUtilities.RectAddition(rectView, rectCard));
            GUI.BeginGroup(rectGroup);

            // Create list of items from array
            float floYPos = 0f;

            for (int i = 0; i < esiStartingItems.Length; i++)
            {
                // Build strings
                string strNameLabel     = esiStartingItems[i].strNameLabel;
                string strQauntityLabel = esiStartingItems[i].thingAmountTotal.ToString();
                string strCostLabel     = String.Format("{0:0}", esiStartingItems[i].subtotal);
                string strDescToolTip   = string.Concat(esiStartingItems[i].thingDef.description, " price: ", esiStartingItems[i].price.ToString(),
                                                        ", itemAmount: ", esiStartingItems[i].itemAmount.ToString());

                // Shape idividual item
                Rect rectWholeItem     = new Rect(0f, floYPos, rectView.width, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectMiniTex       = new Rect(0f, floYPos, floColumnTexWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectNameLabel     = new Rect(floColumnTexWidth, floYPos, floColumnNameWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectQauntityLabel = new Rect(floColumnTexWidth + floColumnNameWidth, floYPos, floColumnQuantityWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectCostLabel     = new Rect(floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, floYPos, floColumnCostWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));

                // update y position for next label
                floYPos += Text.CalcHeight(strNameLabel, floColumnNameWidth);

                // Draw label based upon if it's currently selected
                if (i == intCurSelectedToUnequip)
                {
                    // Using custom font if selected
                    esiStartingItems[i].DrawIcon(rectMiniTex);
                    GUI.Label(rectNameLabel, strNameLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));
                    GUI.Label(rectQauntityLabel, strQauntityLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));
                    GUI.Label(rectCostLabel, strCostLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));

                    // Prime variable for unequip button
                    esItemCurSelectedToUnequip = esiStartingItems[i];
                    //intCurSelectedAmountToUnequip = esiStartingItems[i].amount;
                    //intCurSelectedPriceToUnequip = ES.GetPrice(esiStartingItems[i]);
                }
                else
                {
                    // Using default font if not selected
                    esiStartingItems[i].DrawIcon(rectMiniTex);
                    Widgets.Label(rectNameLabel, strNameLabel);
                    Widgets.Label(rectQauntityLabel, strQauntityLabel);
                    Widgets.Label(rectCostLabel, strCostLabel);
                }

                // Highlight is mouse is hovering over
                if (Mouse.IsOver(rectWholeItem))
                {
                    KrozzyUtilities.Tooltip(KrozzyUtilities.RectAddition(rectScrollingTooltip, Find.WindowStack.currentlyDrawnWindow.windowRect), strDescToolTip);
                    Widgets.DrawHighlight(rectWholeItem);
                }

                // Draw invisible button for item selecting
                if (Widgets.ButtonInvisible(rectWholeItem, true))
                {
                    intCurSelectedToUnequip = i;
                }
            }

            // End group and scroll view
            GUI.EndGroup();
            Widgets.EndScrollView();
            Text.Font = GameFont.Small; // Ensure font size is back to default
        }
예제 #11
0
        private void ItemSheet(Rect _rectOut, ESItem[] _aItems, GameFont _fontSize)
        {
            // Shape item sheet
            float floViewWidth           = _rectOut.width - 16f;   // Scrollbar has 16f hard number
            float floColumnTexWidth      = floViewWidth * .1f;
            float floColumnNameWidth     = floViewWidth * .6f;
            float floColumnQuantityWidth = floViewWidth * .12f;
            float floColumnCostWidth     = floViewWidth * .18f;

            Text.Font = _fontSize;
            float TotalHeight = 0f;

            // Create strings for headers
            string strItemNameHeader   = "Item";
            string strItemAmountHeader = "#";
            string strItemPriceHeader  = "Cost";

            // Calculate header heights
            float floHeaderHeight = Text.CalcHeight(strItemNameHeader, floColumnNameWidth);

            // Shape the headers
            Rect rectItemNameHeader   = new Rect(_rectOut.x + floColumnTexWidth, _rectOut.y, floColumnNameWidth, floHeaderHeight);
            Rect rectItemAmountHeader = new Rect(_rectOut.x + floColumnTexWidth + floColumnNameWidth, _rectOut.y, floColumnQuantityWidth, floHeaderHeight);
            Rect rectItemPriceHeader  = new Rect(_rectOut.x + floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, _rectOut.y, floColumnCostWidth, floHeaderHeight);

            // Draw the headers
            GUI.Label(KrozzyUtilities.RectAddition(rectItemNameHeader, rectCard), strItemNameHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));
            GUI.Label(KrozzyUtilities.RectAddition(rectItemAmountHeader, rectCard), strItemAmountHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));
            GUI.Label(KrozzyUtilities.RectAddition(rectItemPriceHeader, rectCard), strItemPriceHeader, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Bold));

            // Draw the buttons
            if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemNameHeader, rectCard)))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.DefName);
            }
            if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemAmountHeader, rectCard)))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.ThingAmount);
            }
            if (Widgets.ButtonInvisible(KrozzyUtilities.RectAddition(rectItemPriceHeader, rectCard)))
            {
                ES.SortItemsTool(ProEquipmentShop.ESSortList.Items, ProEquipmentShop.ESSortType.Price);
            }

            // Reshape the _rectOut
            _rectOut = new Rect(_rectOut.x, _rectOut.y + floHeaderHeight, _rectOut.width, _rectOut.height - floHeaderHeight);

            // Calculate total item list height
            foreach (ESItem item in _aItems)
            {
                TotalHeight += Text.CalcHeight(item.strNameLabel, floColumnNameWidth);
            }

            // Calculate rectView based on if the scroll bar will need to be shown
            Rect rectView = new Rect();

            if (TotalHeight > _rectOut.height)
            {
                rectView = new Rect(_rectOut.x, _rectOut.y, floViewWidth, TotalHeight);
            }
            else
            {
                rectView = new Rect(_rectOut.x, _rectOut.y, _rectOut.width, TotalHeight);
            }

            // Calculate rects for GUI group and tooltip
            Rect rectGroup            = KrozzyUtilities.RectAddition(rectView, rectCard);
            Rect rectScrollingTooltip = KrozzyUtilities.RectAddition(_rectOut, rectCard);

            // Begin scroll view and group
            Widgets.BeginScrollView(KrozzyUtilities.RectAddition(_rectOut, rectCard), ref v2FoodsScrollPosition1, KrozzyUtilities.RectAddition(rectView, rectCard));
            GUI.BeginGroup(rectGroup);

            // Create list of items from array
            float floYPos = 0f;

            for (int i = 0; i < _aItems.Length; i++)
            {
                string strNameLabel     = _aItems[i].strNameLabel;
                string strQauntityLabel = _aItems[i].thingAmount.ToString();
                string strCostLabel     = String.Format("{0:0}", ES.GetPrice(_aItems[i]));
                string strDescToolTip   = _aItems[i].thingDef.description;

                // Shape idividual item
                Rect rectWholeItem     = new Rect(0f, floYPos, rectView.width, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectMiniTex       = new Rect(0f, floYPos, floColumnTexWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectNameLabel     = new Rect(floColumnTexWidth, floYPos, floColumnNameWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectQauntityLabel = new Rect(floColumnTexWidth + floColumnNameWidth, floYPos, floColumnQuantityWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));
                Rect rectCostLabel     = new Rect(floColumnTexWidth + floColumnNameWidth + floColumnQuantityWidth, floYPos, floColumnCostWidth, Text.CalcHeight(strNameLabel, floColumnNameWidth));

                // update y position for next label
                floYPos += Text.CalcHeight(strNameLabel, floColumnNameWidth);

                // Draw label based upon if it's currently selected
                if (i == intCurSelectedToEquip)
                {
                    GUI.Label(rectNameLabel, strNameLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));
                    GUI.Label(rectQauntityLabel, strQauntityLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));
                    GUI.Label(rectCostLabel, strCostLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.Yellow));
                    _aItems[i].DrawIcon(rectMiniTex);

                    // Prime variable for equip button
                    esItemCurSelectedToEquip = _aItems[i];
                }
                else
                {
                    Widgets.Label(rectNameLabel, strNameLabel);
                    Widgets.Label(rectQauntityLabel, strQauntityLabel);
                    Widgets.Label(rectCostLabel, strCostLabel);
                    _aItems[i].DrawIcon(rectMiniTex);
                }

                // Highlight is mouse is hovering over
                if (Mouse.IsOver(rectWholeItem))
                {
                    KrozzyUtilities.Tooltip(KrozzyUtilities.RectAddition(rectScrollingTooltip, Find.WindowStack.currentlyDrawnWindow.windowRect), strDescToolTip);
                    Widgets.DrawHighlight(rectWholeItem);
                }

                // Draw invisible button for item selecting
                if (Widgets.ButtonInvisible(rectWholeItem, true))
                {
                    intCurSelectedToEquip = i;
                }
            }

            // End group and scroll view
            GUI.EndGroup();
            Widgets.EndScrollView();
            Text.Font = GameFont.Small; // Ensure font size is back to default
        }
예제 #12
0
        private ESItem[] GetLeatherApparel(BiomeDef _biome, string _ApparelDefName, bool _LogCalculation)
        {
            // Variables
            bool boolLogCalculation = _LogCalculation;

            PawnKindDef[] aAnimals = new PawnKindDef[0];
            aAnimals = aAnimals.Concat(_biome.AllWildAnimals).ToArray();
            PawnKindDef[] aAllAnimals       = (from k in DefDatabase <PawnKindDef> .AllDefs where (k.RaceProps.Animal) select k).ToArray();
            PawnKindDef[] aTameAnimals      = (from a in aAllAnimals where (a.race.race.wildness < .1f) select a).ToArray();
            PawnKindDef[] aNoLeatherAnimals = (from b in aAllAnimals where (b.race.race.leatherDef == null) select b).ToArray();

            if (aAnimals.Contains(PawnKindDef.Named("WildBoar")))
            {
                aTameAnimals = aTameAnimals.Where(x => x != PawnKindDef.Named("Pig")).ToArray();
            }

            aTameAnimals = aTameAnimals.Where(x => x != PawnKindDef.Named("YorkshireTerrier") && x != PawnKindDef.Named("Husky") &&
                                              x != PawnKindDef.Named("LabradorRetriever")).ToArray();
            aAnimals = aAnimals.Union(aTameAnimals).ToArray();
            aAnimals = aAnimals.Where(x => !aNoLeatherAnimals.Contains(x)).ToArray();
            aAnimals = aAnimals.OrderBy(pkd => pkd.defName).ToArray();
            ESItem[] aESI        = new ESItem[aAnimals.Length];
            string   strThingDef = _ApparelDefName;

            // Variables for logging
            string strAnimalCommonality       = "";
            string strAnimalLeather           = "";
            string strAnimalBodySize          = "";
            string strAnimalDanger            = "";
            string strAnimalLeatherComonality = "";
            string strAnimalLMVF     = "";
            string strCostPerLeather = "";
            string strFinal          = "";

            string[] aStrings = new string[0];

            // Start master loop for each animal in biome
            for (int i = 0; i < aAnimals.Count(); i++)
            {
                try
                {
                    // variables
                    int    intThingAmount = 1;
                    float  floBasePrice   = 0f;
                    string strStuff;
                    string strAnimalName        = aAnimals[i].defName;
                    float  floAnimalDPS         = 0f;
                    float  floAnimalCommonality = 0f;

                    // variables for tweeking
                    // Scale opens price gaps
                    float floHealthScale      = 1f;                // drives prices up
                    float floDangerScale      = 1f;                // drives prices up
                    float floCommonalityScale = 1f;                // drives prices down
                    float floBodySizeScale    = 1f;                // drives prices down
                    float floInsulationScale  = 6f;                // drives prices up

                    // Floor closes price gaps
                    float floHealthFloor      = .4f;
                    float floDangerFloor      = 20f;
                    float floCommonalityFloor = 1f;
                    float floBodySizeFloor    = 1f;
                    float floInsulationFloor  = 0f;

                    float floPredatorScale = 4f;
                    float floFarmScale     = 1.5f;
                    float floTotalScale    = .1f;

                    // Calc animal DPS
                    if (!aAnimals[i].race.Verbs.NullOrEmpty <VerbProperties>())
                    {
                        VerbProperties[] aVerbs = aAnimals[i].race.Verbs.ToArray();

                        for (int x = 0; x < aVerbs.Length; x++)
                        {
                            if ((float)aVerbs[x].meleeDamageBaseAmount > .001f)
                            {
                                floAnimalDPS += (float)aVerbs[x].meleeDamageBaseAmount / (aVerbs[x].defaultCooldownTime + aVerbs[x].warmupTime);
                            }
                        }

                        floAnimalDPS = floAnimalDPS / (float)aVerbs.Length;
                    }

                    // Calc animal danger with baseHealthScale scale and floor
                    float floAnimalDanger = floAnimalDPS * aAnimals[i].race.GetStatValueAbstract(StatDefOf.MoveSpeed) * (aAnimals[i].race.race.baseHealthScale * floHealthScale + floHealthFloor);

                    // if Boomrat or Boomalope, add more danger
                    if (aAnimals[i].defName == "Boomrat" || aAnimals[i].defName == "Boomalope")
                    {
                        floAnimalDanger += 50f;
                    }

                    // Add danger scale and floor
                    floAnimalDanger = floAnimalDanger * floDangerScale + floDangerFloor;

                    // Calc animal commonality, add animal commonality scale and floor, multiply for predators and farm types
                    if (aAnimals[i].race.race.predator == true)
                    {
                        floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floPredatorScale * floCommonalityScale * _biome.animalDensity;
                    }
                    else if (aAnimals[i].defName == "Chicken" || aAnimals[i].defName == "Pig" || aAnimals[i].defName == "WildBoar" || aAnimals[i].defName == "Cow" || aAnimals[i].defName == "Alpaca")
                    {
                        floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floFarmScale * floCommonalityScale * _biome.animalDensity;
                        //if (floAnimalCommonality < .1f)
                        //{
                        //	floAnimalCommonality = floCommonalityFloor * .5f;
                        //}
                    }
                    else
                    {
                        floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floCommonalityScale * _biome.animalDensity;
                    }
                    floAnimalCommonality += floCommonalityFloor;

                    // Calc animal leather commonality with baseBodySize scale and floor
                    float floAnimalLeatherCommonality = (floAnimalCommonality * (aAnimals[i].race.race.baseBodySize * floBodySizeScale + floBodySizeFloor)) / floAnimalDanger;

                    // Logging part 1
                    if (boolLogCalculation)
                    {
                        strAnimalCommonality       = string.Concat("Commonality of ", aAnimals[i].ToString(), " * Animal Density: ", floAnimalCommonality.ToString(), "\n");
                        strAnimalLeather           = string.Concat(aAnimals[i].race.race.leatherDef.ToString(), ", Insulation: ", aAnimals[i].race.race.leatherInsulation.ToString(), "\n");
                        strAnimalBodySize          = string.Concat("BodySize: ", aAnimals[i].race.race.baseBodySize.ToString(), "\n");
                        strAnimalDanger            = string.Concat("AnimalDPS * AnimalMoveSpeed * AnimalBaseHealthScale = Danger: ", floAnimalDanger.ToString(), "\n");
                        strAnimalLeatherComonality = string.Concat("Animal Commonality * BodySize / Danger = LeatherCommonality: ", floAnimalLeatherCommonality.ToString(), "\n");
                        strAnimalLMVF     = string.Concat("leatherMarketValueFactor: ", aAnimals[i].race.race.leatherMarketValueFactor.ToString(), "\n");
                        strCostPerLeather = string.Concat("leatherInsulation / LeatherCommonality * leatherMarketValueFactor = Cost per leather: ");
                    }

                    // Handle WildBoar because it uses Pig leather, add leatherInsulation scale and floor
                    if (strAnimalName == "WildBoar")
                    {
                        strAnimalName = "Pig";
                        floBasePrice  = ((aAnimals[i].race.race.leatherInsulation * floInsulationScale + floInsulationFloor) / floAnimalLeatherCommonality) * PawnKindDef.Named("Pig").race.race.leatherMarketValueFactor;
                    }
                    else
                    {
                        floBasePrice = ((aAnimals[i].race.race.leatherInsulation * floInsulationScale + floInsulationFloor) / floAnimalLeatherCommonality) * aAnimals[i].race.race.leatherMarketValueFactor;
                    }

                    // Add total scale
                    floBasePrice *= floTotalScale;

                    // Calc ThingDef string for Stuff, calc leather needed for apparel
                    strStuff = string.Concat(strAnimalName, "_Leather");
                    float floFinalCost = (float)ThingDef.Named(strThingDef).costStuffCount *floBasePrice;

                    // Populate ESItem list for return
                    aESI[i] = new ESItem(strThingDef, intThingAmount, floFinalCost, 1, strStuff);

                    // Logging part 2
                    if (boolLogCalculation)
                    {
                        strFinal = string.Concat(aAnimals[i].ToString(), " FINAL: ", floBasePrice.ToString(), "\n", strThingDef, ": ", floFinalCost.ToString());
                        aStrings = new string[] { strAnimalCommonality, strAnimalLeather, strAnimalBodySize, strAnimalDanger, strAnimalLeatherComonality, strAnimalLMVF, strCostPerLeather, strFinal };
                        Log.Message(string.Concat(aStrings));
                    }
                }
                catch
                {
                    aESI[i] = new ESItem("Apparel_Tuque", 1, 9001, 1, "Cloth");
                    Log.Message(string.Concat(aAnimals[i].defName, " FAILED ESApparel.GetLeatherApparel."));
                }
            }

            return(aESI);
        }
예제 #13
0
        private ESItem[] GetWoolApparel(BiomeDef _biome, string _ApparelDefName, bool _LogCalculation)
        {
            // Variables
            bool boolLogCalculation = _LogCalculation;

            PawnKindDef[] aBiomeAnimals = new PawnKindDef[0];
            aBiomeAnimals = aBiomeAnimals.Concat(_biome.AllWildAnimals).ToArray();
            string strThingDef = _ApparelDefName;

            PawnKindDef[] aAllAnimals              = (from k in DefDatabase <PawnKindDef> .AllDefs where (k.RaceProps.Animal) select k).ToArray();
            PawnKindDef[] aWoolAnimals             = (from a in aAllAnimals where a.race.HasComp(typeof(CompShearable)) select a).ToArray();
            PawnKindDef[] aTameAnimals             = (from a in aAllAnimals where (a.race.race.wildness < .1f) select a).ToArray();
            PawnKindDef[] aTameWoolAnimals         = aWoolAnimals.Intersect(aTameAnimals).ToArray();
            PawnKindDef[] aBiomeWoolAnimals        = aBiomeAnimals.Intersect(aWoolAnimals).ToArray();
            PawnKindDef[] aBiomeAndTameWoolAnimals = aTameWoolAnimals.Union(aBiomeWoolAnimals).ToArray();
            PawnKindDef[] aAnimals = aBiomeAndTameWoolAnimals;
            ESItem[]      aESI     = new ESItem[aAnimals.Length];

            // Logging for variables
            if (boolLogCalculation == true)
            {
                string[] aStr = new string[] { "All tame animals: \n" };
                foreach (PawnKindDef pkd in aTameAnimals)
                {
                    aStr = aStr.Concat(new string[] { pkd.defName, "\n" }).ToArray();
                }
                Log.Message(string.Concat(aStr));

                string[] aStr2 = new string[] { "All wool producing animals: \n" };
                foreach (PawnKindDef pkd in aWoolAnimals)
                {
                    aStr2 = aStr2.Concat(new string[] { pkd.defName, "\n" }).ToArray();
                }
                Log.Message(string.Concat(aStr2));

                string[] aStr3 = new string[] { "All tame animals that produce wool: \n" };
                foreach (PawnKindDef pkd in aTameWoolAnimals)
                {
                    aStr3 = aStr3.Concat(new string[] { pkd.defName, "\n" }).ToArray();
                }
                Log.Message(string.Concat(aStr3));

                string[] aStr4 = new string[] { "All animals that produce wool in this biome: \n" };
                foreach (PawnKindDef pkd in aBiomeWoolAnimals)
                {
                    aStr4 = aStr4.Concat(new string[] { pkd.defName, "\n" }).ToArray();
                }
                Log.Message(string.Concat(aStr4));

                string[] aStr5 = new string[] { "All Tame and Biome wool producing animals: \n" };
                foreach (PawnKindDef pkd in aAnimals)
                {
                    aStr5 = aStr5.Concat(new string[] { pkd.defName, "\n" }).ToArray();
                }
                Log.Message(string.Concat(aStr5));
            }

            // Variables for logging
            string strAnimalCommonality    = "";
            string strAnimalWool           = "";
            string strAnimalBodySize       = "";
            string strAnimalDanger         = "";
            string strAnimalwoolComonality = "";
            string strAnimalWMVF           = "";
            string strCostPerWool          = "";
            string strFinal = "";

            string[] aStrings = new string[0];

            // Start master loop for each wool producing animal in biome
            for (int i = 0; i < aAnimals.Count(); i++)
            {
                // variables
                int            intThingAmount = 1;
                float          floBasePrice   = 0f;
                string         strStuff;
                string         strAnimalName        = aAnimals[i].defName;
                float          floAnimalDPS         = 0f;
                float          floAnimalCommonality = 0f;
                string         strAnimalWoolDef     = aAnimals[i].race.GetCompProperties <CompProperties_Shearable>().woolDef.defName;
                StatModifier[] asmStatOffsets       = ThingDef.Named(strAnimalWoolDef).stuffProps.statOffsets.ToArray();
                StatModifier[] asmStatFactors       = ThingDef.Named(strAnimalWoolDef).stuffProps.statFactors.ToArray();
                (from a in aAllAnimals where a.race.HasComp(typeof(CompShearable)) select a).ToArray();

                // variables for tweeking
                // Scale opens price gaps
                float floHealthScale      = 1f;            // drives prices up
                float floDangerScale      = 1f;            // drives prices up
                float floCommonalityScale = 1f;            // drives prices down
                float floBodySizeScale    = 1f;            // drives prices down
                float floInsulationScale  = 6f;            // drives prices up

                // Floor closes price gaps
                float floHealthFloor      = .4f;
                float floDangerFloor      = 20f;
                float floCommonalityFloor = 1f;
                float floBodySizeFloor    = 1f;
                float floInsulationFloor  = 0f;

                float floPredatorScale = 4f;
                float floFarmScale     = 1.5f;
                float floTotalScale    = .05f;

                // Calc animal DPS
                if (!aAnimals[i].race.Verbs.NullOrEmpty <VerbProperties>())
                {
                    VerbProperties[] aVerbs = aAnimals[i].race.Verbs.ToArray();

                    for (int x = 0; x < aVerbs.Length; x++)
                    {
                        if ((float)aVerbs[x].meleeDamageBaseAmount > .001f)
                        {
                            floAnimalDPS += (float)aVerbs[x].meleeDamageBaseAmount / (aVerbs[x].defaultCooldownTime + aVerbs[x].warmupTime);
                        }
                    }

                    floAnimalDPS = floAnimalDPS / (float)aVerbs.Length;
                }

                // Calc animal danger with baseHealthScale scale and floor
                float floAnimalDanger = floAnimalDPS * aAnimals[i].race.GetStatValueAbstract(StatDefOf.MoveSpeed) * (aAnimals[i].race.race.baseHealthScale * floHealthScale + floHealthFloor);

                // Add danger scale and floor
                floAnimalDanger = floAnimalDanger * floDangerScale + floDangerFloor;

                // Calc animal commonality, multiply for predators and farm types
                if (aAnimals[i].race.race.predator == true)
                {
                    floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floPredatorScale * floCommonalityScale * _biome.animalDensity;
                }
                else if (aTameAnimals.Contains(aAnimals[i]))
                {
                    floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floFarmScale * floCommonalityScale * _biome.animalDensity;
                    floAnimalDanger     /= floFarmScale;
                }
                else
                {
                    floAnimalCommonality = _biome.CommonalityOfAnimal(aAnimals[i]) * floCommonalityScale * _biome.animalDensity;
                }

                // Add animal commonality scale and floor
                floAnimalCommonality += floCommonalityFloor;

                // Calc animal Wool commonality with baseBodySize scale and floor
                float floAnimalWoolCommonality = (floAnimalCommonality * ((aAnimals[i].race.race.baseBodySize * 3f) * floBodySizeScale + floBodySizeFloor)) / floAnimalDanger;

                // Calc total statOffsets
                float floStatOffsetsTotal = 0f;
                foreach (StatModifier sm in asmStatOffsets)
                {
                    floStatOffsetsTotal += sm.value;
                }

                // Calc total statFactors
                float floStatFactorsTotal = 0f;
                foreach (StatModifier sf in asmStatFactors)
                {
                    floStatFactorsTotal += (sf.value * .75f);
                }

                //Add woolInsulation scale and floor
                floBasePrice = ((floStatFactorsTotal * floInsulationScale + floInsulationFloor) + floStatOffsetsTotal) / floAnimalWoolCommonality;

                // Logging part 1
                if (boolLogCalculation)
                {
                    strAnimalCommonality    = string.Concat("Commonality of ", aAnimals[i].ToString(), " * Animal Density: ", floAnimalCommonality.ToString(), "\n");
                    strAnimalWool           = string.Concat(aAnimals[i].race.race.leatherDef.ToString(), ", statFactors: ", floStatFactorsTotal.ToString(), "\n");
                    strAnimalBodySize       = string.Concat("BodySize: ", aAnimals[i].race.race.baseBodySize.ToString(), "\n");
                    strAnimalDanger         = string.Concat("AnimalDPS * AnimalMoveSpeed * AnimalBaseHealthScale = Danger: ", floAnimalDanger.ToString(), "\n");
                    strAnimalwoolComonality = string.Concat("Animal Commonality * BodySize / Danger = woolCommonality: ", floAnimalWoolCommonality.ToString(), "\n");
                    strAnimalWMVF           = string.Concat("woolMarketValueFactor: ", aAnimals[i].race.race.leatherMarketValueFactor.ToString(), "\n");
                    strCostPerWool          = string.Concat("statFactors / woolCommonality = Cost per leather: ");
                }

                // Add total scale
                floBasePrice *= floTotalScale;

                // Calc ThingDef string for Stuff, calc wool needed for apparel
                strStuff = strAnimalWoolDef;
                float floFinalCost = (float)ThingDef.Named(strThingDef).costStuffCount *floBasePrice;

                // Populate ESItem list for return
                aESI[i] = new ESItem(strThingDef, intThingAmount, floFinalCost, 1, strStuff);

                // Logging part 2
                if (boolLogCalculation)
                {
                    strFinal = string.Concat(aAnimals[i].ToString(), " FINAL: ", floBasePrice.ToString(), "\n", strThingDef, ": ", floFinalCost.ToString());
                    aStrings = new string[] { strAnimalCommonality, strAnimalWool, strAnimalBodySize, strAnimalDanger, strAnimalwoolComonality, strAnimalWMVF, strCostPerWool, strFinal };
                    Log.Message(string.Concat(aStrings));
                }
            }

            return(aESI);
        }
예제 #14
0
        private ESItem[] GetItems(ThingDef _ItemType, BiomeDef _biome)
        {
            // Variables
            ESItem[] aESI         = new ESItem[0];
            string   strThingDef  = _ItemType.defName;
            float    floBasePrice = 0;
            int      intAmount    = 0;

            switch (strThingDef)
            {
            case "MealSimple":
                intAmount    = 5;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome) * GetPlantPriceInflate(_biome);
                break;

            case "MealFine":
                intAmount    = 1;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome) * GetPlantPriceInflate(_biome);
                break;

            case "EggChickenUnfertilized":
                intAmount    = 5;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome);
                break;

            case "InsectJelly":
                intAmount    = 1;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome);
                break;

            case "Pemmican":
                intAmount    = 10;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome) * GetPlantPriceInflate(_biome);
                break;

            case "Milk":
                intAmount    = 10;
                floBasePrice = _ItemType.BaseMarketValue * GetAnimalPriceInflate(_biome);
                break;

            case "RawAgave":
                if (_biome != BiomeDefOf.Desert && _biome != BiomeDefOf.AridShrubland && _biome.defName != "ExtremeDesert")
                {
                    floBasePrice = _ItemType.BaseMarketValue * GetPlantPriceInflate(_biome) * 3f;
                }
                else
                {
                    floBasePrice = _ItemType.BaseMarketValue * GetPlantPriceInflate(_biome);
                }
                intAmount = 10;
                break;

            case "RawBerries":
                if (_biome != BiomeDefOf.Desert && _biome.defName != "ExtremeDesert")
                {
                    floBasePrice = _ItemType.BaseMarketValue * GetPlantPriceInflate(_biome);
                }
                else
                {
                    floBasePrice = _ItemType.BaseMarketValue * GetPlantPriceInflate(_biome) * 1.5f;
                }
                intAmount = 10;
                break;

            default:
                floBasePrice = _ItemType.BaseMarketValue * GetPlantPriceInflate(_biome);
                intAmount    = 10;
                break;
            }

            aESI = aESI.Concat(new ESItem[] { new ESItem(_ItemType.defName, intAmount, floBasePrice * intAmount) }).ToArray();

            return(aESI);
        }
예제 #15
0
 public void DecrementItem(ESItem _esi)
 {
     thingAmountTotal -= _esi.thingAmount;
     itemAmount       -= _esi.itemAmount;
     subtotal         -= _esi.price;
 }