Exemplo n.º 1
0
        public static void LoadShops(GameInstanceSave gameInstanceSave, SimGameState __instance)
        {
            Control.State.CurrentSystem = __instance.CurSystem;
            Control.State.Sim           = __instance;

            SerializableReferenceContainer globalReferences = gameInstanceSave.GlobalReferences;

            Control.LogDebug(DInfo.SaveLoad, "Loading Shops");
            foreach (var shop in Control.Shops)
            {
                if (shop is ISaveShop save)
                {
                    var name = "Shop" + shop.Name;
                    Control.LogDebug(DInfo.SaveLoad, "- " + shop.Name);
                    try
                    {
                        var Shop = globalReferences.GetItem <Shop>(name);
                        save.SetLoadedShop(Shop);

                        Control.LogDebug(DInfo.SaveLoad, "-- " + shop.Name + " Loaded");
                        Control.LogDebug(DInfo.SaveLoad, $"-- total {Shop.ActiveInventory.Count} items");
                    }
                    catch (Exception)
                    {
                        Control.LogError($"Error finding {name} Create new");
                        shop.RefreshShop();
                        Control.LogDebug(DInfo.SaveLoad, "-- total " + save.GetShopToSave().ActiveInventory.Count + " items");
                    }
                }
                else
                {
                    shop.RefreshShop();
                }
            }

            //Control.Log($"Hated: {__instance.Constants.Story.HatedRepShopAdjustment}");
            //Control.Log($"Disliked: {__instance.Constants.Story.DislikedRepShopAdjustment}");
            //Control.Log($"Indifferent: {__instance.Constants.Story.IndifferentRepShopAdjustment}");
            //Control.Log($"Liked: {__instance.Constants.Story.LikedRepShopAdjustment}");
            //Control.Log($"Friendly: {__instance.Constants.Story.FriendlyRepShopAdjustment}");
            //Control.Log($"Honored: {__instance.Constants.Story.HonoredRepShopAdjustment}");
        }
        public static bool Prefix(AbstractActor __instance, SerializableReferenceContainer references, CombatGameState loadedState,
                                  ref bool ____isShutDown, bool ___underscoreIsShutDown,
                                  ref string ____lanceId, string ___underscoreLanceID,
                                  ref string ____spawnerId, string ___underscoreSpawnerID,
                                  ref string ____teamId, string ___underscoreTeamID,
                                  ref Team ____team,
                                  ref Lance ____lance,
                                  ref bool ____hasHandledDeath, bool ___serializableHasHandledDeath,
                                  ref int ____deathLocation, int ___serializableDeathLocation,
                                  ref DeathMethod ____deathMethod, DeathMethod ___serializableDeathMethod,
                                  List <Weapon> ___weapons
                                  )
        {
            //SkillBasedInit.Logger.Log($"AbstractActor:Hydrate - preventing native call to allow deserialization of initiative");

            Traverse.Create(__instance).Property("Combat").SetValue(loadedState);

            ____isShutDown      = ___underscoreIsShutDown;
            ____lanceId         = ___underscoreLanceID;
            ____spawnerId       = ___underscoreSpawnerID;
            ____teamId          = ___underscoreTeamID;
            ____team            = references.GetItem <Team>(__instance, "_team");
            ____lance           = ____team.GetLanceByUID(____lanceId);
            ____hasHandledDeath = ___serializableHasHandledDeath;
            ____deathLocation   = ___serializableDeathLocation;
            ____deathMethod     = ___serializableDeathMethod;
            if (__instance.BehaviorTree != null)
            {
                __instance.BehaviorTree.Hydrate(loadedState, references);
            }
            ___weapons = references.GetItemList <Weapon>(__instance, "Weapons");
            foreach (Weapon weapon in __instance.Weapons)
            {
                weapon.Hydrate(references);
                __instance.allComponents.Add(weapon);
            }
            __instance.ammoBoxes = references.GetItemList <AmmunitionBox>(__instance, "AmmoBox");
            foreach (AmmunitionBox ammunitionBox in __instance.ammoBoxes)
            {
                ammunitionBox.Hydrate(references);
                __instance.allComponents.Add(ammunitionBox);
            }
            __instance.jumpjets = references.GetItemList <Jumpjet>(__instance, "JumpJets");
            foreach (Jumpjet jumpjet in __instance.jumpjets)
            {
                jumpjet.Hydrate(references);
                __instance.allComponents.Add(jumpjet);
            }
            __instance.ImaginaryLaserWeapon = references.GetItem <Weapon>(__instance, "ImaginaryLaser");
            if (__instance.ImaginaryLaserWeapon != null)
            {
                __instance.ImaginaryLaserWeapon.Hydrate(references);
            }
            if (__instance.CustomHeraldryDef != null)
            {
                Traverse requestResources = Traverse.Create(__instance).Method("RequestResources", new Type[] { typeof(DataManager), typeof(Action) });
                requestResources.GetValue(new object[] { loadedState.DataManager, true });
            }

            // OriginalLogic: Initiative > 0 && Initiative < 6;
            if (!(__instance.Initiative > 0 && __instance.Initiative <= Mod.MaxPhase))
            {
                Mod.Log.Info(string.Format("Loading an AbstractActor of type {0} with an invalid initiative of {1}, Reverting to BaseInitiative", __instance.ClassName, __instance.Initiative));
                __instance.Initiative = 1;
            }

            return(false);
        }