示例#1
0
        IEnumerator ProductionRoutine(Recipe recipe, float startPercentage = 0)
        {
            this.Log($"Production registry starting production for {recipe} with starting percentage of {startPercentage}");

            Register(recipe);

            var percentage = startPercentage == 0 ? 1 : startPercentage;

            ProductionPercentages[recipe] = percentage;

            while (ProductionPercentages[recipe] < 100)
            {
                yield return(new TimeComponent.WaitForMinuteTicked());

                var assignmentCount = Assignment.AssignmentCount(recipe);
                ProductionPercentages[recipe] += 100f * assignmentCount / recipe.Time;
                this.Log($"Production registry progress for {recipe} now at {ProductionPercentages[recipe]}");
            }

            ResetProgress(recipe);

            var employees = Assignment.GetAssignedEmployees(recipe);

            this.Log($"ProductionRegistry finished production for {recipe}");
            RecipeFinished?.Invoke(this, new ProductionComponent.ProductionEventArgs(recipe, employees));
        }