// Method to attempt adding logs to campfire private void AddToFire() { // Step 1) Movement and pathing checks if (!MovementChecker()) // Check if position ready and movement finished { return; // False returned = not ready, so exit function } // Step 2) Check and set: timer, rotation and mesh if (!m_InPosition) // Use position flag to track rotation and mesh { transform.LookAt(new Vector3(m_Campfire.transform.position.x, // Look at resource transform.position.y, m_Campfire.transform.position.z)); // Ignore y component m_Mesh.SetMeshAlternate((int)m_CurrentTask, m_Alternate); // Set appropriate mesh m_InPosition = true; // Set ready flag } if (TimerChecker()) // Run timer checks and see if it's completed { if (m_Inventory.TakeAmount(1, (int)Resource.Log)) // Attempt to take a log from character inventory { if (m_Campfire.AddLogs(1)) // Attempt to add a log to campfire { m_TaskProgress += 1; // Increment task progress if (m_TaskProgress == m_TaskGoal) // Check if task goal now met { m_TaskCompleted = true; // Set success flag if (!m_Campfire.IsLit()) // Check if campfire is NOT lit { QueueNextTask(Task.Firelighting, Resource.Log); // Queue the light fire task at front of queue } return; // Exit function } m_Timer = m_TaskTimes[(int)m_CurrentTask]; // Otherwise reset timer return; // and exit function } m_Inventory.AddAmount(1, (int)Resource.Log); // Otherwise couldn't add to fire so return log to inventory } // Failed log withdrawal so quit task m_CantComplete = true; // Set failure flag return; // and exit } // Otherwise timer not complete so wait till it is } // End of AddLog() function