Exemplo n.º 1
0
        private void setTaxMultiplier(int value)
        {
            EconomyManager em    = Singleton <EconomyManager> .instance;
            FieldInfo      field = em.GetType().GetField("m_taxMultiplier", BindingFlags.NonPublic | BindingFlags.Instance);

            field.SetValue(em, value);
        }
Exemplo n.º 2
0
        //private void BudgetPanel_eventVisibilityChanged(UIComponent component, bool value)
        //{
        //    if (taxMultiplierPanel == null)
        //    {
        //        GameObject obj = new GameObject("TaxMultiplierPanel");
        //        obj.transform.parent = UIView.GetAView().cachedTransform;
        //        taxMultiplierPanel = obj.AddComponent<TaxMultiplierPanel>();
        //        taxMultiplierPanel.name = "TaxMultiplierPanel";
        //    }

        //    if (value && taxMultiplierPanel.absolutePosition == Vector3.zero)
        //    {
        //        Vector3 economyPanelPos = ToolsModifierControl.economyPanel.component.absolutePosition;
        //        taxMultiplierPanel.absolutePosition = new Vector3(economyPanelPos.x + 27, economyPanelPos.y + 598);
        //    }

        //    taxMultiplierPanel.isVisible = value;
        //}

        public int GetTaxMultiplier()
        {
            EconomyManager em    = Singleton <EconomyManager> .instance;
            FieldInfo      field = em.GetType().GetField("m_taxMultiplier", BindingFlags.NonPublic | BindingFlags.Instance);

            return((int)field.GetValue(em));
        }
Exemplo n.º 3
0
        public override int OnAddResource(EconomyResource resource, int amount, Service service, SubService subService, Level level)
        {
            if (resource == EconomyResource.TourismIncome)
            {
                // Changing the "amount" value does change the tourism income value displayed in the Economy panel,
                // but does NOT add actual money to the player. Therefore
                // the increased cash amount should be added manually, taking into account m_taxMultiplier value.

                EconomyManager em = Singleton <EconomyManager> .instance;

                // Get taxMultiplier value
                FieldInfo field           = em.GetType().GetField("m_taxMultiplier", BindingFlags.NonPublic | BindingFlags.Instance);
                int       m_taxMultiplier = (int)field.GetValue(em);

                int newAmount = amount * PTM_Options.Instance.TourismIncomeMultiplier;

                em.AddPrivateIncome(
                    (int)((newAmount - amount) * 10000L / m_taxMultiplier), // Ectract "amount", because it is already added, and exclude the influence of m_taxMultiplier
                    (ItemClass.Service)service,
                    (ItemClass.SubService)subService,
                    (ItemClass.Level)level,
                    100 // Set 100% tax rate because we want to add actual money as it is.
                    );

                return(newAmount);
            }

            // Office income multiplier
            if ((ItemClass.Service)service == ItemClass.Service.Office)
            {
                return(amount * PTM_Options.Instance.OfficeIncomeMultiplier);
            }

            // Office income multiplier
            if ((ItemClass.Service)service == ItemClass.Service.Industrial)
            {
                return(amount * PTM_Options.Instance.IndustryIncomeMultiplier);
            }

            // Bonus feature :)
            if ((ItemClass.SubService)subService == ItemClass.SubService.PublicTransportTaxi)
            {
                return(amount * PTM_Options.Instance.TaxiIncomeMultiplier);
            }

            return(amount);
        }
Exemplo n.º 4
0
        // Copy from EconomyManager.SimulationStepImpl()
        private int calculateVanillaTaxMultiplier()
        {
            EconomyManager em = Singleton <EconomyManager> .instance;

            FieldInfo field;

            field = em.GetType().GetField("m_lastCashDelta", BindingFlags.NonPublic | BindingFlags.Instance);
            long m_lastCashDelta = (long)field.GetValue(em);

            field = em.GetType().GetField("m_cashAmount", BindingFlags.NonPublic | BindingFlags.Instance);
            long m_cashAmount = (long)field.GetValue(em);

            field = em.GetType().GetField("m_totalExpenses", BindingFlags.NonPublic | BindingFlags.Instance);
            long[] m_totalExpenses = (long[])field.GetValue(em);

            long totalExpenses = 0L;

            for (int l = 0; l < 16; l++)
            {
                totalExpenses += m_totalExpenses[l];
            }
            long result;

            if (totalExpenses != 0L)
            {
                long num17 = 200000L;
                long num18 = (m_lastCashDelta - num17) * 20000L / totalExpenses;
                if (num18 > 0L)
                {
                    result = 5000L + 50000000L / (num18 + 10000L);
                }
                else if (num18 < 0L)
                {
                    result = 20000L + 200000000L / (num18 - 20000L);
                }
                else
                {
                    result = 10000L;
                }
                long num20 = m_cashAmount;
                long num21 = (long)Singleton <DistrictManager> .instance.m_districts.m_buffer[0].m_populationData.m_finalCount;
                if (num20 < 0L)
                {
                    num20 = 0L;
                }
                if (num21 < 0L)
                {
                    num21 = 0L;
                }
                result = result * 1000000000L / (1000000000L + num20);
                result = result * 1000000L / (1000000L + num21);
                if (result < 100L)
                {
                    result = 100L;
                }
                else if (result > 30000L)
                {
                    result = 30000L;
                }
            }
            else
            {
                result = 10000L;
            }

            return((int)result);
        }