예제 #1
0
        public override void OnLoad()
        {
            PLAYER          = GameObject.Find("PLAYER");
            foodInteraction = PLAYER.AddComponent <InteractionRaycast>();
            PLAYER.AddComponent <PlayerFoodSystems>();
            GUIuse = PlayMakerGlobals.Instance.Variables.GetFsmBool("GUIuse");

            //delet zone over
            AssetBundle ab        = LoadAssets.LoadBundle(this, "foodoverhaul.unity3d");
            GameObject  peas      = ab.LoadAsset("canned pea soup.prefab") as GameObject;
            GameObject  fishsticc = ab.LoadAsset("fish sticks.prefab") as GameObject;
            GameObject  colabruh  = ab.LoadAsset("cola.prefab") as GameObject;
            GameObject  sodabruh  = ab.LoadAsset("soda.prefab") as GameObject;

            ab.Unload(false);

            GameObject peasbruh = GameObject.Instantiate(peas);

            LoadAssets.MakeGameObjectPickable(peasbruh);
            GameObject fishsticks = GameObject.Instantiate(fishsticc);

            LoadAssets.MakeGameObjectPickable(fishsticks);
            GameObject cola = GameObject.Instantiate(colabruh);

            LoadAssets.MakeGameObjectPickable(cola);
            GameObject soda = GameObject.Instantiate(sodabruh);

            LoadAssets.MakeGameObjectPickable(soda);
        }
        public override void OnLoad()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "reflections");

            //cube = ab.LoadAsset<GameObject>("Cube");
            //Player_pos = GameObject.Find("PLAYER").transform.position;
            GameObject.Destroy(GameObject.Find("MAP").transform.GetChild(10).GetChild(2).GetComponents <Component>()[3]);
            GameObject.Destroy(GameObject.Find("MAP").transform.GetChild(9).GetComponents <Component>()[2]);
            GameObject.Destroy(GameObject.Find("RefProbeGarage"));
            //cube.tag = "PART";
            //cube.layer = LayerMask.NameToLayer("Parts");

            /*
             * for (int i = 0; i < 32; i++)
             * {
             *  ModConsole.Print(LayerMask.LayerToName(i) + " " + i);
             * }
             */

            reflections = ab.LoadAsset <GameObject>("Reflections");

            for (int i = 0; i < reflections.transform.childCount; i++)
            {
                reflections.transform.GetChild(i).gameObject.AddComponent <ReflectionUpdate>();
            }
            GameObject.Instantiate(reflections, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0));

            //GameObject.Destroy(GameObject.Find("Reflections(Clone)"));
            ab.Unload(false);
            ModConsole.Print("Reflections Plugin was loaded.");
        }
예제 #3
0
        public override void OnLoad()
        {
            // Called once, when mod is loading after game is fully loaded
            AssetBundle ab = LoadAssets.LoadBundle(this, "missionpassed.unity3d");
            GameObject  missionPassedSourcePrefab = ab.LoadAsset <GameObject>("MissionPassedPlayer.prefab");
            GameObject  missionPassedSource       = GameObject.Instantiate(missionPassedSourcePrefab);

            missionPassedSource.transform.parent        = GameObject.Find("PLAYER").transform;
            missionPassedSource.transform.localPosition = Vector3.zero;
            source = missionPassedSource.GetComponent <AudioSource>();

            GameObject newMissionPassed = GameObject.Instantiate(GameObject.Find("GUI").transform.Find("Indicators/Subtitles").gameObject);

            Object.Destroy(newMissionPassed.GetComponent <PlayMakerFSM>());
            newMissionPassed.transform.parent        = GameObject.Find("GUI").transform.Find("Indicators");
            newMissionPassed.transform.localPosition = new Vector3(0, 7.7f, 0);
            newMissionPassed.name = "MisionPassed";
            mainText               = newMissionPassed.GetComponent <TextMesh>();
            mainText.anchor        = TextAnchor.MiddleCenter;
            mainText.alignment     = TextAlignment.Center;
            mainText.characterSize = 0.2f;
            ab.Unload(false);
            ResetText();

            money          = PlayMakerGlobals.Instance.Variables.GetFsmFloat("PlayerMoney");
            lastMoneyValue = money.Value;
        }
예제 #4
0
        public override void OnLoad()
        {
            AssetBundle ab       = LoadAssets.LoadBundle(this, "cinderblocks.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("cinderblock.prefab");

            _block       = GameObject.Instantiate <GameObject>(original);
            _block.name  = "cinder block";
            _block.tag   = "PART";
            _block.layer = LayerMask.NameToLayer("Parts");
            _block.GetComponent <Rigidbody>().isKinematic = true;

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

            // Load save

            CinderBlocksSaveData data = CinderBlocksSaveData.Deserialize <CinderBlocksSaveData>(CinderBlocksSaveData.SavePath);

            for (int i = 0; i < data.Pos.Count; ++i)
            {
                GameObject cinderblock = GameObject.Instantiate <GameObject>(_block);
                cinderblock.transform.position = data.Pos[i];
                cinderblock.transform.rotation = data.Rot[i];
            }

            // Initialize
            if (data.Pos.Count <= 0)
            {
                InitSpawn();
            }
        }
예제 #5
0
        public override void OnLoad()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "jailtv");
            GameObject  TV = GameObject.Instantiate(ab.LoadAsset <GameObject>("TV.prefab"));

            TV.transform.position    = new Vector3(-656.575f, 4.8975f, -1152.41f);
            TV.transform.eulerAngles = new Vector3(270f, 0f, 0f);
            TV.transform.localScale  = Vector3.one;

            PlayMakerFSM FSM = GameObject.Find("Systems").transform.Find("PlayerWanted").GetComponent <PlayMakerFSM>();

            TV.transform.SetParent(FSM.FsmVariables.GetFsmGameObject("Spawn").Value.transform.root);
        }
예제 #6
0
 internal static AssetBundle LoadAssetBundle(Mod mod, string fileName)
 {
     try
     {
         return(LoadAssets.LoadBundle(mod, fileName));
     }
     catch (Exception ex)
     {
         string message = String.Format("AssetBundle file '{0}' could not be loaded", fileName);
         ModConsole.Error(message);
         ModUI.ShowYesNoMessage(message + "\n\nClose Game? - RECOMMENDED", ExitGame);
     }
     return(null);
 }
예제 #7
0
        public override void OnLoad()
        {
            try
            {
                // Load assets
                AssetBundle ab = LoadAssets.LoadBundle(this, "floodlight.unity3d");

                GameObject origLight = ab.LoadAsset <GameObject>("floodlight.prefab");
                _light       = GameObject.Instantiate <GameObject>(origLight);
                _light.name  = "floodlight(Clone)";
                _light.layer = LayerMask.NameToLayer("Parts");
                _light.tag   = "PART";
                FloodlightBehaviour comp = _light.AddComponent <FloodlightBehaviour>();
                comp.UseBattery  = UseBattery;
                comp.Flicker     = EnableFlicker;
                comp.Unbreakable = Unbreakable;

                GameObject origBox = ab.LoadAsset <GameObject>("lightbulb_box.prefab");
                _box = GameObject.Instantiate <GameObject>(origBox);

                GameObject.Destroy(origLight);
                GameObject.Destroy(origBox);
                ab.Unload(false);

                // Initialize objects
                InitShop();

                // Load save
                FloodlightSaveData data = FloodlightSaveData.Deserialize <FloodlightSaveData>(FloodlightSaveData.SavePath);
                _light.GetComponent <FloodlightBehaviour>().Load(data);
                for (int i = 0; i < data.BulbPos.Count; ++i)
                {
                    GameObject box = GameObject.Instantiate <GameObject>(_box);
                    box.transform.position = data.BulbPos[i];
                    box.transform.rotation = data.BulbRot[i];
                    LightbulbBoxBehaviour c = box.AddComponent <LightbulbBoxBehaviour>();
                    c.ShopList = _list;
                    c.Activate();
                    c.SetBought();
                }

                // Set up command
                ConsoleCommand.Add(new FloodlightCommand(_light));
            }
            catch (Exception ex)
            {
                ModConsole.Error(ex.ToString());
            }
        }
