public override void Run(string[] args)
            {
                // Make sure the command is executed with arguments.
                if (args.Length < 1)
                {
                    ModConsole.Error("Incorrect number of arguments. See 'gps help' for details.");
                    return;
                }

                // Print the help text
                if (Array.Exists(args, e => e.ToLowerInvariant() == "help" || e == "-?"))
                {
                    ModConsole.Print(_helpString);
                    return;
                }

                // When starting or restarting, try to find -p and try to validate the following argument as a port number
                if (Array.Exists(args, e => e.ToLowerInvariant() == "start" || e.ToLowerInvariant() == "restart"))
                {
                    int p;
                    if ((p = Array.IndexOf(args, "-p")) >= 0 || (p = Array.IndexOf(args, "--port")) >= 0)
                    {
                        if (args.Length >= p + 1 && int.TryParse(args[p + 1], out int portNumber) && portNumber <= 65535 && portNumber >= 1)
                        {
                            _mod._port = portNumber;
                        }
                        else
                        {
                            ModConsole.Print(_helpString);
                        }
                    }
                }

                // Restart
                if (Array.Exists(args, e => e.ToLowerInvariant() == "restart"))
                {
                    _mod.StopServer();
                    _mod.StartServer();
                    return;
                }

                // Start
                if (Array.Exists(args, e => e.ToLowerInvariant() == "start"))
                {
                    _mod.StartServer();
                    return;
                }

                // Stop
                if (Array.Exists(args, e => e.ToLowerInvariant() == "stop"))
                {
                    _mod.StopServer();
                    return;
                }

                // Write to file
                if (Array.Exists(args, e => e.ToLowerInvariant() == "write"))
                {
                    if (Array.Exists(args, e => e.ToLowerInvariant() == "json"))
                    {
                        using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.json")))
                        {
                            writer.Write(_mod.GetJsonContent());
                        }
                    }
                    else if (Array.Exists(args, e => e.ToLowerInvariant() == "xml"))
                    {
                        using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.xml")))
                        {
                            writer.Write(_mod.GetXmlContent());
                        }
                    }
                    else
                    {
                        using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.json")))
                        {
                            writer.Write(_mod.GetJsonContent());
                        }
                        using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.xml")))
                        {
                            writer.Write(_mod.GetXmlContent());
                        }
                    }
                    ModConsole.Print("Completed writing - check the mod's config folder.");
                    return;
                }

                // If this point is reached, there were no valid commands to execute.
                ModConsole.Error("Invalid arguments. See 'gps help' for details.");
            }
