protected void SetUpIncentives(CityEventXmlIncentive[] incentives) { if (incentives != null) { m_eventData.m_incentives = new CityEventDataIncentives[incentives.Length]; for (int index = 0; index < incentives.Length; ++index) { CityEventXmlIncentive incentive = incentives[index]; CityEventDataIncentives dataIncentive = new CityEventDataIncentives() { itemCount = 0, name = incentive._name, returnCost = incentive._returnCost }; m_eventData.m_incentives[index] = dataIncentive; } } }
protected override bool CitizenRegistered(uint citizenID, ref Citizen person) { bool canAttend = true; float maxSpend = 0f; if (m_eventData.m_userEvent) { SimulationManager simulationManager = Singleton <SimulationManager> .instance; Citizen.Wealth wealth = person.WealthLevel; switch (wealth) { case Citizen.Wealth.Low: maxSpend = 30f + simulationManager.m_randomizer.Int32(60); break; case Citizen.Wealth.Medium: maxSpend = 80f + simulationManager.m_randomizer.Int32(80); break; case Citizen.Wealth.High: maxSpend = 120f + simulationManager.m_randomizer.Int32(320); break; } if (m_eventCosts != null) { maxSpend -= m_eventCosts._entry; canAttend = maxSpend > 0; if (m_eventData.m_incentives != null && m_eventData.m_incentives.Length > 0) { int startFrom = simulationManager.m_randomizer.Int32(0, m_eventData.m_incentives.Length - 1); int index = startFrom; string buying = m_eventData.m_eventName + " "; do { CityEventDataIncentives incentive = m_eventData.m_incentives[index]; if (incentive.boughtItems < incentive.itemCount && maxSpend - incentive.returnCost >= 0) { maxSpend -= incentive.returnCost; ++incentive.boughtItems; buying += "[" + incentive.name + " (" + incentive.boughtItems + "/" + incentive.itemCount + ")] "; } if (++index >= m_eventData.m_incentives.Length) { index = 0; } } while (index != startFrom); CimTools.CimToolsHandler.CimToolBase.DetailedLogger.Log(buying); } } } if (!canAttend) { CimTools.CimToolsHandler.CimToolBase.DetailedLogger.Log("Cim is too poor to attend the event :("); } return(canAttend); }