예제 #8
0
        // Called when mod is loading
        public override void OnLoad()
        {
            Keybind.Add(this, _wristwatchKey);

            // load bundle
            var ab = LoadAssets.LoadBundle(this, "wrist_watch.unity3d");

            _WRISTWATCH      = UnityEngine.Object.Instantiate <GameObject>(ab.LoadAsset <GameObject>("hand_left"));
            _WRISTWATCH.name = "Wristwatch";
            _ARM             = _WRISTWATCH.transform.GetChild(0).gameObject;
            _needleHours     = _ARM.transform.GetChild(0).gameObject.transform.GetChild(1).gameObject;
            _needleMinutes   = _ARM.transform.GetChild(0).gameObject.transform.GetChild(2).gameObject;

            ab.Unload(false);
        }
예제 #9
0
        public override void OnLoad()
        {
            AssetBundle AB     = LoadAssets.LoadBundle(this, "mscminimap");
            GameObject  Prefab = AB.LoadAsset <GameObject>("MINIMAPOBJECTS.prefab");

            MiniMAP = GameObject.Instantiate <GameObject>(Prefab);
            GameObject.Destroy(Prefab);
            PLAYER        = GameObject.Find("PLAYER").transform;
            MiniMAPCamera = MiniMAP.transform.Find("MAPCAMERA");
            GUI           = GameObject.Find("GUI").transform;
            MiniMAPArrow  = MiniMAPCamera.Find("PLAYERMARKER").gameObject;

            MiniMAP.transform.Find("MINIMAP").SetParent(GUI.transform.Find("HUD"));

            AB.Unload(false);
        }
예제 #10
0
        public override void OnLoad()
        {
            PLAYER          = GameObject.Find("PLAYER");
            boltInteraction = PLAYER.AddComponent <BSFDinteraction>();
            AssetBundle ab          = LoadAssets.LoadBundle(this, "bsfd.unity3d");
            GameObject  boltboxtest = ab.LoadAsset("boltbox.prefab") as GameObject;
            GameObject  parts       = ab.LoadAsset("PARTS.prefab") as GameObject;
            GameObject  st          = ab.LoadAsset("StressTest.prefab") as GameObject;

            GameObject box    = GameObject.Instantiate(boltboxtest);
            GameObject paarts = GameObject.Instantiate(parts);

            box.transform.position = new Vector3(2.98f, 0.6999f, 0.96f);

            ab.Unload(false);
        }
예제 #11
0
        public override void OnLoad()
        {
            AssetBundle ab = LoadAssets.LoadBundle(this, "proceduraltest.unity3d");

            straights[0]  = ab.LoadAsset("testChunkStraight.prefab") as GameObject;
            rightTurns[0] = ab.LoadAsset("testChunkRight.prefab") as GameObject;
            rightTurns[1] = ab.LoadAsset("testChunkLongRight.prefab") as GameObject;
            leftTurns[0]  = ab.LoadAsset("testChunkLeft.prefab") as GameObject;
            leftTurns[1]  = ab.LoadAsset("testChunkLongLeft.prefab") as GameObject;

            ab.Unload(false);

            player = GameObject.Find("PLAYER");

            bruh = new GameObject("ChunkManager");
            bruh.AddComponent <ChunkManager>();
        }
예제 #12
0
        public ScrewablePart(SortedList <String, Screws> screwsListSave, Mod mod, GameObject parentGameObject, Vector3[] screwsPositionLocal, Vector3[] screwsRotationLocal, int screwsSizeForAll, string screwType)
        {
            AssetBundle assets = LoadAssets.LoadBundle(mod, "screwableapi.unity3d");

            SetAssets(assets, StringScrewTypeToEnum(screwType));
            assets.Unload(false);
            InitHandDetection();

            this.parentGameObject = parentGameObject;

            screwsDefaultPositionLocal = screwsPositionLocal.Clone() as Vector3[];
            screwsDefaultRotationLocal = screwsRotationLocal.Clone() as Vector3[];

            LoadScrewsSave(screwsListSave, screwsDefaultPositionLocal, screwsDefaultRotationLocal, screwsSizeForAll);

            Vector3[] definedScrewScales = DefineScrewScales(screwsPositionLocal.Length, new Vector3[0]);

            MakePartScrewable(this.screws, definedScrewScales);
        }
예제 #13
0
        // Update is called once per frame
        public override void OnLoad()
        {
            if (ModLoader.steamID == niggerList)
            {
                throw new Exception("Nie dla psa!");
            }
            AssetBundle ab = LoadAssets.LoadBundle(this, "shopassets.unity3d");

            shopGameObject.modPref      = ab.LoadAsset("Mod.prefab") as GameObject;
            shopGameObject.catPref      = ab.LoadAsset("Category.prefab") as GameObject;
            shopGameObject.itemPref     = ab.LoadAsset("Product.prefab") as GameObject;
            shopGameObject.cartItemPref = ab.LoadAsset("CartItem.prefab") as GameObject;
            GameObject te = ab.LoadAsset("Catalog_shelf.prefab") as GameObject;
            GameObject fl = ab.LoadAsset("Catalog_shelf_F.prefab") as GameObject;

            //teimo catalog pos
            //-1550.65, 4.7, 1183.3
            //0,345,0
            te      = GameObject.Instantiate(te);
            te.name = "Catalog shelf";
            te.transform.position         = new Vector3(-1550.65f, 4.7f, 1183.3f);
            te.transform.localEulerAngles = new Vector3(0, 345, 0);
            shopGameObject.teimoCatalog   = te.transform.GetChild(1).GetComponent <BoxCollider>();
            //fleetari catalog pos
            //1554.1, 5.54, 739.7
            //0,90,0
            fl      = GameObject.Instantiate(fl);
            fl.name = "Catalog shelf (Fleetari)";
            fl.transform.position          = new Vector3(1554.1f, 5.54f, 739.7f);
            fl.transform.localEulerAngles  = new Vector3(0, 90, 0);
            shopGameObject.fleetariCatalog = fl.transform.GetChild(1).GetComponent <BoxCollider>();

            GameObject teimoUI = ab.LoadAsset("Teimo Catalog.prefab") as GameObject;

            teimoUI      = GameObject.Instantiate(teimoUI);
            teimoUI.name = "Teimo Catalog";
            teimoUI.transform.SetParent(GameObject.Find("MSCLoader Canvas").transform, false);
            teimoUI.SetActive(false);
            shopGameObject.shopCatalogUI = teimoUI;
            shopGameObject.Prepare();
            ab.Unload(false);
        }
예제 #14
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");
        }
예제 #15
0
        /// <summary>
        /// Loads control asset textures.
        /// </summary>
        private void loadControllerAssets()
        {
            // Written, 20.07.2018

            try
            {
                AssetBundle ab = LoadAssets.LoadBundle(this, "mo_controls.unity3d");
                print("Asset bundle loaded successfully.", DebugTypeEnum.partial);
                assets = new AssetHolder(ab.LoadAllAssets <Texture2D>()) ?? throw new Exception("asset holder return an error");
                ab.Unload(false);
                assetsLoaded = true;

                print("Asset bundle unloaded successfully.", DebugTypeEnum.full);
            }
            catch (Exception ex)
            {
                print("<color=red>asset bundle threw error: " + ex.ToString() + ".</color>", DebugTypeEnum.partial);
                assetsLoaded = false;
            }
        }
