コード例 #1
0
        public void TickCrafting()
        {
            if (!IsCrafting)
            {
                return;
            }

            if (_currentCrafter == null)
            {
                throw new Exception("Attempted to tick crafting, but no crafter.");
            }

            if (_currentCraftingState == null)
            {
                throw new Exception("Attempted to tick crafting, but no crafting state.");
            }

            // TODO: Logic for crafting work per tick;
            _currentCraftingState.AddWork(_currentCraftingState.CraftingDef.BaseWorkPerTick, _currentCrafter);

            if (_currentCraftingState.PercentDone >= 1)
            {
                var itemController = GameMaster.Instance.GetController <IItemController>();
                var def            = itemController.GetDef(_currentCraftingState.CraftingDef.OutputItemDefName);
                itemController.CreateNewItems(def, _outputInventory, _currentCraftingState.CraftingDef.OutputCount);

                _currentCraftingState = null;
                _currentCrafter       = null;
            }
        }
コード例 #2
0
 public CraftingQReq(Item.Type typeNeeded, int amountNeeded,
                     ICrafter crafter, string description = null)
     : base(string.IsNullOrWhiteSpace(description)
                           ? "Craft {0} {1}: {2} / {0}" : description, null)
 {
     this.typeNeeded   = typeNeeded;
     this.amountNeeded = amountNeeded;
     this.crafter      = crafter;
 }
コード例 #3
0
 public void SetCrafter(ICrafter newCrafter)
 {
     if (newCrafter == null)
     {
         return;
     }
     UnSubscribeFromCrafterInventories(crafter);
     crafter = newCrafter;
     SubscribeToCrafterInventories(crafter);
 }
コード例 #4
0
        private void UnSubscribeFromCrafterInventories(ICrafter crafter)
        {
            if (crafter == null)
            {
                return;
            }
            List <Storage> inventories = crafter.GetAllInventories;

            for (int i = 0; i < inventories.Count; i++)
            {
                inventories[i].OnStackUpdated -= UpdateUI;
            }
        }
コード例 #5
0
        public void Initialise(CraftingUIController craftingUI, CraftingRecipe recipe, ICrafter crafter)
        {
            this.craftingUI = craftingUI;
            this.recipe     = recipe;
            this.crafter    = crafter;

            ingredients = recipe.IngredientsCopy;
            results     = recipe.ResultsCopy;

            stackGroup.SetStackGroup(results);

            UpdateCraftableIndicator();
        }
コード例 #6
0
 public void AddWork(float work, ICrafter crafter)
 {
     if (work > 0)
     {
         _workSoFar += work;
         if (!_crafterHistory.Contains(crafter))
         {
             _crafterHistory.Add(crafter);
         }
     }
     else
     {
         throw new Exception($"Work is not greater than zero 0. Must be positive and non zero.");
     }
 }
コード例 #7
0
        public string TryStartCrafting(string craftingDefName, ICrafter crafter)
        {
            // TODO: Logic for filtering crafters
            //if (false)
            //    return false;

            if (!_manufacturingBuildingDef.CraftingDefs.Where(x => x.DefName == craftingDefName).Any())
            {
                throw new Exception("Crafting def '{craftingDefName}' not found.");
            }

            _currentCrafter       = crafter;
            _currentCraftingState = new CraftingState(_manufacturingBuildingDef.CraftingDefs.Single(x => x.DefName == craftingDefName));
            return(CraftingResults.Success);
        }
コード例 #8
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            //Success!
            wasSuccessful = true;

            result = ActionName + " used!  " + Math.Abs(DurabilityUsed) + " durability restored.";

            craft.IncrementStep();
            craft.UpdateDurability(DurabilityUsed);
            crafter.UpdateCP(CPCost);

            this.actionUsed = true;
            return result;
        }
コード例 #9
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            //Success!
            wasSuccessful = true;

            double progress = Calc.Progress(craft.RecipeLevel, craft.ItemLevel, crafter.CrafterLevel, crafter.Craftsmanship) * ProgressModifier;
            result = ActionName + " successful!  Progress increased by " + Math.Round(progress, 0, MidpointRounding.ToEven);

            craft.UpdateProgress(progress);

            craft.IncrementStep();
            craft.UpdateDurability(DurabilityUsed);
            crafter.UpdateCP(CPCost);

            this.actionUsed = true;
            return result;
        }
コード例 #10
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            if (condition == Conditions.Good || condition == Conditions.Excellent)
            {
                //Calculate success.
                if (Calc.ActionIsSuccessful(rng, SuccessChance))
                {
                    //Success!
                    wasSuccessful = true;
                    double quality = Calc.ApplyCondition(Calc.Quality(craft.RecipeLevel, craft.ItemLevel, crafter.CrafterLevel, crafter.Control) * qualityModifier, condition);
                    result = ActionName + " successful!  Quality increased by " + Math.Round(quality, 0, MidpointRounding.ToEven);

                    //Update quality.
                    craft.UpdateQuality(quality);
                }
                else
                {
                    //Failure!
                    wasSuccessful = false;
                    result = ActionName + " failed!";
                }

                craft.IncrementStep();
                craft.UpdateDurability(DurabilityUsed);
                crafter.UpdateCP(CPCost);

                this.actionUsed = true;
            }
            else
            {
                result = "Condition must be good or excellent to use Precise Touch.";
            }

            return result;
        }
