public RecipesViewModel() { // initialize commands m_addNewRecipeCommand = new RelayCommand(AddNewRecipe); m_deleteRecipeCommand = new RelayCommand <RecipeDataModel>(DeleteRecipe); m_addHopsIngredientToRecipeCommand = new RelayCommand <Hops>(AddHopsIngredient); m_addFermentableIngredientToRecipeCommand = new RelayCommand <Fermentable>(AddFermentableIngredient); m_changeYeastCommand = new RelayCommand <Yeast>(ChangeYeast); m_deleteHopsIngredientCommand = new RelayCommand <IHopsIngredient>(DeleteHopsIngredient); m_deleteFermentableIngredientCommand = new RelayCommand <IFermentableIngredient>(DeleteFermentableIngredient); // get available ingredients List <IngredientTypeBase> allAvailableIngredients = RecipeUtility.GetAvailableIngredients().OrderBy(ingredient => ingredient.Name).ToList(); m_availableHops = allAvailableIngredients.OfType <Hops>().ToReadOnlyObservableCollection(); m_availableFermentables = allAvailableIngredients.OfType <Fermentable>().ToReadOnlyObservableCollection(); m_availableYeasts = allAvailableIngredients.OfType <Yeast>().ToReadOnlyObservableCollection(); List <Style> beerStyles = RecipeUtility.GetAvailableBeerStyles().OrderBy(style => style.Name).ToList(); m_availableBeerStyles = beerStyles.ToReadOnlyObservableCollection(); m_savedRecipes = new ObservableCollection <RecipeDataModel>(RecipeUtility.GetSavedRecipes(beerStyles)); GetSettings(); // set the current recipe to the first in the collection CurrentRecipe = m_savedRecipes.FirstOrDefault(); }
public bool TryAddPawnForModification(Pawn pawn, RecipeDef recipeDef) { Bill_Medical bill = new Bill_Medical(recipeDef); IEnumerable <BodyPartRecord> bodyparts = RecipeUtility.GetPartsToApplyOn(pawn, bill.recipe); if (pawn.health.surgeryBills.FirstShouldDoNow == null || pawn.health.surgeryBills.FirstShouldDoNow.recipe != WTH_DefOf.WTH_HackMechanoid && pawn.health.surgeryBills.FirstShouldDoNow.recipe != WTH_DefOf.WTH_InduceEmergencySignal) { pawn.health.surgeryBills.AddBill(bill); bill.Part = bodyparts.FirstOrDefault(); } /* * Need_Power powerNeed = pawn.needs.TryGetNeed<Need_Power>(); * if (powerNeed != null) * { * //discharge mech battery so pawns can work safely. * powerNeed.CurLevel = 0; * } */ pawn.jobs.StartJob(new Job(WTH_DefOf.WTH_Mechanoid_Rest, this), JobCondition.InterruptForced); if (pawn.jobs.curDriver != null) { pawn.jobs.posture = PawnPosture.LayingInBed; } return(true); }
public void SaveCurrentRecipe() { if (IsRecipeSelected) { RecipeUtility.SaveRecipe(CurrentRecipe); } }
public bool TryAddPawnForModification(Pawn pawn, RecipeDef recipeDef) { if ((!pawn.IsHacked() || (pawn.IsHacked() && pawn.Faction != Faction.OfPlayer))) { Bill_Medical bill = new Bill_Medical(recipeDef); IEnumerable <BodyPartRecord> bodyparts = RecipeUtility.GetPartsToApplyOn(pawn, bill.recipe); if (bodyparts.Count() == 0) { return(false); } if (pawn.health.surgeryBills.FirstShouldDoNow == null || pawn.health.surgeryBills.FirstShouldDoNow.recipe != WTH_DefOf.WTH_HackMechanoid) { pawn.health.surgeryBills.AddBill(bill); bill.Part = bodyparts.First(); } } Need_Power powerNeed = pawn.needs.TryGetNeed <Need_Power>(); if (powerNeed != null) { //discharge mech battery so pawns can work safely. powerNeed.CurLevel = 0; } pawn.jobs.TryTakeOrderedJob(new Job(WTH_DefOf.WTH_Mechanoid_Rest, this)); if (pawn.jobs.curDriver != null) { pawn.jobs.posture = PawnPosture.LayingInBed; } return(true); }
private void DeleteRecipe(RecipeDataModel recipe) { RecipeUtility.DeleteRecipe(recipe); // set the current recipe to the previous recipe in the collection int previousRecipeIndex = SavedRecipes.IndexOf(recipe) - 1; CurrentRecipe = previousRecipeIndex == -1 ? SavedRecipes.FirstOrDefault() : SavedRecipes[previousRecipeIndex]; SavedRecipes.Remove(recipe); }
private void AddNewRecipe() { SaveCurrentRecipe(); CurrentRecipe = RecipeUtility.CreateRecipe(); CurrentRecipe.Name = c_defaultRecipeName; CurrentRecipe.Size = m_settings.RecipeSize; CurrentRecipe.BoilTime = m_settings.BoilTime; CurrentRecipe.ExtractionEfficiency = m_settings.ExtractionEfficiency; CurrentRecipe.YeastIngredient.Weight = m_settings.YeastWeight; SavedRecipes.Add(CurrentRecipe); RaisePropertyChanged(nameof(IsRecipeSelected)); }
public BatchesViewModel() { m_addNewBatchCommand = new RelayCommand <RecipeDataModel>(AddNewBatch, CanAddNewBatch); m_deleteBatchCommand = new RelayCommand <BatchDataModel>(DeleteBatch); m_addGravityReadingCommand = new RelayCommand(AddGravityReading, CanAddGravityReading); m_deleteGravityReadingCommand = new RelayCommand <GravityReadingDataModel>(DeleteGravityReading); List <Style> beerStyles = RecipeUtility.GetAvailableBeerStyles().OrderBy(style => style.Name).ToList(); m_availableRecipes = new ObservableCollection <RecipeDataModel>(RecipeUtility.GetSavedRecipes(beerStyles)); m_savedBatches = new ObservableCollection <BatchDataModel>(BatchUtility.GetSavedBatches(m_availableRecipes)); CurrentBatch = m_savedBatches.FirstOrDefault(); }