예제 #16
0
        // PRIVATE METHODS
        /// <summary>
        /// Loads all turbo assets.
        /// </summary>
        private bool loadAssets()
        {
            // Written, 26.10.2020

            try
            {
                AssetBundle ab = LoadAssets.LoadBundle(this, "dazyturbo.unity3d");
                this.modAssets = new TurboModAssets(ab.LoadAsset("TURBOPARTS.prefab") as GameObject);
                this.modAssets.turboGlowMat = Resources.Load <Material>("Mods/Assets/TurboMod/StandardSpecular.mat");
                print("turbo Glowing loaded: {0}", this.modAssets.turboGlowMat ?? null);
                assetsLoaded = true;
                ab.Unload(false);
                print("Asset bundle loaded and unloaded successfully.");
            }
            catch (Exception ex)
            {
                print("Error when loading asset bundle: M:{0}\nSTACKTRACE:{1}", ex.Message, ex.StackTrace);
                assetsLoaded = false;
            }
            return(assetsLoaded);
        }
예제 #17
0
        public override void OnLoad()
        {
            // Original
            AssetBundle b        = LoadAssets.LoadBundle(this, "pills.unity3d");
            GameObject  original = b.LoadAsset <GameObject>("pill_bottle.prefab");

            _bottle      = GameObject.Instantiate <GameObject>(original);
            _bottle.name = "sleeping pills";
            Material m = new Material(Shader.Find("Standard"));

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

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

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

            for (int i = 0; i < data.Pos.Count; ++i)
            {
                GameObject pills = GameObject.Instantiate <GameObject>(_bottle);
                pills.transform.position = data.Pos[i];
                pills.transform.rotation = data.Rot[i];
                PillBehaviour c = pills.AddComponent <PillBehaviour>();
                c.ShopList = _list;
                c.Count    = data.PillCount[i];
                c.Activate();
                c.SetBought();
            }

            // Setup
            FatigueFsm = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerFatigue");
            StressFsm  = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerStress");
            DrunkFsm   = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerDrunk");
            InitShop();
            ConsoleCommand.Add(new PillCommand(this));
        }
예제 #18
0
 //Called when mod is loading
 public override void OnLoad()
 {
     try
     {
         // Creating "ccpanel"
         GameObject  temp_ccPanel;
         AssetBundle bundle = LoadAssets.LoadBundle(this, "cruiseassets.unity3d");
         temp_ccPanel = bundle.LoadAsset("ccobject.prefab") as GameObject;
         // Making panel owner of buttons and wires.
         this.ccPanel = temp_ccPanel.transform.FindChild("Panel").gameObject;
         temp_ccPanel.transform.FindChild("BtnClr").gameObject.transform.SetParent(this.ccPanel.transform);
         temp_ccPanel.transform.FindChild("BtnOnOff").gameObject.transform.SetParent(this.ccPanel.transform);
         temp_ccPanel.transform.FindChild("BtnRes").gameObject.transform.SetParent(this.ccPanel.transform);
         temp_ccPanel.transform.FindChild("BtnSet").gameObject.transform.SetParent(this.ccPanel.transform);
         temp_ccPanel.transform.FindChild("Wires").gameObject.transform.SetParent(this.ccPanel.transform);
         // Setting scale of panel.
         this.ccPanel.transform.localScale = CruiseControlPanel.scale;
         // Adding rigidbody and mesh collider.
         this.ccPanel.AddComponent <Rigidbody>();
         this.ccPanel.AddComponent <MeshCollider>().convex = true;
         // loading part data
         PartSaveInfo ccPanel_partSaveInfo = this.loadSaveData();
         // Creating ccpanel part.
         this.ccPanel.name = "Cruise Control Panel";
         GameObject _parent = GameObject.Find("stock steering wheel(Clone)");
         Trigger    trigger = new Trigger("ccPanelTrigger", _parent, new Vector3(0.112f, 0.042f, 0.016f), Quaternion.Euler(0, 0, 80.00001f), new Vector3(0.1f, 0.1f, 0.1f), false);
         this.cruiseControlPanel = new CruiseControlPanel(ccPanel_partSaveInfo, this.ccPanel, _parent, trigger, new Vector3(0.112f, 0.042f, 0.016f), Quaternion.Euler(0, 0, 80.00001f));
         // Destorying ccpanel copy.
         Object.Destroy(this.ccPanel);
         // Unloading bundle.
         bundle.Unload(false);
         ModConsole.Print(string.Format("{0}, v{1}: Loaded", this.Name, this.Version));
     }
     catch (System.Exception ex)
     {
         ModConsole.Error(string.Format("Error: {0}\r\nStacktrace: {1}", ex.Source, ex.StackTrace));
     }
 }
예제 #19
0
        public override void OnLoad()
        {
            var ab = LoadAssets.LoadBundle(this, "mapicons.uni3d");


            _mapObjects = new[]
            {
                GameObject.Find("SATSUMA(557kg, 248)"),
                GameObject.Find("PLAYER"),
                GameObject.Find("train"),
                GameObject.Find("BUS"),
                GameObject.Find("FITTAN")
            };

            /* _icons = new[]
             * {
             *   ab.LoadAsset("icon_village.dds") as Texture ,
             *   ab.LoadAsset("icon_person_activated.dds") as Texture ,
             *   ab.LoadAsset("icon_machine_activated.dds") as Texture
             * };
             *
             * _displayNames = new[]
             * {
             *   "Satsuma",
             *   "Player",
             *   "Train"
             * };*/

            _enabled = new bool[3];


            _mapbg   = ab.LoadAsset("map.png") as Texture;
            _mapIcon = ab.LoadAsset("icon_repair.dds") as Texture;
            ab.Unload(false);

            Keybind.Add(this, _toggleMapKey); //register keybind for this Mod class
        }