コード例 #11
0
ファイル: Ingenuity2.cs プロジェクト: lchesley/test-simulator
        public string ApplyModifier(ICrafter crafter, ICraft craft)
        {
            crafter.UpdateCP(CPCost);

            craft.SetItemLevel(Calc.GetIngenuityIIItemLevels(craft.ItemLevel));

            return ModifierName + " is applied.  Item Level is now " + craft.ItemLevel;
        }
コード例 #12
0
 public void StopCrafting()
 {
     _currentCrafter       = null;
     _currentCraftingState = null;
 }
コード例 #13
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            if (Calc.ActionIsSuccessful(rng, SuccessChance))
            {
                //Success!
                wasSuccessful = true;
                double progress = 40;
                result = ActionName + " successful!  Progress increased by " + Math.Round(progress, 0, MidpointRounding.ToEven);

                //Update progress.
                craft.UpdateProgress(progress);
            }
            else
            {
                //Failure!
                wasSuccessful = false;
                result = ActionName + " failed!";
            }

            craft.IncrementStep();
            craft.UpdateDurability(DurabilityUsed);
            crafter.UpdateCP(CPCost);

            this.actionUsed = true;

            return result;
        }
コード例 #14
0
 public void AtEndOfStep(ICrafter crafter, ICraft craft)
 {
     if (stepsRemaining > 0)
     {
         stepsRemaining--;
     }
 }
コード例 #15
0
ファイル: Rumination.cs プロジェクト: lchesley/test-simulator
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            //If Inner Quiet active, set quality modifier.
            var innerQuiet = activeModifiers.Where(o => o.ModifierName == "Inner Quiet" && o.StepsRemaining > 0).FirstOrDefault() as InnerQuiet;
            if (innerQuiet != null && innerQuiet.StepsActive > 0)
            {
                //Success!
                wasSuccessful = true;
                double cpRestored = ((21 * innerQuiet.StepsActive) - Math.Pow(innerQuiet.StepsActive, 2) + 10) / 2;
                result = ActionName + " successful!  " + cpRestored + " CP restored!";

                //Update quality.
                craft.IncrementStep();
                craft.UpdateDurability(DurabilityUsed);
                crafter.UpdateCP(Convert.ToInt32(cpRestored * -1));

                innerQuiet.ConsumeStacks();

                this.actionUsed = true;
            }
            else
            {
                result = "Inner Quiet stacks not available, cannot use " + ActionName + ".";
            }

            return result;
        }
コード例 #16
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            //Calculate success.
            if (Calc.ActionIsSuccessful(rng, SuccessChance))
            {
                //Success!
                wasSuccessful = true;

                if (activeModifiers.Where(o => o.ModifierName == "Name Of Water").Count() > 0)
                {
                    progressModifier = 2 * ((craft.Difficulty - craft.Progress) / craft.Difficulty - 1) + 3;
                }

                if(craft.Affinity == ElementalAffinity.Water)
                {
                    progressModifier = progressModifier * 2;
                }

                double progress = Calc.Progress(craft.RecipeLevel, craft.ItemLevel, crafter.CrafterLevel, crafter.Craftsmanship) * ProgressModifier;
                result = ActionName + " successful!  Progress increased by " + Math.Round(progress, 0, MidpointRounding.ToEven);

                //Update quality.
                craft.UpdateProgress(progress);
            }
            else
            {
                //Failure!
                wasSuccessful = false;
                result = ActionName + " failed!";
            }

            craft.IncrementStep();
            craft.UpdateDurability(DurabilityUsed);
            crafter.UpdateCP(CPCost);

            this.actionUsed = true;
            return result;
        }
コード例 #17
0
ファイル: Innovation.cs プロジェクト: lchesley/test-simulator
 public void AtEndOfStep(ICrafter crafter, ICraft craft)
 {
     if (stepsRemaining > 0)
     {
         stepsRemaining--;
     }
     else
     {
         if (!controlRemoved)
         {
             crafter.IncreaseControl(crafter.BaseControl * ControlModifier * -1);
             controlRemoved = true;
         }
     }
 }
コード例 #18
0
 public void AfterSuccessfulQualityIncrease(ICrafter crafter)
 {
 }
コード例 #19
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            if (craft.Step == 0)
            {
                //Success!
                wasSuccessful = true;

                double progress = craft.Difficulty * 0.33;
                result = ActionName + " successful!  Progress increased by " + Math.Round(progress, 0, MidpointRounding.ToEven);

                craft.UpdateProgress(progress);

                craft.IncrementStep();
                craft.UpdateDurability(DurabilityUsed);
                crafter.UpdateCP(CPCost);

                this.actionUsed = true;
            }
            else
            {
                result = ActionName + " can only be used on the first step.";
            }

            return result;
        }
