Esempio n. 1
0
        private double ComputeWarRatio()
        {
            double peaceCounter = 0f;
            double warCounter   = 0f;

            foreach (EmpireData empire in GlobalData.world.empires)
            {
                EmpireStanding standings = Diplomacy.FindStandings(m_empireData, empire);
                if (standings == null)
                {
                    continue;
                }
                if ((Diplomacy.EmpireType)empire.empireType == Diplomacy.EmpireType.TRUE_HOSTILE)
                {
                    continue;
                }
                if (standings.atWar)
                {
                    warCounter += 1.0f;
                }
                else
                {
                    peaceCounter += 1.0f;
                }
            }
            return(warCounter / (warCounter + peaceCounter));
        }
        /**
         * Initialize the mod
         */
        private void InitializeMod()
        {
            foreach (EmpireData empire in GlobalData.world.empires)
            {
                m_empireManagers.Add(new EmpireManager(empire));
            }
            foreach (EmpireManager empire in m_empireManagers)
            {
                empire.Initialize();
            }
            Diplomacy.Initialize();

            MyAPIGateway.Session.DamageSystem.RegisterBeforeDamageHandler(0, GenericDamageHandler);
            MyAPIGateway.Session.DamageSystem.RegisterDestroyHandler(0, GenericDamageHandler);

            Util.Notify("Welcome to FSTC.");
        }
Esempio n. 3
0
        public void TakeStandingsHit(EmpireData aggressorEmpire)
        {
            if (m_nextStandingsChange > GlobalData.world.currentTick)
            {
                return;
            }
            m_nextStandingsChange = GlobalData.world.currentTick + Tick.Seconds(STANDINGS_DEBOUCE_SEC);

            EmpireData.EmpireStanding standings = Diplomacy.FindStandings(m_data, aggressorEmpire);
            if (standings == null)
            {
                return;
            }
            standings.reputation--;
            if (standings.atWar)
            {
                return;
            }
            Diplomacy.CallPolice(m_data, aggressorEmpire);
            if (standings.reputation < 0)
            {
                Diplomacy.DeclareWar(m_data, aggressorEmpire);
            }
        }