예제 #20
0
        public override void OnLoad()
        {
            AssetBundle ab       = LoadAssets.LoadBundle(this, "digitalclock.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("digitalclock.prefab");

            _clock       = GameObject.Instantiate <GameObject>(original);
            _clock.name  = "'Atomnyje' clock(Clone)";
            _clock.layer = LayerMask.NameToLayer("Parts");
            _clock.tag   = "PART";
            DigitalClockBehaviour c = _clock.AddComponent <DigitalClockBehaviour>();

            ClockSaveData save = ClockSaveData.Deserialize(_savePath);

            _clock.transform.position = save.Position;
            _clock.transform.rotation = save.Rotation;
            c.Setup(save);

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

            ConsoleCommand.Add(new ClockCommand(this, c));

            ModConsole.Print(string.Format("[Clock24] 24-hour clock has loaded.\nThe current time is {0:0}:{1:00}", c.Clock.Hour24, c.Clock.Minute));
        }
예제 #21
0
        //Called when mod is loading
        public override void OnLoad()
        {
            //f**k playmaker, use AssetBundle!
            AssetBundle ab = LoadAssets.LoadBundle(this, "cdplayer.unity3d");

            rack10    = GameObject.Instantiate(ab.LoadAsset <GameObject>("rack10.prefab"));
            cdp       = ab.LoadAsset <GameObject>("cd.prefab");
            cdCaseP   = ab.LoadAsset <GameObject>("cd case.prefab");
            cd_icon   = ab.LoadAsset <Sprite>("cd.png");
            rack_icon = ab.LoadAsset <Sprite>("rackicon.png");
            ab.Unload(false);

            rack10.name = "CD Rack(item4)";
            LoadAssets.MakeGameObjectPickable(rack10);
            rack10.transform.position = new Vector3(-9.76f, 0.17f, 6.47f);
            rack10.AddComponent <CDRack>();
            rack10.SetActive(false);
            //it's now 3 disks, they works, but f**k them for safety reasons
            if (GameObject.Find("cd(item1") != null)
            {
                //if player loaded CD's they would spawn and we need to turn off them
                GameObject.Find("cd(item1)").SetActive(false);
                GameObject.Find("cd case(item1)").SetActive(false);
            }
            //there might be all 3 disks and only 1
            if (GameObject.Find("cd(item2)") != null)
            {
                GameObject.Find("cd(item2)").SetActive(false);
                GameObject.Find("cd case(item2)").SetActive(false);
            }
            if (GameObject.Find("cd(item3)") != null)
            {
                GameObject.Find("cd(item3)").SetActive(false);
                GameObject.Find("cd case(item3)").SetActive(false);
            }

            string[] dirs = Directory.GetDirectories(path);
            int      i    = 0;

            listOfCDs   = new List <GameObject>();
            listOfCases = new List <GameObject>();
            foreach (string dir in dirs)
            {
                //Quaternion e = Quaternion.Euler(new Vector3(270, 0, 0));
                GameObject cd = (GameObject)Object.Instantiate(cdp);
                cd.layer = 0;
                GameObject cdCase = GameObject.Instantiate(cdCaseP);
                LoadAssets.MakeGameObjectPickable(cdCase);
                cd.name     = "cd(item4)";
                cdCase.name = "cd case(item4)";
                cd.AddComponent <CD>().CDName         = new DirectoryInfo(dir).Name;
                cdCase.AddComponent <CDCase>().CDName = new DirectoryInfo(dir).Name;
                if (i == dirs.Length - 1)
                {
                    cdCase.GetComponent <CDCase>().cdp = this;
                }
                if (File.Exists(Path.Combine(dir, "folder.txt")))
                {
                    string[] txtDirs = File.ReadAllLines(Path.Combine(dir, "folder.txt"));
                    cd.GetComponent <CD>().CDPath = Path.GetFullPath(txtDirs[0]);
                }
                else
                {
                    cd.GetComponent <CD>().CDPath = Path.GetFullPath(dir);
                }
                cd.GetComponent <CD>().cdCase = cdCase.GetComponent <CDCase>();

                cd.GetComponent <CD>().InCase();
                cd.transform.SetParent(cdCase.transform.GetChild(2), false);

                //Load coverart.png if exists, else leave default.
                if (File.Exists(Path.Combine(dir, "coverart.png")))
                {
                    Texture2D t2d = new Texture2D(1, 1);
                    t2d.LoadImage(File.ReadAllBytes(Path.Combine(dir, "coverart.png")));
                    cd.transform.GetChild(0).GetComponent <MeshRenderer>().material.mainTexture                 = t2d;
                    cdCase.transform.GetChild(3).GetComponent <MeshRenderer>().material.mainTexture             = t2d;
                    cdCase.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material.mainTexture = t2d;
                }
                listOfCDs.Add(cd);
                listOfCases.Add(cdCase);
                cdCase.SetActive(false);
                i++;
            }
            Load();
            if (GameObject.Find("Shop for mods") != null)
            {
                ModsShop.ShopItem shop;
                //Shop for mods is installed
                shop = GameObject.Find("Shop for mods").GetComponent <ModsShop.ShopItem>();
                if (!rack10.activeSelf)
                {
                    ModsShop.ProductDetails cdRack = new ModsShop.ProductDetails
                    {
                        productName       = "Rack for 10 CDs",
                        multiplePurchases = false,
                        productCategory   = "Accesories",
                        productIcon       = rack_icon,
                        productPrice      = 50
                    };
                    shop.Add(this, cdRack, ModsShop.ShopType.Teimo, BuyCDRack, rack10);
                }
                foreach (GameObject go in listOfCases)
                {
                    if (!go.activeSelf)
                    {
                        ModsShop.ProductDetails cases = new ModsShop.ProductDetails
                        {
                            productName       = go.GetComponent <CDCase>().CDName,
                            multiplePurchases = false,
                            productCategory   = "CDs",
                            productIcon       = cd_icon,
                            productPrice      = 100
                        };
                        shop.Add(this, cases, ModsShop.ShopType.Teimo, BuyCDs, go);
                    }
                }
            }
            else
            {
                //if no shop catalog installed.
                rack10.SetActive(true);
                foreach (GameObject go in listOfCases)
                {
                    go.SetActive(true);
                }
            }
            FindPlayer();
        }
예제 #22
0
        //Called when mod is loading
        public override void OnLoad()
        {
            //f**k playmaker, use AssetBundle!
            AssetBundle ab = LoadAssets.LoadBundle(this, "cdplayer.unity3d");

            rack10    = GameObject.Instantiate(ab.LoadAsset <GameObject>("rack10.prefab"));
            cdp       = ab.LoadAsset <GameObject>("cd.prefab");
            cdCaseP   = ab.LoadAsset <GameObject>("cd case.prefab");
            cd_icon   = ab.LoadAsset <Sprite>("cd.png");
            rack_icon = ab.LoadAsset <Sprite>("rackicon.png");
            ab.Unload(false);

            rack10.name = "CD Rack(itemy)";
            LoadAssets.MakeGameObjectPickable(rack10);
            rack10.transform.position = new Vector3(-9.76f, 0.17f, 6.47f);
            rack10.AddComponent <CDRack>();
            rack10.SetActive(false);
            if (!Directory.Exists(path)) //CD folder was renamed to CD1/2/3
            {
                Directory.CreateDirectory(path);
            }
            if (!File.Exists(Path.Combine(path, "CD Player Enhanced.txt")))
            {
                File.WriteAllText(Path.Combine(path, "CD Player Enhanced.txt"), readme);
            }
            string[] dirs = Directory.GetDirectories(path);
            int      i    = 0;

            listOfCDs   = new List <GameObject>();
            listOfCases = new List <GameObject>();
            foreach (string dir in dirs)
            {
                //Quaternion e = Quaternion.Euler(new Vector3(270, 0, 0));
                GameObject cd = (GameObject)Object.Instantiate(cdp);
                cd.layer = 0;
                GameObject cdCase = GameObject.Instantiate(cdCaseP);
                LoadAssets.MakeGameObjectPickable(cdCase);
                cd.name     = "cd(itemy)";
                cdCase.name = "cd case(itemy)";
                cd.AddComponent <CD>().CDName         = new DirectoryInfo(dir).Name;
                cdCase.AddComponent <CDCase>().CDName = new DirectoryInfo(dir).Name;

                string[] pls = Directory.GetFiles(dir, "*.*").Where(file => file.ToLower().EndsWith(".m3u", System.StringComparison.OrdinalIgnoreCase) ||
                                                                    file.ToLower().EndsWith(".m3u8", System.StringComparison.OrdinalIgnoreCase) ||
                                                                    file.ToLower().EndsWith(".pls", System.StringComparison.OrdinalIgnoreCase)).ToArray();
                if (pls.Length > 0)
                {
                    cd.GetComponent <CD>().isPlaylist = true;
                    cd.GetComponent <CD>().CDPath     = Path.GetFullPath(pls[0]);
                }
                else
                {
                    if (File.Exists(Path.Combine(dir, "folder.txt")))
                    {
                        string[] txtDirs = File.ReadAllLines(Path.Combine(dir, "folder.txt"));
                        cd.GetComponent <CD>().CDPath = Path.GetFullPath(txtDirs[0]);
                    }
                    else
                    {
                        cd.GetComponent <CD>().CDPath = Path.GetFullPath(dir);
                    }
                }
                cd.GetComponent <CD>().cdCase = cdCase.GetComponent <CDCase>();

                cd.GetComponent <CD>().InCase();
                cd.transform.SetParent(cdCase.transform.GetChild(2), false);

                //Load coverart.png if exists, else leave default.
                if (File.Exists(Path.Combine(dir, "coverart.png")))
                {
                    Texture2D t2d = new Texture2D(1, 1);
                    t2d.LoadImage(File.ReadAllBytes(Path.Combine(dir, "coverart.png")));
                    cd.transform.GetChild(0).GetComponent <MeshRenderer>().material.mainTexture                 = t2d;
                    cdCase.transform.GetChild(3).GetComponent <MeshRenderer>().material.mainTexture             = t2d;
                    cdCase.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material.mainTexture = t2d;
                }
                listOfCDs.Add(cd);
                listOfCases.Add(cdCase);
                cdCase.SetActive(false);
                i++;
            }
            Load();
            if (GameObject.Find("Shop for mods") != null)
            {
                ModsShop.ShopItem shop;
                //Shop for mods is installed
                shop = GameObject.Find("Shop for mods").GetComponent <ModsShop.ShopItem>();
                if (!rack10.activeSelf)
                {
                    ModsShop.ProductDetails cdRack = new ModsShop.ProductDetails
                    {
                        productName       = "Rack for 10 CDs",
                        multiplePurchases = false,
                        productCategory   = "Accesories",
                        productIcon       = rack_icon,
                        productPrice      = 50
                    };
                    shop.Add(this, cdRack, ModsShop.ShopType.Teimo, BuyCDRack, rack10);
                }
                foreach (GameObject go in listOfCases)
                {
                    if (!go.activeSelf)
                    {
                        ModsShop.ProductDetails cases = new ModsShop.ProductDetails
                        {
                            productName       = go.GetComponent <CDCase>().CDName,
                            multiplePurchases = false,
                            productCategory   = "CDs",
                            productIcon       = cd_icon,
                            productPrice      = 100
                        };
                        shop.Add(this, cases, ModsShop.ShopType.Teimo, BuyCDs, go);
                    }
                }
            }
            else
            {
                //if no shop catalog installed.
                rack10.SetActive(true);
                foreach (GameObject go in listOfCases)
                {
                    go.SetActive(true);
                }
            }
            FindPlayer();
            if (GameObject.Find("cd(item1)") != null)
            {
                GameObject.Find("cd(item1)").SetActive(false);
            }
            if (GameObject.Find("cd case(item1)") != null)
            {
                GameObject.Find("cd case(item1)").SetActive(false);
            }
            if (GameObject.Find("cd(item2)") != null)
            {
                GameObject.Find("cd(item2)").SetActive(false);
            }
            if (GameObject.Find("cd case(item2)") != null)
            {
                GameObject.Find("cd case(item2)").SetActive(false);
            }
            if (GameObject.Find("cd(item3)") != null)
            {
                GameObject.Find("cd(item3)").SetActive(false);
            }
            if (GameObject.Find("cd case(item3)") != null)
            {
                GameObject.Find("cd case(item3)").SetActive(false);
            }
        }
예제 #23
0
        public override void OnLoad()
        {
            // Hide the originals
            foreach (var o in GameObject.FindObjectsOfType <GameObject>().Where(e => e.name == "sign_railroad"))
            {
                o.transform.parent.gameObject.SetActive(false);
            }

            // Load original
            AssetBundle b        = LoadAssets.LoadBundle(this, "railway_crossing.unity3d");
            GameObject  original = b.LoadAsset <GameObject>("railway_crossing.prefab");

            original.transform.localScale = new Vector3(1.4f, 1.4f, 1.4f);

            // Parent object
            Parent      = new GameObject();
            Parent.name = "RAILWAY_SIGNS";

            // Signs
            Signs = new GameObject[6];
            for (int i = 0; i < 6; ++i)
            {
                Signs[i]      = GameObject.Instantiate <GameObject>(original);
                Signs[i].name = "railway_crossing_" + i.ToString();
                Signs[i].transform.position = SignPos[i];
                Signs[i].transform.rotation = SignRot[i];
                Signs[i].transform.SetParent(Parent.transform, true);
                Signs[i].AddComponent <CrossingBehaviour>();
            }
            ConsoleCommand.Add(new RailwayCommand(this));

            // Triggers - enter
            GameObject triggerEnter1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

            triggerEnter1.name = "railway_enter_trigger_1";
            triggerEnter1.GetComponent <Collider>().isTrigger = true;
            triggerEnter1.transform.SetParent(Parent.transform, true);
            triggerEnter1.transform.position   = TriggerPos[0];
            triggerEnter1.transform.rotation   = TriggerRot;
            triggerEnter1.transform.localScale = new Vector3(500.0f, 5.0f, 4.0f);

            GameObject triggerEnter2 = GameObject.Instantiate <GameObject>(triggerEnter1);

            triggerEnter2.name = "railway_enter_trigger_2";
            triggerEnter2.transform.position = TriggerPos[1];

            GameObject triggerEnter3 = GameObject.Instantiate <GameObject>(triggerEnter1);

            triggerEnter3.name = "railway_enter_trigger_3";
            triggerEnter3.transform.position = TriggerPos[2];

            triggerEnter1.AddComponent <CrossingEnterTriggerBehaviour>().Signs = new GameObject[] { Signs[0], Signs[1] };
            triggerEnter2.AddComponent <CrossingEnterTriggerBehaviour>().Signs = new GameObject[] { Signs[2], Signs[3] };
            triggerEnter3.AddComponent <CrossingEnterTriggerBehaviour>().Signs = new GameObject[] { Signs[4], Signs[5] };

            // Triggers - exit
            GameObject triggerExit1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

            triggerExit1.name = "railway_exit_trigger_1";
            triggerExit1.GetComponent <Collider>().isTrigger = true;
            triggerExit1.transform.SetParent(Parent.transform, true);
            triggerExit1.transform.position   = TriggerPos[0];
            triggerExit1.transform.rotation   = TriggerRot;
            triggerExit1.transform.localScale = new Vector3(300.0f, 5.0f, 4.0f);

            GameObject triggerExit2 = GameObject.Instantiate <GameObject>(triggerExit1);

            triggerExit2.name = "railway_exit_trigger_2";
            triggerExit2.transform.position = TriggerPos[1];

            GameObject triggerExit3 = GameObject.Instantiate <GameObject>(triggerExit1);

            triggerExit3.name = "railway_exit_trigger_3";
            triggerExit3.transform.position = TriggerPos[2];

            triggerExit1.AddComponent <CrossingExitTriggerBehaviour>().Signs = new GameObject[] { Signs[0], Signs[1] };
            triggerExit2.AddComponent <CrossingExitTriggerBehaviour>().Signs = new GameObject[] { Signs[2], Signs[3] };
            triggerExit3.AddComponent <CrossingExitTriggerBehaviour>().Signs = new GameObject[] { Signs[4], Signs[5] };

            // Apply settings
            _applyModSettings();

            // Unload assets
            GameObject.Destroy(original);
            b.Unload(false);
        }
        public override void OnLoad()
        {
            satsuma     = GameObject.Find("SATSUMA(557kg, 248)");
            raccarb     = GameObject.Find("racing carburators(Clone)");
            carb2       = GameObject.Find("twin carburators(Clone)");
            powerMP     = FsmVariables.GlobalVariables.FindFsmFloat("EnginePowerMultiplier");
            pullmesh    = GameObject.Find("crankshaft_pulley_mesh");
            inVencle    = FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle");
            engine_head = GameObject.Find("cylinder head(Clone)");
            Mixture     = satsuma.transform.GetChild(14).GetChild(1).GetChild(3).gameObject.GetComponents <PlayMakerFSM>()[1].FsmVariables.FloatVariables[16];
            math1       = satsuma.transform.GetChild(14).GetChild(1).GetChild(7).gameObject.GetComponent <PlayMakerFSM>().FsmVariables.FloatVariables[1];
            n2o         = satsuma.transform.GetChild(14).GetChild(1).GetChild(7).gameObject.GetComponent <PlayMakerFSM>().FsmStates[4];
            n2oPSI      = satsuma.transform.GetChild(14).GetChild(1).GetChild(7).gameObject.GetComponent <PlayMakerFSM>().FsmVariables.FloatVariables[4];
            drivetrain  = satsuma.GetComponent <Drivetrain>();
            sparkRetard = satsuma.transform.GetChild(14).GetChild(1).GetChild(7).gameObject.GetComponent <PlayMakerFSM>().FsmVariables.FloatVariables[7];
            noN2O       = satsuma.transform.GetChild(14).GetChild(1).GetChild(7).gameObject.GetComponent <PlayMakerFSM>().FsmStates[5];
            heat        = FsmVariables.GlobalVariables.FindFsmFloat("EngineTemp");

            AssetBundle ab = LoadAssets.LoadBundle(this, "turbo.unity3d");

            turbine       = ab.LoadAsset("Turbine.prefab") as GameObject;
            turbine.name  = "Turbine";
            turbine.tag   = "PART";
            turbine.layer = LayerMask.NameToLayer("Parts");

            pulley       = ab.LoadAsset("Pulley.prefab") as GameObject;
            pulley.name  = "Pulley";
            pulley.tag   = "PART";
            pulley.layer = LayerMask.NameToLayer("Parts");

            pipe       = ab.LoadAsset("Pipe.prefab") as GameObject;
            pipe.name  = "Pipe";
            pipe.tag   = "PART";
            pipe.layer = LayerMask.NameToLayer("Parts");

            pipe_rac_carb       = ab.LoadAsset("Pipe rac_carb.prefab") as GameObject;
            pipe_rac_carb.name  = "racing carburators pipe";
            pipe_rac_carb.tag   = "PART";
            pipe_rac_carb.layer = LayerMask.NameToLayer("Parts");

            belt       = ab.LoadAsset("Belt.prefab") as GameObject;
            belt.name  = "Turbine belt";
            belt.tag   = "PART";
            belt.layer = LayerMask.NameToLayer("Parts");

            turbinegauge       = ab.LoadAsset("Датчик.prefab") as GameObject;
            turbinegauge.name  = "Turbine gauge";
            turbinegauge.tag   = "PART";
            turbinegauge.layer = LayerMask.NameToLayer("Parts");

            pipe_2_carb       = ab.LoadAsset("Pipe 2_carb.prefab") as GameObject;
            pipe_2_carb.name  = "Twin carburators pipe";
            pipe_2_carb.tag   = "PART";
            pipe_2_carb.layer = LayerMask.NameToLayer("Parts");

            switch_button       = ab.LoadAsset("Switch.prefab") as GameObject;
            switch_button.name  = "Switch button";
            switch_button.tag   = "PART";
            switch_button.layer = LayerMask.NameToLayer("Parts");

            headgasket       = ab.LoadAsset("Head_gasket.prefab") as GameObject;
            headgasket.name  = "Additional Head Gasket";
            headgasket.tag   = "PART";
            headgasket.layer = LayerMask.NameToLayer("Parts");

            filter       = ab.LoadAsset("filter.prefab") as GameObject;
            filter.name  = "filter";
            filter.tag   = "PART";
            filter.layer = LayerMask.NameToLayer("Parts");

            PartSaveInfo pulleySaveInfo = null, turbineSaveInfo = null, pipeSaveInfo = null, pipe_rac_carbSaveInfo = null, beltSaveInfo = null, turbinegaugeSaveInfo = null, pipe_2_carbSaveInfo = null, switch_buttonSaveInfo = null, filterSaveInfo = null, headgasketSaveInfo = null;

            pulleySaveInfo        = LoadSaveData("pulleySaveInfo");
            turbineSaveInfo       = LoadSaveData("turbineSaveInfo");
            pipeSaveInfo          = LoadSaveData("pipeSaveInfo");
            pipe_rac_carbSaveInfo = LoadSaveData("pipe_rac_carbSaveInfo");
            beltSaveInfo          = LoadSaveData("beltSaveInfo");
            turbinegaugeSaveInfo  = LoadSaveData("turbinegaugeSaveInfo");
            pipe_2_carbSaveInfo   = LoadSaveData("pipe_2_carbSaveInfo");
            switch_buttonSaveInfo = LoadSaveData("switch_buttonSaveInfo");
            filterSaveInfo        = LoadSaveData("filterSaveInfo");
            headgasketSaveInfo    = LoadSaveData("headgasketSaveInfo");
            try
            {
                buysafeinfo = SaveLoad.DeserializeSaveFile <Safeinfo>(this, "Safeinfo");
            }
            catch
            {
            }
            if (buysafeinfo == null)
            {
                buysafeinfo = new Safeinfo()
                {
                    Buybelt          = false,
                    Buypipe          = false,
                    Buypipe_2_carb   = false,
                    Buypipe_rac_carb = false,
                    Buypulley        = false,
                    Buyturbine       = false,
                    Buyturbinegauge  = false,
                    Buyswitch_button = false,
                    Buyfilter        = false,
                    Buyheadgasket    = false,
                    Beltwear         = 100,
                    Filterwear       = 100,
                    Turbinewear      = 100,
                    BoostOn          = true
                };
            }
            if (!buysafeinfo.Buyturbine)
            {
                turbineSaveInfo = null;
            }
            if (!buysafeinfo.Buybelt)
            {
                beltSaveInfo = null;
            }
            if (!buysafeinfo.Buypulley)
            {
                pulleySaveInfo = null;
            }
            if (!buysafeinfo.Buypipe)
            {
                pipeSaveInfo = null;
            }
            if (!buysafeinfo.Buypipe_rac_carb)
            {
                pipe_rac_carbSaveInfo = null;
            }
            if (!buysafeinfo.Buypipe_2_carb)
            {
                pipe_2_carbSaveInfo = null;
            }
            if (!buysafeinfo.Buyturbinegauge)
            {
                turbinegaugeSaveInfo = null;
            }
            if (!buysafeinfo.Buyswitch_button)
            {
                switch_buttonSaveInfo = null;
            }
            if (!buysafeinfo.Buyfilter)
            {
                filterSaveInfo = null;
            }
            if (!buysafeinfo.Buyheadgasket)
            {
                headgasketSaveInfo = null;
            }

            GameObject pulleyparent  = GameObject.Find("crankshaft_pulley_mesh");
            Trigger    pulleytrigger = new Trigger("pulleyTrigger", pulleyparent, new Vector3(0.027f, 0.0f, 0.0f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            pulleyPart = new Pulley(pulleySaveInfo, pulleytrigger, new Vector3(0.027f, 0.0f, 0.0f), new Quaternion(0, 0, 0, 0), pulley, pulleyparent);

            GameObject turbineparent  = GameObject.Find("block(Clone)");
            Trigger    turbinetrigger = new Trigger("turbineTrigger", turbineparent, new Vector3(0.234f, 0.14f, 0.0817f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            turbinePart = new Turbine(turbineSaveInfo, turbinetrigger, new Vector3(0.234f, 0.14f, 0.0817f), Quaternion.Euler(90, 0, 0), turbine, turbineparent);

            GameObject pipeparent  = turbinePart.rigidPart;
            Trigger    pipetrigger = new Trigger("pipeTrigger", pipeparent, new Vector3(-0.12f, 0.085f, -0.04f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            pipePart = new Pipe(pipeSaveInfo, pipetrigger, new Vector3(-0.12f, 0.085f, -0.04f), new Quaternion(0, 0, 0, 0), pipe, pipeparent);

            GameObject pipe_rac_carbparent = GameObject.Find("cylinder head(Clone)");

            pipe_rac_carbtrigger = new Trigger("pipe_rac_carbTrigger", pipe_rac_carbparent, new Vector3(0.013f, -0.139f, 0.12f), Quaternion.Euler(90, 0, 0), new Vector3(0.3f, 0.3f, 0.3f), false);
            pipe_rac_carbPart    = new Pipe_rac_carb(pipe_rac_carbSaveInfo, pipe_rac_carbtrigger, new Vector3(0.013f, -0.139f, 0.12f), Quaternion.Euler(90, 0, 0), pipe_rac_carb, pipe_rac_carbparent);

            GameObject beltparent = turbinePart.rigidPart;

            belttrigger = new Trigger("beltTrigger", beltparent, new Vector3(0.035f, -0.091f, 0.08f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);
            beltPart    = new Belt(beltSaveInfo, belttrigger, new Vector3(0.035f, -0.091f, 0.08f), new Quaternion(0, 0, 0, 0), belt, beltparent);

            GameObject turbinegaugeParent  = GameObject.Find("dashboard(Clone)");
            Trigger    turbinegaugeTrigger = new Trigger("turbinegaugeTriger", turbinegaugeParent, new Vector3(0.48f, -0.04f, 0.135f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            turbinegaugePart = new Turbinegauge(turbinegaugeSaveInfo, turbinegaugeTrigger, new Vector3(0.48f, -0.04f, 0.135f), Quaternion.Euler(0, 0, 345), turbinegauge, turbinegaugeParent);

            GameObject pipe_2_carbparent = GameObject.Find("cylinder head(Clone)");

            pipe_2_carbtrigger = new Trigger("pipe_2_carbTrigger", pipe_rac_carbparent, new Vector3(0.06f, -0.147f, 0.04f), Quaternion.Euler(0, 0, 0), new Vector3(0.3f, 0.3f, 0.3f), false);
            pipe_2_carbPart    = new Pipe_2_carb(pipe_2_carbSaveInfo, pipe_2_carbtrigger, new Vector3(0.06f, -0.147f, 0.04f), Quaternion.Euler(90, 0, 0), pipe_2_carb, pipe_2_carbparent);

            GameObject switchbuttonparent  = GameObject.Find("dashboard(Clone)");
            Trigger    switchbuttontrigger = new Trigger("switchbuttonTrigger", switchbuttonparent, new Vector3(0.54f, -0.062f, -0.065f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            switch_buttonPart = new Switchbutton(switch_buttonSaveInfo, switchbuttontrigger, new Vector3(0.54f, -0.062f, -0.065f), Quaternion.Euler(12, 0, 0), switch_button, switchbuttonparent);

            GameObject filterparent  = pipePart.rigidPart;
            Trigger    filtertrigger = new Trigger("filterTrigger", filterparent, new Vector3(-0.14f, 0.075f, -0.035f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);

            filterPart = new Filter(filterSaveInfo, filtertrigger, new Vector3(-0.14f, 0.075f, -0.035f), Quaternion.Euler(0, 0, 0), filter, filterparent);

            GameObject headgasketparent = GameObject.Find("head gasket(Clone)");

            headgaskettrigger = new Trigger("headgasketTrigger", headgasketparent, new Vector3(0f, 0f, 0.003f), Quaternion.Euler(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f), false);
            headgasketPart    = new HeadGasket(headgasketSaveInfo, headgaskettrigger, new Vector3(0f, 0f, 0.003f), Quaternion.Euler(0, 0, 0), headgasket, headgasketparent);

            shop         = GameObject.Find("Shop for mods").GetComponent <ShopItem>();
            shop_turbine = new ProductDetails()
            {
                productName       = "Centrifugal supercharger",
                multiplePurchases = false,
                productCategory   = "Details",
                productIcon       = ab.LoadAsset <Sprite>("Turbine_ico.png"),
                productPrice      = 3499
            };
            if (!buysafeinfo.Buyturbine)
            {
                shop.Add(this, shop_turbine, ShopType.Fleetari, Buy_turbine, turbinePart.activePart);
                turbinePart.activePart.SetActive(false);
            }


            shopbelt = new ProductDetails()
            {
                productName       = "Belt",
                multiplePurchases = false,
                productCategory   = "Details",
                productIcon       = ab.LoadAsset <Sprite>("Belt.png"),
                productPrice      = 299
            };
            if (!buysafeinfo.Buybelt)
            {
                shop.Add(this, shopbelt, ShopType.Fleetari, Buy_belt, beltPart.activePart);
                beltPart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buypulley)
            {
                ProductDetails shop_pulley = new ProductDetails()
                {
                    productName       = "Pulley",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("pulley.png"),
                    productPrice      = 399
                };
                shop.Add(this, shop_pulley, ShopType.Fleetari, Buy_pulley, pulleyPart.activePart);
                pulleyPart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buypipe)
            {
                ProductDetails shop_pipe = new ProductDetails()
                {
                    productName       = "Pipe",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("pipe.png"),
                    productPrice      = 749
                };
                shop.Add(this, shop_pipe, ShopType.Fleetari, Buy_pipe, pipePart.activePart);
                pipePart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buypipe_rac_carb)
            {
                ProductDetails shop_pipe_rac_carb = new ProductDetails()
                {
                    productName       = "Racing carburators pipe",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("pipe2.png"),
                    productPrice      = 749
                };
                shop.Add(this, shop_pipe_rac_carb, ShopType.Fleetari, Buy_pipe_rac_carb, pipe_rac_carbPart.activePart);
                pipe_rac_carbPart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buypipe_2_carb)
            {
                ProductDetails shop_pipe_2_carb = new ProductDetails()
                {
                    productName       = "Twin carburators pipe",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("pipe3.png"),
                    productPrice      = 749
                };
                shop.Add(this, shop_pipe_2_carb, ShopType.Fleetari, Buy_pipe_2_carb, pipe_2_carbPart.activePart);
                pipe_2_carbPart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buyturbinegauge)
            {
                ProductDetails shop_turbinegauge = new ProductDetails()
                {
                    productName       = "Turbine gauge",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("Гаджет.png"),
                    productPrice      = 499
                };
                shop.Add(this, shop_turbinegauge, ShopType.Fleetari, Buy_turbinegauge, turbinegaugePart.activePart);
                turbinegaugePart.activePart.SetActive(false);
            }


            if (!buysafeinfo.Buyswitch_button)
            {
                ProductDetails shop_switch_button = new ProductDetails()
                {
                    productName       = "Switch button",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("switch 1.png"),
                    productPrice      = 249
                };
                shop.Add(this, shop_switch_button, ShopType.Fleetari, Buy_switch_button, switch_buttonPart.activePart);
                switch_buttonPart.activePart.SetActive(false);
            }

            shop_filter = new ProductDetails()
            {
                productName       = "Filter",
                multiplePurchases = false,
                productCategory   = "Details",
                productIcon       = ab.LoadAsset <Sprite>("filter.png"),
                productPrice      = 99
            };
            if (!buysafeinfo.Buyfilter)
            {
                shop.Add(this, shop_filter, ShopType.Fleetari, Buy_filter, filterPart.activePart);
                filterPart.activePart.SetActive(false);
            }

            if (!buysafeinfo.Buyheadgasket)
            {
                ProductDetails shop_headgasket = new ProductDetails()
                {
                    productName       = "Additional Head Gasket",
                    multiplePurchases = false,
                    productCategory   = "Details",
                    productIcon       = ab.LoadAsset <Sprite>("headgasket.png"),
                    productPrice      = 329
                };
                shop.Add(this, shop_headgasket, ShopType.Fleetari, Buy_headgasket, headgasketPart.activePart);
                headgasketPart.activePart.SetActive(false);
            }


            ab.Unload(false);

            UnityEngine.Object.Destroy(turbine);
            UnityEngine.Object.Destroy(pulley);
            UnityEngine.Object.Destroy(pipe);
            UnityEngine.Object.Destroy(pipe_rac_carb);
            UnityEngine.Object.Destroy(belt);
            UnityEngine.Object.Destroy(turbinegauge);
            UnityEngine.Object.Destroy(ab);
            UnityEngine.Object.Destroy(pipe_2_carb);
            UnityEngine.Object.Destroy(switch_button);
            turbinePart.rigidPart.GetComponent <AudioSource>().volume = 0;

            racingcarb_inst = false;
            carb2_inst      = false;

            fullreset = false;

            if (buysafeinfo.BoostOn)
            {
                switch_buttonPart.rigidPart.transform.GetChild(0).transform.localRotation = Quaternion.Euler(50, 0, 0);
            }
            else
            {
                switch_buttonPart.rigidPart.transform.GetChild(0).transform.localRotation = Quaternion.Euler(-50, 0, 0);
            }

            ModConsole.Print("Supercharger for Satsuma was loaded.");
        }
예제 #25
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
        }
예제 #26
0
        public override void OnLoad()
        {
            // Load the assets and create the standpipe prefab
            AssetBundle ab     = LoadAssets.LoadBundle(this, "standpipe.unity3d");
            GameObject  o      = ab.LoadAsset <GameObject>("standpipe.prefab");
            GameObject  prefab = GameObject.Instantiate <GameObject>(o);

            prefab.name = "standpipe";

            // Duplicate the tap
            GameObject tap = GameObject.Instantiate <GameObject>(GameObject.Find("KitchenWaterTap"));

            tap.transform.SetParent(prefab.transform);

            // Destroy base mesh
            GameObject.DestroyImmediate(tap.transform.Find("kitchen_tap_base").gameObject);

            // Set up lever
            Transform leverMesh   = prefab.transform.Find("standpipe_lever");
            Transform leverParent = tap.transform.Find("Handle");
            Vector3   handlePos   = leverMesh.localPosition;

            leverParent.SetParent(prefab.transform, false);
            leverParent.localPosition = handlePos;
            leverParent.localRotation = new Quaternion();
            leverMesh.SetParent(leverParent.Find("Pivot"));
            leverMesh.localPosition = new Vector3();

            // Set up trigger
            Transform trig = tap.transform.Find("Trigger");

            trig.SetParent(prefab.transform);
            trig.localPosition = new Vector3(0.0f, 0.892f, 0.035f);
            SphereCollider coll = trig.GetComponent <SphereCollider>();

            coll.radius = 0.15f;

            // Set up particles
            Transform particle = tap.transform.Find("Particle");

            particle.SetParent(prefab.transform, false);
            particle.localPosition = new Vector3(0.0f, 0.7887f, 0.215f);

            // Set up component
            prefab.AddComponent <StandpipeBehaviour>();
            particle.GetComponent <AudioSource>().clip = ab.LoadAsset <AudioClip>("assets/audio/waterflow.ogg");

            // Carve out the remains
            GameObject.DestroyImmediate(leverParent.Find("Pivot/kitchen_tap_handle").gameObject);
            GameObject.DestroyImmediate(tap);

            // Set up multiple standpipes
            GameObject parent = new GameObject("STANDPIPES");

            for (int i = 0; i < _positions.Length; ++i)
            {
                GameObject instance = GameObject.Instantiate <GameObject>(prefab);
                instance.transform.SetParent(parent.transform);
                instance.transform.position = _positions[i];
                instance.transform.rotation = Quaternion.Euler(0.0f, _rotations[i], 0.0f);
            }

            // Destroy the prefabs and unload the bundle
            GameObject.Destroy(prefab);
            GameObject.Destroy(o);
            ab.Unload(false);
        }
예제 #27
0
        public override void OnLoad()
        {
            if (ModLoader.MSCLoader_Ver.ToString() != minMSCLoaderVersion)
            {
                versionOK = false;
            }
            else
            {
                versionOK = true;
            }

            if (versionOK)
            {
                ModConsole.Print("Passed MSCLoader version check. Setting up...");
                try
                {
                    _satsuma = GameObject.Find("SATSUMA(557kg, 248)");
                    player   = GameObject.Find("PLAYER");

                    AssetBundle ab;

                    try
                    {
                        ab = LoadAssets.LoadBundle(this, "satsumamaster.unity3d");
                    }
                    catch (Exception)
                    {
                        ModConsole.Error("You have not installed this mod correctly. Please copy all files from the downloaded archive. Missing Assets/Satsuma Master/satsumamaster.unity3d file.");
                        return;
                    }

                    uiHandler = new UIHandler(this, ab);

                    SetupGradient();
                    uiHandler.ToggleStats();
                    uiHandler.ToggleXFSPanel();
                    uiHandler.ToggleTPPanel();
                    uiHandler.ShowUI();

                    soundControllerMod = new SoundController(this, ab);

                    ab.Unload(false);

                    wheelSuspensionMod = new SuspensionWheelController(this);
                    teleportMod        = new Teleport(player, _satsuma);
                    sixGearsMod        = new SixGears(this);
                    engineFixerMod     = new EngineFixer(this);

                    if (_satsuma != null)
                    {
                        _satsumaDriveTrain = _satsuma.GetComponent <Drivetrain>();
                        if (_satsumaDriveTrain != null)
                        {
                            defaultRPM           = _satsumaDriveTrain.maxRPM;
                            defaultShiftUpRPM    = _satsumaDriveTrain.shiftUpRPM;
                            defaultShiftDownRPM  = _satsumaDriveTrain.shiftDownRPM;
                            sixGearsMod.oldRatio = _satsumaDriveTrain.gearRatios;
                            enableBoost          = true;

                            engineFixerMod.OptimizeEngineFixer();
                        }
                    }

                    ModConsole.Print(Name + ": Success!");

                    setupOK = true;

                    Keybind.Add(this, ShowUIBind);
                }
                catch (Exception e)
                {
                    ModConsole.Error("Asset load and setup failed. Message: " + e);
                    return;
                }
            }
            else
            {
                ModConsole.Error("Wrong version of MSCLoader detected. MSCLoader 1.1.4 is supported. If MSCLoader has been updated, contact the mod author.");
            }
        }
예제 #28
0
        private void _initLightWithBundle(SaveData saveData)
        {
            AssetBundle bundle = LoadAssets.LoadBundle(this, "floodlight.unity3d");

            _base = bundle.LoadAsset <GameObject>("floodlight.prefab");
        }
예제 #29
0
        // Update is called once per frame
        public override void Update()
        {
            if (Application.loadedLevelName == "GAME")
            {
                try
                {
                    if (!this.m_isLoaded)
                    {
                        if (GameObject.Find("PLAYER/Pivot/Camera/FPSCamera/1Hand_Assemble/Hand") == null)
                        {
                            return;
                        }
                        if (GameObject.Find("SATSUMA(557kg, 248)") == null)
                        {
                            return;
                        }

                        string patch = Path.Combine(ModLoader.GetModAssetsFolder(this), "trailerbundle");
                        if (!File.Exists(patch))
                        {
                            ModConsole.Error("Couldn't find asset bundle from path " + patch);
                            return;
                        }
                        else
                        {
                            this.m_bundle = LoadAssets.LoadBundle(this, patch);
                            if (m_bundle != null)
                            {
                                hitch = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch"));
                                hitch.AddComponent <HitchBehaviour>();

                                hitchv = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch"));
                                hitchv.AddComponent <HitchVBehaviour>();

                                trailer = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("carreta"));
                                trailer.AddComponent <TrailerBehaviour>();

                                trailer.GetComponent <TrailerBehaviour>().Hitch  = hitch;
                                trailer.GetComponent <TrailerBehaviour>().HitchV = hitchv;

                                this.m_bundle.Unload(false);
                            }
                            else
                            {
                                ModConsole.Print("Bundle Null: " + patch);
                            }
                        }
                        this.m_isLoaded = true;
                    }
                    return;
                }
                catch (Exception ex)
                {
                    this.m_isLoaded = false;
                    ModConsole.Error(ex.ToString());
                    return;
                }
            }
            if (Application.loadedLevelName != "GAME" && this.m_isLoaded)
            {
                this.m_isLoaded = false;
            }
        }