Exemple #1
0
 void OnTick(object sender, EventArgs e)
 {
     if (ModOptions.instance == null)
     {
         return;
     }
     if (ModOptions.instance.msAutoSaveInterval <= 0)               //reset if invalid
     {
         ModOptions.instance.msAutoSaveInterval = 3000;
     }
     Wait(ModOptions.instance.msAutoSaveInterval);
     if (gangDataDirty)
     {
         PersistenceHandler.SaveToFile(GangManager.instance.gangData, "GangData", gangDataNotifySave);
         gangDataDirty      = false;
         gangDataNotifySave = false;
         return;
     }
     if (zoneDataDirty)
     {
         PersistenceHandler.SaveToFile(ZoneManager.instance.zoneData, "TurfZoneData", zoneDataNotifySave);
         zoneDataDirty      = false;
         zoneDataNotifySave = false;
         return;
     }
 }
Exemple #2
0
        /// <summary>
        /// adds the gang to a xml file that contains a list of gangs that have been wiped out,
        ///  so that the player can reuse their data in the future
        /// </summary>
        /// <param name="gangToAdd"></param>
        public void AddGangToWipedOutList(Gang gangToAdd)
        {
            List <Gang> WOList = PersistenceHandler.LoadFromFile <List <Gang> >("wipedOutGangsList");

            if (WOList == null)
            {
                WOList = new List <Gang>();
            }
            WOList.Add(gangToAdd);
            PersistenceHandler.SaveToFile(WOList, "wipedOutGangsList");
        }
        public static bool AddVehicleAndSavePool(PotentialGangVehicle newCar)
        {
            //check if there isn't an identical entry in the pool
            if (!CarPool.HasIdenticalEntry(newCar))
            {
                CarPool.carList.Add(newCar);
                PersistenceHandler.SaveToFile <PotentialCarPool>(CarPool, "VehiclePool");
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public static bool AddMemberAndSavePool(PotentialGangMember newMember)
        {
            //check if there isn't an identical entry in the pool
            if (!MemberPool.HasIdenticalEntry(newMember))
            {
                MemberPool.memberList.Add(newMember);
                PersistenceHandler.SaveToFile <PotentialMemberPool>(MemberPool, "MemberPool");
                return(true);
            }

            return(false);
        }
        public static bool RemoveVehicleAndSavePool(PotentialGangVehicle newCar)
        {
            int identicalEntryIndex = 0;

            //check if there is an identical entry in the pool
            if (CarPool.HasIdenticalEntry(newCar, ref identicalEntryIndex))
            {
                CarPool.carList.RemoveAt(identicalEntryIndex);
                PersistenceHandler.SaveToFile <PotentialCarPool>(CarPool, "VehiclePool");
                return(true);
            }

            return(false);
        }
Exemple #6
0
        public static bool RemoveMemberAndSavePool(PotentialGangMember newMember)
        {
            //find an identical or similar entry and remove it
            PotentialGangMember similarEntry = MemberPool.GetSimilarEntry(newMember);

            if (similarEntry != null)
            {
                MemberPool.memberList.Remove(similarEntry);
                PersistenceHandler.SaveToFile <PotentialMemberPool>(MemberPool, "MemberPool");
                return(true);
            }

            return(false);
        }
Exemple #7
0
        public void LoadOptions()
        {
            ModOptions loadedOptions = PersistenceHandler.LoadFromFile <ModOptions>("ModOptions");

            if (loadedOptions != null)
            {
                //get the loaded options
                this.msAutoSaveInterval = loadedOptions.msAutoSaveInterval;

                this.gangMemberAggressiveness = loadedOptions.gangMemberAggressiveness;

                this.addToGroupKey   = loadedOptions.addToGroupKey;
                this.mindControlKey  = loadedOptions.mindControlKey;
                this.openGangMenuKey = loadedOptions.openGangMenuKey;
                this.openZoneMenuKey = loadedOptions.openZoneMenuKey;

                this.possibleGangFirstNames     = loadedOptions.possibleGangFirstNames;
                this.possibleGangLastNames      = loadedOptions.possibleGangLastNames;
                this.buyableWeapons             = loadedOptions.buyableWeapons;
                this.similarColors              = loadedOptions.similarColors;
                this.extraPlayerExclusiveColors = loadedOptions.extraPlayerExclusiveColors;

                this.startingGangMemberHealth = loadedOptions.startingGangMemberHealth;
                this.maxGangMemberHealth      = loadedOptions.maxGangMemberHealth;
                this.maxGangMemberArmor       = loadedOptions.maxGangMemberArmor;
                this.maxGangMemberAccuracy    = loadedOptions.maxGangMemberAccuracy;

                this.emptyZoneDuringWar = loadedOptions.emptyZoneDuringWar;
                this.maxDistToWarBlipBeforePlayerLeavesWar = loadedOptions.maxDistToWarBlipBeforePlayerLeavesWar;
                this.ticksBeforeWarEndWithPlayerAway       = loadedOptions.ticksBeforeWarEndWithPlayerAway;
                this.postWarBackupsAmount              = loadedOptions.postWarBackupsAmount;
                this.baseNumKillsBeforeWarVictory      = loadedOptions.baseNumKillsBeforeWarVictory;
                this.extraKillsPerTurfValue            = loadedOptions.extraKillsPerTurfValue;
                this.killsBetweenEnemySpawnReplacement = loadedOptions.killsBetweenEnemySpawnReplacement;
                this.ticksBetweenEnemySpawnReplacement = loadedOptions.ticksBetweenEnemySpawnReplacement;

                this.msTimeBetweenTurfRewards            = loadedOptions.msTimeBetweenTurfRewards;
                this.ticksBetweenGangAIUpdates           = loadedOptions.ticksBetweenGangAIUpdates;
                this.minMsTimeBetweenAttacksOnPlayerTurf = loadedOptions.minMsTimeBetweenAttacksOnPlayerTurf;
                this.ticksBetweenGangMemberAIUpdates     = loadedOptions.ticksBetweenGangMemberAIUpdates;
                this.baseRewardPerZoneOwned = loadedOptions.baseRewardPerZoneOwned;
                this.maxRewardPerZoneOwned  = loadedOptions.maxRewardPerZoneOwned;
                this.maxTurfValue           = loadedOptions.maxTurfValue;

                this.rewardMultiplierPerZone = loadedOptions.rewardMultiplierPerZone;

                this.baseCostToTakeTurf       = loadedOptions.baseCostToTakeTurf;
                this.rewardForTakingEnemyTurf = loadedOptions.rewardForTakingEnemyTurf;

                this.baseCostToUpgradeGeneralGangTurfValue = loadedOptions.baseCostToUpgradeGeneralGangTurfValue;
                this.baseCostToUpgradeSingleTurfValue      = loadedOptions.baseCostToUpgradeSingleTurfValue;
                this.baseCostToUpgradeArmor    = loadedOptions.baseCostToUpgradeArmor;
                this.baseCostToUpgradeHealth   = loadedOptions.baseCostToUpgradeHealth;
                this.baseCostToUpgradeAccuracy = loadedOptions.baseCostToUpgradeAccuracy;

                this.wanderingDriverDrivingStyle       = loadedOptions.wanderingDriverDrivingStyle;
                this.driverWithDestinationDrivingStyle = loadedOptions.driverWithDestinationDrivingStyle;

                this.numUpgradesUntilMaxMemberAttribute = loadedOptions.numUpgradesUntilMaxMemberAttribute;
                this.costToCallBackupCar            = loadedOptions.costToCallBackupCar;
                this.costToCallParachutingMember    = loadedOptions.costToCallParachutingMember;
                this.ticksCooldownBackupCar         = loadedOptions.ticksCooldownBackupCar;
                this.ticksCooldownParachutingMember = loadedOptions.ticksCooldownParachutingMember;

                this.minWantedFactorWhenInGangTurf = loadedOptions.minWantedFactorWhenInGangTurf;
                this.maxWantedLevelInMaxedGangTurf = loadedOptions.maxWantedLevelInMaxedGangTurf;
                this.freezeWantedLevelDuringWars   = loadedOptions.freezeWantedLevelDuringWars;

                this.notificationsEnabled      = loadedOptions.notificationsEnabled;
                this.loggerLevel               = loadedOptions.loggerLevel;
                this.preventAIExpansion        = loadedOptions.preventAIExpansion;
                this.membersSpawnWithMeleeOnly = loadedOptions.membersSpawnWithMeleeOnly;
                this.warAgainstPlayerEnabled   = loadedOptions.warAgainstPlayerEnabled;
                this.ambientSpawningEnabled    = loadedOptions.ambientSpawningEnabled;
                this.forceSpawnCars            = loadedOptions.forceSpawnCars;
                this.joypadControls            = loadedOptions.joypadControls;

                this.showGangMemberBlips = loadedOptions.showGangMemberBlips;

                this.gangsStartWithPistols               = loadedOptions.gangsStartWithPistols;
                this.gangsCanBeWipedOut                  = loadedOptions.gangsCanBeWipedOut;
                this.maxCoexistingGangs                  = loadedOptions.maxCoexistingGangs;
                this.extraProfitForAIGangsFactor         = loadedOptions.extraProfitForAIGangsFactor;
                this.spawnedMembersBeforeAmbientGenStops = loadedOptions.spawnedMembersBeforeAmbientGenStops;
                this.msBaseIntervalBetweenAmbientSpawns  = loadedOptions.msBaseIntervalBetweenAmbientSpawns;
                this.spawnedMemberLimit                  = loadedOptions.spawnedMemberLimit;
                this.numSpawnsReservedForCarsDuringWars  = loadedOptions.numSpawnsReservedForCarsDuringWars;
                this.minDistanceCarSpawnFromPlayer       = loadedOptions.minDistanceCarSpawnFromPlayer;
                this.minDistanceMemberSpawnFromPlayer    = loadedOptions.minDistanceMemberSpawnFromPlayer;
                this.maxDistanceCarSpawnFromPlayer       = loadedOptions.maxDistanceCarSpawnFromPlayer;
                this.maxDistanceMemberSpawnFromPlayer    = loadedOptions.maxDistanceMemberSpawnFromPlayer;

                if (similarColors.Count == 0)
                {
                    SetColorTranslationDefaultValues();
                }
                else
                {
                    if (similarColors[0].blipColors == null)
                    {
                        SetColorTranslationDefaultValues();
                    }
                }

                SaveOptions();
            }
            else
            {
                SetAllValuesToDefault();
                SetNameListsDefaultValues();
                SetColorTranslationDefaultValues();
                PersistenceHandler.SaveToFile(this, "ModOptions");
            }
        }
Exemple #8
0
 public void SaveOptions(bool notifyMsg = true)
 {
     PersistenceHandler.SaveToFile(this, "ModOptions", notifyMsg);
 }
Exemple #9
0
 public void SaveZoneData(bool notifySuccess = true)
 {
     PersistenceHandler.SaveToFile <TurfZoneData>(zoneData, "TurfZoneData", notifySuccess);
 }