public virtual void AddAttributeValue(Guid attributeValueId) { if (AttributeValues.Any(x => x.AttributeId == attributeValueId)) { AttributeValues.RemoveAll(x => x.AttributeId == attributeValueId); } AttributeValues.Add(new ProductAttribute(Id, attributeValueId)); }
public override bool Doable(AreaInteractable interactable, out string message) { switch (actionType) { case Type.WashDishes: if (room.dishesWashed) { message = string.Format($"<color={GameAction.errorColor}>Dishes are already washed."); return(false); } break; case Type.EatMeal: if (room.meals <= 0) { message = string.Format($"<color={GameAction.errorColor}>There are no meals."); return(false); } if (!room.dishesWashed) { message = string.Format($"<color={GameAction.errorColor}>All the dishes are dirty."); return(false); } break; case Type.EatIngredients: AttributeValues.RemoveAll(e => (e.type == Person.AttributeTypes.Hunger)); Required req = new Required(); req.type = Person.AttributeTypes.Hunger; req.netAmount = room.CheckIngredientsConsumption(); if (req.netAmount <= 0) { message = string.Format($"<color={GameAction.errorColor}>No ingredients in the kitchen."); return(false); } AttributeValues.Add(req); break; case Type.PrepareMeal: if (room.meals >= room.maxMeals) { message = string.Format($"<color={GameAction.errorColor}>Meals are at full capacity. [{room.meals}/{room.maxMeals}]"); } if (room.ingredients < mealCost) { message = string.Format($"<color={GameAction.errorColor}>Not enough ingredients for a meal. [{room.ingredients}/{mealCost}]"); return(false); } break; case Type.AddIngredients: FoodIngredient ingredient = interactable as FoodIngredient; if (ingredient) { int waste; if ((waste = room.CheckIngredients(ingredient.nutritionValue)) > 0) { if (ingredient.nutritionValue - waste <= 0) { message = string.Format($"<color={GameAction.errorColor}>Full food ingredient capacity [{room.ingredients}/{room.maxIngredients}]"); return(false); } message = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue-waste} ingredients."); message += string.Format($"<color={GameAction.errorColor}> \n -{waste} Wasted"); } else { message = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue} food ingredients."); } return(true); } break; default: break; } return(base.Doable(interactable, out message)); }