コード例 #20
0
ファイル: MakersMark.cs プロジェクト: lchesley/test-simulator
        public string ApplyModifier(ICrafter crafter, ICraft craft)
        {
            string result = String.Empty;

            if (craft.Step == 0)
            {
                crafter.UpdateCP(CPCost);
                this.stepsActive = Convert.ToInt32(Math.Ceiling((double)craft.Difficulty/100));
                this.stepsRemaining = StepsActive + 1;
                result =  ModifierName + " applied.";
            }
            else
            {
                result = ModifierName + " can only be used as the first step.";
            }

            return result;
        }
コード例 #21
0
ファイル: Innovation.cs プロジェクト: lchesley/test-simulator
 public string ApplyModifier(ICrafter crafter, ICraft craft)
 {
     crafter.UpdateCP(CPCost);
     crafter.IncreaseControl(crafter.BaseControl * ControlModifier);
     return ModifierName + " is applied.  Control is now " + crafter.Control;
 }
コード例 #22
0
ファイル: Ingenuity2.cs プロジェクト: lchesley/test-simulator
 public void AtEndOfStep(ICrafter crafter, ICraft craft)
 {
     if (stepsRemaining > 0)
     {
         stepsRemaining--;
     }
     else
     {
         if (!baseItemLevelRestored)
         {
             craft.SetItemLevel(craft.BaseItemLevel);
         }
     }
 }
コード例 #23
0
        public void AtEndOfStep(ICrafter crafter, ICraft craft)
        {
            if(stepsRemaining > 0)
            {
                //Don't give cp back on first step
                if(!(stepsRemaining > StepsActive))
                {
                    crafter.UpdateCP(DurabilityReturned * -1);
                }

                stepsRemaining--;
            }
        }
コード例 #24
0
 public void AfterSuccessfulQualityIncrease(ICrafter crafter)
 {
     stepsRemaining = 0;
 }
コード例 #25
0
 public string ApplyModifier(ICrafter crafter, ICraft craft)
 {
     crafter.UpdateCP(CPCost);
     return ModifierName + " applied.";
 }
コード例 #26
0
ファイル: InnerQuiet.cs プロジェクト: lchesley/test-simulator
 public void AtEndOfStep(ICrafter crafter, ICraft craft)
 {
     if(stepsRemaining == 0 && stepsActive > 0)
     {
         crafter.IncreaseControl((crafter.BaseControl * ControlModifier) * (StepsActive - 1) * -1);
         stepsActive = 0;
     }
 }
コード例 #27
0
 public CraftingQReq(Item.Type typeNeeded, ICrafter crafter,
                     string description = null)
     : this(typeNeeded, 1, crafter, description)
 {
 }
コード例 #28
0
ファイル: InnerQuiet.cs プロジェクト: lchesley/test-simulator
 public void AfterSuccessfulQualityIncrease(ICrafter crafter)
 {
     if (stepsRemaining > 0)
     {
         crafter.IncreaseControl(crafter.BaseControl * ControlModifier);
         stepsActive++;
     }
 }
コード例 #29
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            if (condition == Conditions.Good || condition == Conditions.Excellent)
            {
                wasSuccessful = true;
                result = ActionName + " successful!  CP increased by 20.";
                craft.IncrementStep();
                craft.UpdateDurability(DurabilityUsed);
                crafter.UpdateCP(CPCost);

                this.actionUsed = true;
            }
            else
            {
                result = "Condition must be good or excellent to use Tricks of the Trade.";
            }

            return result;
        }
コード例 #30
0
        public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition)
        {
            string result = String.Empty;

            //If Inner Quiet active, set quality modifier.
            var innerQuiet = activeModifiers.Where(o => o.ModifierName == "Inner Quiet" && o.StepsRemaining > 0).FirstOrDefault() as InnerQuiet;
            if (innerQuiet != null && innerQuiet.StepsActive > 0)
            {
                //Calculate success.
                if (Calc.ActionIsSuccessful(rng, SuccessChance))
                {
                    //Success!
                    wasSuccessful = true;
                    qualityModifier = qualityModifier * (1 + (innerQuiet.StepsActive * .2));
                    double quality = Calc.ApplyCondition(Calc.Quality(craft.RecipeLevel, craft.ItemLevel, crafter.CrafterLevel, crafter.Control) * qualityModifier, condition);
                    result = ActionName + " successful!  Quality increased by " + Math.Round(quality, 0, MidpointRounding.ToEven);

                    //Update quality.
                    craft.UpdateQuality(quality);
                }
                else
                {
                    //Failure!
                    wasSuccessful = false;
                    result = ActionName + " failed!";
                }

                craft.IncrementStep();
                craft.UpdateDurability(DurabilityUsed);
                crafter.UpdateCP(CPCost);

                innerQuiet.ConsumeStacks();

                this.actionUsed = true;
            }
            else
            {
                result = "Inner Quiet stacks not available, cannot use " + ActionName + ".";
            }

            return result;
        }