public void AddIngredients(List <Ingredient> ingredients) { if (ingredients == null || ingredients.Count < 1) { return; } Main.AUDIO_PutDown(); foreach (Ingredient ingredient in ingredients) { Ingredient newIngredient = Ingredient.Grab(ingredient.m_ingredientType); Vector3 offset = 0.25f * Ingredient.GetPlacementOffset(m_currentIngredients.Count); if (!m_currentIngredients.Contains(newIngredient)) { m_currentIngredients.Add(newIngredient); } Transform parentTransform = (m_ingredientPos != null ? m_ingredientPos : transform); newIngredient.transform.localPosition = Vector3.zero; newIngredient.transform.position = parentTransform.position + offset; newIngredient.transform.SetParent(parentTransform); m_chopTimer += (newIngredient != null ? newIngredient.m_choppingTime : 0.0f); m_currentIngredientsMask |= newIngredient.m_ingredientMask; } }
// Main decision maker void CheckAction(MY_GAME_INPUTS gi) { if (m_model == null) { return; } // Only allow action when stopped if (m_state != PLAYER_STATE.IDLE) { return; } // No model if (m_model == null) { return; } // User is calling for an action - Find the context and trigger it if (gi.trigger1) { // Always stop FullStop(); if (m_focusTrashCan != null) { Main.AUDIO_PutDown(); ClearIngredients(); return; } // If I have an ingredien, either drop it or put it on the table if (m_ingredients.Count >= cm_MAX_INGREDIENTS) { // If I have an ingredient no table, drop it if (m_focusChoppingTable != null) { // If I have an ingredient and a table, drop it on the table m_focusChoppingTable.AddIngredients(m_ingredients); ClearIngredients(); } else { Main.AUDIO_Wrong(); Main.SendFloater(m_model.transform.position + Vector3.up, 3.0f, ("Inventory Full")); } } // Can carry more ingredients else { if (m_focusIngredient != null) { ChangeState(PLAYER_STATE.TRANSFER); } else { // Start chopping with a table full of ingredients) if (m_ingredients.Count < 1 && m_focusChoppingTable != null && m_focusChoppingTable.HasIngredients()) { ChangeState(PLAYER_STATE.CHOPPING); } else { if (m_focusChoppingTable != null) { m_focusChoppingTable.AddIngredients(m_ingredients); ClearIngredients(); } } } } } }