private BrokenRibSaveDataProxy ConvertBackBrokenRib(BrokenRibSaveDataProxy proxy, Dictionary <AfflictionType, List <Affliction> > afflictionDict)
        {
            proxy = proxy ?? new BrokenRibSaveDataProxy();
            var brokenRibs = afflictionDict.Get(AfflictionType.BrokenRib)?.Cast <BrokenRib>().ToList();

            if (brokenRibs == null)
            {
                return((proxy.m_CausesLocIDs?.Count > 0) ? new BrokenRibSaveDataProxy() : proxy);
            }
            proxy.m_BandagesApplied         = new List <int>();
            proxy.m_CausesLocIDs            = new List <string>();
            proxy.m_ElapsedRestList         = new List <float>();
            proxy.m_Locations               = new List <int>();
            proxy.m_NumHoursRestForCureList = new List <float>();
            proxy.m_PainKillersTaken        = new List <int>();
            foreach (var brokenRib in brokenRibs)
            {
                proxy.m_BandagesApplied.Add(brokenRib.BandagesApplied);
                proxy.m_CausesLocIDs.Add(brokenRib.CauseLocID);
                proxy.m_ElapsedRestList.Add(brokenRib.ElapsedRest);
                proxy.m_Locations.Add(brokenRib.Location);
                proxy.m_NumHoursRestForCureList.Add(brokenRib.NumHoursRestForCure);
                proxy.m_PainKillersTaken.Add(brokenRib.PainKillersTaken);
            }
            return(proxy);
        }
 private void ConvertBrokenRib(BrokenRibSaveDataProxy proxy)
 {
     if (proxy == null || proxy.m_CausesLocIDs == null)
     {
         return;
     }
     for (int i = 0; i < proxy.m_Locations.Count; i++)
     {
         Negative.Add(new BrokenRib(negative)
         {
             AfflictionType      = AfflictionType.BrokenRib,
             Location            = proxy.m_Locations[i],
             BandagesApplied     = proxy.m_BandagesApplied[i],
             ElapsedRest         = proxy.m_ElapsedRestList[i],
             NumHoursRestForCure = proxy.m_NumHoursRestForCureList[i],
             PainKillersTaken    = proxy.m_PainKillersTaken[i],
         });
     }
 }
        public GlobalSaveGameFormat SerializeTo(GlobalSaveGameFormat proxy)
        {
            var afflictions = new Dictionary <AfflictionType, List <Affliction> >();

            foreach (var affliction in Negative)
            {
                if (!afflictions.ContainsKey(affliction.AfflictionType))
                {
                    afflictions.Add(affliction.AfflictionType, new List <Affliction>());
                }
                afflictions[affliction.AfflictionType].Add(affliction);
            }

            if (afflictions.ContainsKey(AfflictionType.Hypothermia))
            {
                proxy.m_HypothermiaSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.Hypothermia][0]).proxy;
            }

            var frostBiteProxy = new FrostBiteSaveDataProxy();

            frostBiteProxy.m_LocationsCurrentFrostbiteDamage = new float[11];
            frostBiteProxy.m_LocationsWithActiveFrostbite    = new int[0];
            frostBiteProxy.m_LocationsWithFrostbiteRisk      = new int[0];
            if (afflictions.ContainsKey(AfflictionType.Frostbite))
            {
                frostBiteProxy.m_LocationsWithActiveFrostbite = afflictions[AfflictionType.Frostbite].Select(f => f.Location).ToArray();
            }
            if (afflictions.ContainsKey(AfflictionType.FrostbiteRisk))
            {
                var locations = new List <int>();
                foreach (var frostBiteRisk in afflictions[AfflictionType.FrostbiteRisk])
                {
                    locations.Add(frostBiteRisk.Location);
                    frostBiteProxy.m_LocationsCurrentFrostbiteDamage[frostBiteRisk.Location] = ((FrostBiteRisk)frostBiteRisk).Damage;
                }
            }
            proxy.m_FrostbiteSerialized = Util.SerializeObject(frostBiteProxy);

            if (afflictions.ContainsKey(AfflictionType.FoodPoisioning))
            {
                proxy.m_FoodPoisoningSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.FoodPoisioning][0]).proxy;
            }

            if (afflictions.ContainsKey(AfflictionType.Dysentery))
            {
                proxy.m_DysenterySerialized = ((AfflictionWithProxy)afflictions[AfflictionType.Dysentery][0]).proxy;
            }

            if (afflictions.ContainsKey(AfflictionType.SprainedAnkle))
            {
                var sprainedAnkleProxy = new SprainedAnkleSaveDataProxy();
                var sprains            = afflictions[AfflictionType.SprainedAnkle];
                sprainedAnkleProxy.m_CausesLocIDs      = new string[sprains.Count];
                sprainedAnkleProxy.m_DurationHoursList = new float[sprains.Count];
                sprainedAnkleProxy.m_ElapsedHoursList  = new float[sprains.Count];
                sprainedAnkleProxy.m_ElapsedRestList   = new float[sprains.Count];
                sprainedAnkleProxy.m_Locations         = new int[sprains.Count];

                for (int i = 0; i < sprains.Count; i++)
                {
                    var sprain = (SprainAffliction)sprains[i];
                    sprainedAnkleProxy.m_CausesLocIDs[i]      = sprain.CauseLocID;
                    sprainedAnkleProxy.m_DurationHoursList[i] = sprain.Duration;
                    sprainedAnkleProxy.m_ElapsedHoursList[i]  = sprain.ElapsedHours;
                    sprainedAnkleProxy.m_ElapsedRestList[i]   = sprain.ElapsedHours;
                    sprainedAnkleProxy.m_Locations[i]         = sprain.Location;
                }
                proxy.m_SprainedAnkleSerialized = Util.SerializeObject(sprainedAnkleProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.SprainedWrist))
            {
                var sprainedWristProxy = new SprainedWristSaveDataProxy();
                var sprains            = afflictions[AfflictionType.SprainedWrist];
                sprainedWristProxy.m_CausesLocIDs      = new string[sprains.Count];
                sprainedWristProxy.m_DurationHoursList = new float[sprains.Count];
                sprainedWristProxy.m_ElapsedHoursList  = new float[sprains.Count];
                sprainedWristProxy.m_ElapsedRestList   = new float[sprains.Count];
                sprainedWristProxy.m_Locations         = new int[sprains.Count];

                for (int i = 0; i < sprains.Count; i++)
                {
                    var sprain = (SprainAffliction)sprains[i];
                    sprainedWristProxy.m_CausesLocIDs[i]      = sprain.CauseLocID;
                    sprainedWristProxy.m_DurationHoursList[i] = sprain.Duration;
                    sprainedWristProxy.m_ElapsedHoursList[i]  = sprain.ElapsedHours;
                    sprainedWristProxy.m_ElapsedRestList[i]   = sprain.ElapsedHours;
                    sprainedWristProxy.m_Locations[i]         = sprain.Location;
                }
                proxy.m_SprainedWristSerialized = Util.SerializeObject(sprainedWristProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.SprainedWristMajor))
            {
                var sprainedWristMajorProxy = new SprainedWristMajorSaveDataProxy();
                var sprains = afflictions[AfflictionType.SprainedWristMajor];
                sprainedWristMajorProxy.m_CausesLocIDs    = new string[sprains.Count];
                sprainedWristMajorProxy.m_ElapsedRestList = new float[sprains.Count];
                sprainedWristMajorProxy.m_Locations       = new int[sprains.Count];

                for (int i = 0; i < sprains.Count; i++)
                {
                    var sprain = (SprainedWristMajor)sprains[i];
                    sprainedWristMajorProxy.m_Locations[i]       = sprain.Location;
                    sprainedWristMajorProxy.m_ElapsedRestList[i] = sprain.ElapsedRest;
                    sprainedWristMajorProxy.m_CausesLocIDs[i]    = sprain.CauseLocID;
                }
                proxy.m_SprainedWristMajorSerialized = Util.SerializeObject(sprainedWristMajorProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.Burns))
            {
                proxy.m_BurnsSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.Burns][0]).proxy;
            }

            if (afflictions.ContainsKey(AfflictionType.BurnsElectric))
            {
                proxy.m_BurnsSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.BurnsElectric][0]).proxy;
            }

            if (afflictions.ContainsKey(AfflictionType.BloodLoss))
            {
                var bloodLossProxy = new BloodLossSaveDataProxy();
                var bloodLosses    = afflictions[AfflictionType.BloodLoss];
                bloodLossProxy.m_CausesLocIDs      = new string[bloodLosses.Count];
                bloodLossProxy.m_DurationHoursList = new float[bloodLosses.Count];
                bloodLossProxy.m_ElapsedHoursList  = new float[bloodLosses.Count];
                bloodLossProxy.m_Locations         = new int[bloodLosses.Count];

                for (int i = 0; i < bloodLosses.Count; i++)
                {
                    var bloodLoss = (BloodLoss)bloodLosses[i];
                    bloodLossProxy.m_CausesLocIDs[i]      = bloodLoss.CauseLocID;
                    bloodLossProxy.m_DurationHoursList[i] = bloodLoss.DurationHours;
                    bloodLossProxy.m_ElapsedHoursList[i]  = bloodLoss.ElapsedHours;
                    bloodLossProxy.m_Locations[i]         = bloodLoss.Location;
                }
                proxy.m_BloodLossSerialized = Util.SerializeObject(bloodLossProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.Infection))
            {
                var infectionProxy = new InfectionSaveDataProxy();
                var infections     = afflictions[AfflictionType.Infection];
                infectionProxy.m_AntibioticsTakenList = new bool[infections.Count];
                infectionProxy.m_CausesLocIDs         = new string[infections.Count];
                infectionProxy.m_DurationHoursList    = new float[infections.Count];
                infectionProxy.m_ElapsedHoursList     = new float[infections.Count];
                infectionProxy.m_ElapsedRestList      = new float[infections.Count];
                infectionProxy.m_Locations            = new int[infections.Count];

                for (int i = 0; i < infections.Count; i++)
                {
                    var infection = (Infection)infections[i];
                    infectionProxy.m_AntibioticsTakenList[i] = infection.AntibioticsTaken;
                    infectionProxy.m_CausesLocIDs[i]         = infection.CauseLocID;
                    infectionProxy.m_DurationHoursList[i]    = infection.DurationHours;
                    infectionProxy.m_ElapsedHoursList[i]     = infection.ElapsedHours;
                    infectionProxy.m_ElapsedRestList[i]      = infection.ElapsedRest;
                    infectionProxy.m_Locations[i]            = infection.Location;
                }
                proxy.m_InfectionSerialized = Util.SerializeObject(infectionProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.InfectionRisk))
            {
                var infectionRisk  = new InfectionRiskSaveDataProxy();
                var infectionRisks = afflictions[AfflictionType.InfectionRisk];
                infectionRisk.m_CausesLocIDs               = new string[infectionRisks.Count];
                infectionRisk.m_DurationHoursList          = new float[infectionRisks.Count];
                infectionRisk.m_ElapsedHoursList           = new float[infectionRisks.Count];
                infectionRisk.m_Locations                  = new int[infectionRisks.Count];
                infectionRisk.m_AntisepticTakenList        = new bool[infectionRisks.Count];
                infectionRisk.m_CurrentInfectionChanceList = new float[infectionRisks.Count];

                for (int i = 0; i < infectionRisks.Count; i++)
                {
                    var infection = (InfectionRisk)infectionRisks[i];
                    infectionRisk.m_CausesLocIDs[i]               = infection.CauseLocID;
                    infectionRisk.m_DurationHoursList[i]          = infection.DurationHours;
                    infectionRisk.m_ElapsedHoursList[i]           = infection.ElapsedHours;
                    infectionRisk.m_Locations[i]                  = infection.Location;
                    infectionRisk.m_AntisepticTakenList[i]        = infection.AntisepticTaken;
                    infectionRisk.m_CurrentInfectionChanceList[i] = infection.CurrentInfectionChance;
                }
                proxy.m_InfectionRiskSerialized = Util.SerializeObject(infectionRisk);
            }

            if (afflictions.ContainsKey(AfflictionType.BrokenRib))
            {
                var brokenRibProxy = new BrokenRibSaveDataProxy();
                var brokenRibs     = afflictions[AfflictionType.BrokenRib];
                brokenRibProxy.m_BandagesApplied         = new int[brokenRibs.Count];
                brokenRibProxy.m_CausesLocIDs            = new string[brokenRibs.Count];
                brokenRibProxy.m_ElapsedRestList         = new float[brokenRibs.Count];
                brokenRibProxy.m_Locations               = new int[brokenRibs.Count];
                brokenRibProxy.m_NumHoursRestForCureList = new float[brokenRibs.Count];
                brokenRibProxy.m_PainKillersTaken        = new int[brokenRibs.Count];

                for (int i = 0; i < brokenRibs.Count; i++)
                {
                    var brokenRib = (BrokenRib)brokenRibs[i];
                    brokenRibProxy.m_BandagesApplied[i]         = brokenRib.BandagesApplied;
                    brokenRibProxy.m_CausesLocIDs[i]            = brokenRib.CauseLocID;
                    brokenRibProxy.m_ElapsedRestList[i]         = brokenRib.ElapsedRest;
                    brokenRibProxy.m_Locations[i]               = brokenRib.Location;
                    brokenRibProxy.m_NumHoursRestForCureList[i] = brokenRib.NumHoursRestForCure;
                    brokenRibProxy.m_PainKillersTaken[i]        = brokenRib.PainKillersTaken;
                }
                proxy.m_BrokenRibSerialized = Util.SerializeObject(brokenRibProxy);
            }

            if (afflictions.ContainsKey(AfflictionType.CabinFever))
            {
                proxy.m_CabinFeverSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.CabinFever][0]).proxy;
            }

            if (afflictions.ContainsKey(AfflictionType.IntestinalParasites))
            {
                proxy.m_IntestinalParasitesSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.IntestinalParasites][0]).proxy;
            }
            else if (afflictions.ContainsKey(AfflictionType.IntestinalParasitesRisk))
            {
                proxy.m_IntestinalParasitesSerialized = ((AfflictionWithProxy)afflictions[AfflictionType.IntestinalParasitesRisk][0]).proxy;
            }

            return(proxy);
        }