Beispiel #2
0
        public void Load()
        {
            string old_path  = Path.Combine(ModLoader.GetModConfigFolder(this), "case.save");
            string old_path2 = Path.Combine(ModLoader.GetModConfigFolder(this), "cd.save");

            if (File.Exists(old_path))
            {
                File.Delete(old_path);
            }
            if (File.Exists(old_path2))
            {
                File.Delete(old_path2);
            }

            CDSaveData data = SaveLoad.DeserializeSaveFile <CDSaveData>(this, "cdplayer.save");

            if (data != null)
            {
                if (data.rackpurchased)
                {
                    rack10.transform.position = data.rackpos;
                    rack10.transform.rotation = Quaternion.Euler(data.rackrotX, data.rackrotY, data.rackrotZ);
                    rack10.SetActive(true);
                    rack10.GetComponent <CDRack>().purchased = true;
                }
                foreach (GameObject go in listOfCases)
                {
                    for (int i = 0; i < data.cases.Count; i++)
                    {
                        if (data.cases[i].CDName == go.GetComponent <CDCase>().CDName&& data.cases[i].purchased)
                        {
                            if (!data.cases[i].inRack)
                            {
                                go.transform.position = data.cases[i].pos;
                                go.transform.rotation = Quaternion.Euler(data.cases[i].rotX, data.cases[i].rotY, data.cases[i].rotZ);
                            }
                            else
                            {
                                go.GetComponent <Rigidbody>().isKinematic      = true;
                                go.GetComponent <Rigidbody>().detectCollisions = false;
                                go.transform.SetParent(rack10.transform.GetChild(data.cases[i].inRackSlot), false);
                                go.transform.localPosition            = Vector3.zero;
                                go.transform.localEulerAngles         = Vector3.zero;
                                go.GetComponent <CDCase>().inRack     = true;
                                go.GetComponent <CDCase>().inRackSlot = data.cases[i].inRackSlot;
                                go.name = "cd case (" + (data.cases[i].inRackSlot + 1).ToString() + ")(item4)";
                            }
                            go.GetComponent <CDCase>().purchased = true;
                            go.SetActive(true);
                        }
                    }
                }
                foreach (GameObject go in listOfCDs)
                {
                    for (int i = 0; i < data.cds.Count; i++)
                    {
                        if (data.cds[i].CDName == go.GetComponent <CD>().CDName)
                        {
                            if (!data.cds[i].inCase)
                            {
                                go.GetComponent <CD>().inCase = false;
                                LoadAssets.MakeGameObjectPickable(go);
                                go.transform.SetParent(null);
                                go.transform.position = data.cds[i].pos;
                                go.transform.rotation = Quaternion.Euler(data.cds[i].rotX, data.cds[i].rotY, data.cds[i].rotZ);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public void Load()
        {
            string old_path  = Path.Combine(ModLoader.GetModConfigFolder(this), "case.save");
            string old_path2 = Path.Combine(ModLoader.GetModConfigFolder(this), "cd.save");

            if (File.Exists(old_path))
            {
                File.Delete(old_path);
            }
            if (File.Exists(old_path2))
            {
                File.Delete(old_path2);
            }

            CDSaveData data = SaveLoad.DeserializeSaveFile <CDSaveData>(this, "cdplayer.save");

            if (data != null)
            {
                if (data.rackpurchased)
                {
                    rack10.transform.position    = data.rackpos;
                    rack10.transform.eulerAngles = new Vector3(data.rackrotX, data.rackrotY, data.rackrotZ);
                    rack10.SetActive(true);
                    rack10.GetComponent <CDRack>().purchased = true;
                }
                for (int i = 0; i < listOfCases.Count; i++)
                {
                    CaseSaveDataList cas = data.cases.Where(x => x.CDName == listOfCases[i].GetComponent <CDCase>().CDName&& x.purchased).FirstOrDefault();
                    if (cas != null)
                    {
                        if (!cas.inRack)
                        {
                            listOfCases[i].transform.position    = cas.pos;
                            listOfCases[i].transform.eulerAngles = new Vector3(cas.rotX, cas.rotY, cas.rotZ);
                        }
                        else
                        {
                            listOfCases[i].GetComponent <Rigidbody>().isKinematic      = true;
                            listOfCases[i].GetComponent <Rigidbody>().detectCollisions = false;
                            listOfCases[i].transform.SetParent(rack10.transform.GetChild(cas.inRackSlot), false);
                            listOfCases[i].transform.localPosition            = Vector3.zero;
                            listOfCases[i].transform.localEulerAngles         = Vector3.zero;
                            listOfCases[i].GetComponent <CDCase>().inRack     = true;
                            listOfCases[i].GetComponent <CDCase>().inRackSlot = cas.inRackSlot;
                            listOfCases[i].name = "cd case (" + (cas.inRackSlot + 1).ToString() + ")(itemy)";
                        }
                        listOfCases[i].GetComponent <CDCase>().purchased = true;
                        listOfCases[i].SetActive(true);
                    }
                }

                for (int i = 0; i < listOfCDs.Count; i++)
                {
                    CDSaveDataList cds = data.cds.Where(x => x.CDName == listOfCDs[i].GetComponent <CD>().CDName).FirstOrDefault();
                    if (cds != null)
                    {
                        if (cds.CDName == listOfCDs[i].GetComponent <CD>().CDName)
                        {
                            if (!cds.inCase)
                            {
                                listOfCDs[i].GetComponent <CD>().inCase = false;
                                LoadAssets.MakeGameObjectPickable(listOfCDs[i]);
                                listOfCDs[i].transform.SetParent(null);
                                listOfCDs[i].transform.position    = cds.pos;
                                listOfCDs[i].transform.eulerAngles = new Vector3(cds.rotX, cds.rotY, cds.rotZ);
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public ListStuffCommand(ListGameObjects sender)
 {
     this.sender     = sender;
     this.objectPath = Path.Combine(ModLoader.GetModConfigFolder(this.sender), "GameObjects.csv");
     this.varPath    = Path.Combine(ModLoader.GetModConfigFolder(this.sender), "FsmVars.csv");
 }
Beispiel #5
0
        public override void OnLoad() // Called once, when mod is loading after game is fully loaded
        {
            // Create BottleRecyclingManager / Desk Trigger
            GameObject bottleRecyclingTrigger = GameObject.CreatePrimitive(PrimitiveType.Cube);

            bottleRecyclingTrigger.name = "Bottle Recycling Manager";
            bottleRecyclingTrigger.transform.position                  = new Vector3(-1551.096f, 4.712f, 1182.784f);
            bottleRecyclingTrigger.transform.localEulerAngles          = new Vector3(-90, 0, 61.256f);
            bottleRecyclingTrigger.transform.localScale                = new Vector3(0.4274191f, 0.5956179f, 0.1249701f);
            bottleRecyclingTrigger.GetComponent <Collider>().isTrigger = true;
            bottleRecyclingManager = bottleRecyclingTrigger.AddComponent <BottleRecyclingManager>();
            GameObject.Destroy(bottleRecyclingTrigger.GetComponent <MeshRenderer>());
            GameObject.Destroy(bottleRecyclingTrigger.GetComponent <MeshFilter>());

            // Create Receive Money Trigger
            GameObject receiveMoneyTrigger = GameObject.CreatePrimitive(PrimitiveType.Cube);

            receiveMoneyTrigger.name  = "Bottle Receive Money Trigger";
            receiveMoneyTrigger.layer = LayerMask.NameToLayer("DontCollide");
            receiveMoneyTrigger.transform.position                  = new Vector3(-1551.336f, 5.0255f, 1183.061f);
            receiveMoneyTrigger.transform.localEulerAngles          = new Vector3(-90, 0, 57.398f);
            receiveMoneyTrigger.transform.localScale                = new Vector3(0.2007769f, 0.5619151f, 0.8257601f);
            receiveMoneyTrigger.GetComponent <Collider>().isTrigger = true;
            GameObject.Destroy(receiveMoneyTrigger.GetComponent <MeshRenderer>());
            GameObject.Destroy(receiveMoneyTrigger.GetComponent <MeshFilter>());
            bottleRecyclingManager.receiveMoneyTrigger = receiveMoneyTrigger.transform;

            // Create Recycling Prices Note
            if ((bool)useAdditionalStoreGfx.GetValue())
            {
                GameObject bottleDepositsNoteVisual = GameObject.CreatePrimitive(PrimitiveType.Plane);
                GameObject.Destroy(bottleDepositsNoteVisual.GetComponent <Collider>());
                bottleDepositsNoteVisual.transform.position         = new Vector3(-1551.484f, 4.36f, 1182.2f);
                bottleDepositsNoteVisual.transform.localEulerAngles = new Vector3(270, 327.354f, 0);
                bottleDepositsNoteVisual.transform.localScale       = new Vector3(0.023f, 0.02f, 0.032f);
                bottleDepositsNoteVisual.name           = "Bottle Deposits Note Visual";
                bottleRecyclingManager.pricesNoteVisual = bottleDepositsNoteVisual.transform;

                GameObject bottleDepositsNote = GameObject.CreatePrimitive(PrimitiveType.Cube);
                bottleDepositsNote.name  = "Bottle Deposits Note";
                bottleDepositsNote.layer = LayerMask.NameToLayer("DontCollide");
                bottleDepositsNote.transform.position                    = new Vector3(-1551.484f, 4.36f, 1182.2f);
                bottleDepositsNote.transform.localEulerAngles            = new Vector3(0, -32.646f, 0);
                bottleDepositsNote.transform.localScale                  = new Vector3(0.1900704f, 0.2755774f, 0.001717138f);
                bottleDepositsNote.GetComponent <Collider>().isTrigger   = true;
                bottleDepositsNote.GetComponent <MeshRenderer>().enabled = false;
                bottleRecyclingManager.pricesNote = bottleDepositsNote.transform;
            }

            // Create BeercaseManager
            if ((bool)useFilledBeercases.GetValue())
            {
                GameObject _beerCaseManager = GameObject.CreatePrimitive(PrimitiveType.Cube);
                beerCaseManager      = _beerCaseManager.AddComponent <BeercaseManager>();
                beerCaseManager.name = "Beercase Manager";
                beerCaseManager.GetComponent <Collider>().isTrigger = true;
                beerCaseManager.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
                GameObject.Destroy(beerCaseManager.GetComponent <MeshRenderer>());
                GameObject.Destroy(beerCaseManager.GetComponent <MeshFilter>());
            }

            // Custom Bottles
            if ((bool)useCustomBottles.GetValue())
            {
                string[] customBottles = null;
                try
                {
                    customBottles = System.IO.File.ReadAllLines(System.IO.Path.Combine(ModLoader.GetModConfigFolder(this), "custom_bottles.txt"));
                }
                catch { }

                if (customBottles != null)
                {
                    foreach (string s in customBottles)
                    {
                        if (s.StartsWith("//") || string.IsNullOrEmpty(s)) // ignore comments
                        {
                            continue;
                        }

                        string[] chars = s.Split('=');
                        if (chars.Length > 1)
                        {
                            if (int.TryParse(chars[1], out int _price))
                            {
                                bottleRecyclingManager.customBottles.Add(chars[0]);
                                bottleRecyclingManager.customBottlePrices.Add(_price);
                            }
                        }
                    }
                }
            }

            ab = LoadAssets.LoadBundle(this, "bottlerecyclingbundle"); // load assetbundle
            LoadSaveFile();                                            // load savefile

            // apply bottle deposits note material
            if (bottleRecyclingManager.pricesNote != null)
            {
                Material noteMaterial = ab.LoadAsset("bottleDepositNoteMat") as Material;
                try
                {
                    bottleRecyclingManager.pricesNoteVisual.GetComponent <MeshRenderer>().material = GameObject.Instantiate(noteMaterial) as Material;
                }
                catch { }
            }

            ab.Unload(false); // unload assetbundle
        }