Ejemplo n.º 1
0
        public override void OnSave()
        {
            GumSaveData data = new GumSaveData(new List <Vector3>(), new List <Quaternion>(), new List <int>(), OverdoseAmount);

            foreach (GameObject o in GameObject.FindObjectsOfType <GameObject>().Where(o => o.GetComponent <GumBehaviour>() != null && !_list.Contains(o)))
            {
                data.Pos.Add(o.transform.position);
                data.Rot.Add(o.transform.rotation);
                data.GumCount.Add(o.GetComponent <GumBehaviour>().Count);
            }
            GumSaveData.Serialize(data, GumSaveData.SavePath);
        }
Ejemplo n.º 2
0
        public override void OnLoad()
        {
            // Original
            AssetBundle ab       = LoadAssets.LoadBundle(this, "pack.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("pack.prefab");

            _pack      = GameObject.Instantiate <GameObject>(original);
            _pack.name = "nicotine gum";
            Material m = new Material(Shader.Find("Standard"));

            m.mainTexture = original.GetComponent <Renderer>().material.mainTexture;
            _pack.GetComponent <Renderer>().material = m;

            GameObject.Destroy(original);
            ab.Unload(false);

            // Load save
            GumSaveData data = GumSaveData.Deserialize <GumSaveData>(GumSaveData.SavePath);

            for (int i = 0; i < data.Pos.Count; ++i)
            {
                GameObject gum = GameObject.Instantiate <GameObject>(_pack);
                gum.transform.position = data.Pos[i];
                gum.transform.rotation = data.Rot[i];
                GumBehaviour c = gum.AddComponent <GumBehaviour>();
                c.ShopList = _list;
                c.Count    = data.GumCount[i];
                c.Activate();
                c.SetBought();
            }

            // Setup
            FatigueFsm    = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerFatigue");
            StressFsm     = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerStress");
            StressRateFsm = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerStressRate");
            DrunkFsm      = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerDrunk");
            ThirstFsm     = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerThirst");
            InitShop();
            ConsoleCommand.Add(new GumCommand(this));

            ModConsole.Print($"[Gum] has loaded without issue");
        }