public CookIngredientAction(PlayerControls player) { Logger.Log("CookIngredientAction instantiated"); this.player = player; state = 0; cookableContainer = ComponentUtil.GetClosestMatchingComponent <ClientCookableContainer>(player.transform.position, IsCookablePot); Logger.Log($"Cookable container pos: {Logger.FormatPosition(cookableContainer.transform.position)}"); bool cookableOnStation = false; foreach (var possibleCookingStation in Object.FindObjectsOfType <ClientCookingStation>()) { Logger.Log($"Station pos: {Logger.FormatPosition(possibleCookingStation.transform.position)}"); if (IsCookableOnStation(cookableContainer, possibleCookingStation)) { cookableOnStation = true; cookingStation = possibleCookingStation; break; } } if (cookableOnStation) { currentAction = new PathFindAction( player, cookingStation ); state = 3; } else { currentAction = new PathFindAction( player, cookableContainer ); } }
private bool IsCookableOnStation(ClientCookableContainer container, ClientCookingStation station) { if (ReflectionUtil.GetValue(station, "m_itemPot") == null) { Logger.Log("Cookable is not on station (null)"); return(false); } IClientCookable clientCookable = (IClientCookable)ReflectionUtil.GetValue(station, "m_itemPot"); if (clientCookable.Equals(container.GetCookingHandler())) { Logger.Log("Cookable is on station"); } else { Logger.Log("Cookable is not on station"); } return(clientCookable.Equals(container.GetCookingHandler())); }