예제 #1
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();
            }
        }
        /// <summary>
        /// Occurs on game load.
        /// </summary>
        public override void OnLoad()
        {
            // Written, 18.10.2018
            // Called once, when mod is loading after game is fully loaded

            // Creating truck engine object. NOTE Mod-API excepts the gameobject to have both a rigidbody and a collider attached before passing the reference.
            GameObject truckEngineGo = LoadAssets.LoadOBJ(this, @"truck_engine.obj", rigidbody: true);

            truckEngineGo.name = "Truck Engine";
            // Loading and assigning the texture for the object.
            Texture2D engineTexture = LoadAssets.LoadTexture(this, "Truck_Engine_Texture.png");

            truckEngineGo.GetComponent <Renderer>().material.mainTexture = engineTexture;
            GameObject parent = GameObject.Find("SATSUMA(557kg, 248)");
            // Creating trigger for truck engine. and assigning the local location and scale of the trigger related to the parent. (in this case the satsuma).
            Trigger trigger = new Trigger("TruckEngineTrigger", parent, new Vector3(0.0f, 1.3f, -0.3f), Quaternion.Euler(0, 0, 0), new Vector3(1f, 1f, 1f), false);

            // Creating a new instance of the truckengine.
            this.truckEngine = new TruckEngine(
                this.loadSaveData(),            // The save data, as this is null, default save info will always be loaded.
                truckEngineGo,                  // The instance of the part to create.
                parent,                         // The parent for the part; the gameobject the part installs to.
                trigger,                        // The trigger for the part.
                new Vector3(0.0f, 0.63f, 1.5f), // The installed-position
                new Quaternion(0, 90, 90, 0));  // The installed-rotation
            ModConsole.Print(string.Format("{0} v{1}: Loaded.", this.Name, this.Version));
        }
        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.");
        }
예제 #4
0
        private void Waiting2r()
        {
            Thread.Sleep(20000);
            Mesh      mesh        = LoadAssets.LoadOBJMesh(this, "tire_rally.obj");
            Texture2D mainTexture = LoadAssets.LoadTexture(this, "tires_rally.dds", false);

            GameObject[] array = GameObject.FindObjectsOfType <GameObject>();
            for (int i = 0; i < array.Length; i++)
            {
                GameObject gameObject = array[i];
                if (gameObject.name == "TireRally(Clone)")
                {
                    gameObject.GetComponent <MeshFilter>().mesh = (mesh);
                    gameObject.GetComponent <MeshRenderer>().material.mainTexture = (mainTexture);
                }
            }
            if (GameObject.Find("wheel rally fl(Clone)").activeSelf)
            {
                this.FLRIM = GameObject.Find("wheel rally fl(Clone)");
                this.FRRIM = GameObject.Find("wheel rally fr(Clone)");
                this.RLRIM = GameObject.Find("wheel rally rl(Clone)");
                this.RRRIM = GameObject.Find("wheel rally rr(Clone)");
                Mesh mesh2 = LoadAssets.LoadOBJMesh(this, "rim_rally.obj");
                this.FLRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2);
                this.FRRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2);
                this.RLRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2);
                this.RRRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2);
            }
        }
예제 #5
0
    public void LoadPlayerFromAssetBundle()
    {
        LoadAssets loader = GetComponent <LoadAssets>();

        StartCoroutine(loader.InstantiateGameObjectAsync(assetBundleName, assetName));
        //this.gameObject.SetActive(false);
    }
예제 #6
0
    void Update()
    {
        if (loadingList.Count > 0)
        {
            for (int i = 0; i < loadingList.Count; i++)
            {
                if (loadingList[i].IsDone)
                {
                    LoadAssets loadAssets = loadingList[i];
                    for (int j = 0; j < loadAssets.Listeners.Count; j++)
                    {
                        loadAssets.Listeners[j].OnLoaded(loadAssets.AssetPath, loadAssets.GetAsset);
                    }
                    //添加到已经加载的字典里
                    loadedAssets.Add(loadAssets.AssetPath, loadAssets.GetAsset);
                    //从正在加载列表里移除
                    loadingList.RemoveAt(i);
                }
            }
        }

        while (waitingQueue.Count > 0 && loadingList.Count < 5)
        {
            LoadAssets loadAssets = waitingQueue.Dequeue();
            loadingList.Add(loadAssets);
            loadAssets.LoadAsync();
        }
    }
예제 #7
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);
        }
예제 #8
0
        private void _initShop()
        {
            // Load the lightbulb box
            GameObject original = LoadAssets.LoadOBJ(this, "model\\box.obj", false, false);

            original.name = "new_lightbulb";
            original.GetComponent <MeshRenderer>().material.mainTexture = LoadAssets.LoadTexture(this, "model\\box_d.png");
            AudioSource audio = original.AddComponent <AudioSource>();

            audio.clip             = GameObject.Find("cash_register_2").GetComponent <AudioSource>().clip;
            audio.transform.parent = original.transform;
            audio.spatialBlend     = 1.0f;
            audio.maxDistance      = 10.0f;

            GameObject fBox = GameObject.Instantiate <GameObject>(original);

            original.transform.position = _teimoPos;
            original.transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f);
            MeshCollider coll = original.AddComponent <MeshCollider>();

            coll.name         = "replace lightbulb (300mk)(Clone)";
            coll.convex       = true;
            coll.isTrigger    = true;
            _boxColliderTeimo = coll;

            fBox.transform.position = _fleetariPos;
            coll                 = fBox.AddComponent <MeshCollider>();
            coll.name            = "replace lightbulb (300mk)(Clone)";
            coll.convex          = true;
            coll.isTrigger       = true;
            _boxColliderFleetari = coll;
        }
예제 #9
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;
        }
예제 #10
0
    /// <summary>
    /// 异步加载
    /// </summary>
    /// <param name="assetPath">资源路径</param>
    /// <param name="assetType">资源类型</param>
    /// <param name="listener">回调</param>
    private void LoadAsync(string assetPath, Type assetType, IResourceListener listener)
    {
        //正在被加载,还没加载完成
        foreach (LoadAssets item in loadingList)
        {
            if (item.AssetPath == assetPath)
            {
                item.AddListener(listener);
                return;
            }
        }
        //等待的队列里面有
        foreach (LoadAssets item in waitingQueue)
        {
            if (item.AssetPath == assetPath)
            {
                item.AddListener(listener);
                return;
            }
        }
        //都没有 先创建
        LoadAssets loadAssets = new LoadAssets();

        loadAssets.AssetPath = assetPath;
        loadAssets.AssetType = assetType;
        loadAssets.AddListener(listener);
        //添加到等待队列
        waitingQueue.Enqueue(loadAssets);
    }
예제 #11
0
 void Start()
 {
     loadAssets = GetComponent <LoadAssets>();
     foreach (KeyValuePair <string, int> selectionType in currentIndex)
     {
         SetSelectionText(selectionType.Key, loadAssets.GetName(selectionType.Key, currentIndex[selectionType.Key]));
     }
 }
예제 #12
0
    void Start()
    {
        loadAssets      = FindObjectOfType <LoadAssets>();
        rend            = GetComponent <Renderer>();
        microphoneInput = FindObjectOfType <MicrophoneInput>();

        StartCoroutine(CoBlink());
        StartCoroutine(CoFrameChangeChecker());
    }
예제 #13
0
 // 结束加载和更新程序
 public void  startAnimEnd()
 {
     if (_loadassets != null)
     {
         _loadassets.clear();
         Destroy(_loadassets.MyGameObj);
         _loadassets = null;
     }
 }
예제 #14
0
    void Start()
    {
        audioSource = GetComponent <AudioSource>();
        rend        = GetComponent <Renderer>();

        textureHandler = FindObjectOfType <TextureHandler>();
        loadAssets     = FindObjectOfType <LoadAssets>();

        StartCoroutine(CoRecordingRestarter());
    }
예제 #15
0
 void ThrowEvent()
 {
     transform.SetParent(null);
     LoadAssets.MakeGameObjectPickable(gameObject);
     rigidbody.isKinematic   = false;
     transform.localPosition = Camera.main.transform.position + new Vector3(0, -0.1f, 0);
     MasterAudio.PlaySound3DAndForget("Burb", transform, false, 1f, null, 0f, "burb01");
     rigidbody.AddForce(Camera.main.transform.forward * 150);
     gameObject.name = "empty(Clone)";
     enabled         = false;
 }
예제 #16
0
        private void showLoadAnim()
        {
            GameObject gameObj = GameObject.Find("UILoadAssets");

            if (gameObj == null)
            {
                GameObject showObj = (GameObject)Resources.Load("UILoadAssets");
                gameObj = (GameObject)Instantiate(showObj);
            }
            _loadassets = gameObj.GetComponent <LoadAssets>();
            _loadassets.init(this);
        }
예제 #17
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);
        }
예제 #18
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);
 }
예제 #19
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());
            }
        }
예제 #20
0
 void TakeOutItem()
 {
     if (amount > 0)
     {
         GameObject instantiatedObject = GameObject.Instantiate(item) as GameObject;
         instantiatedObject.transform.position = gameObject.transform.position;
         LoadAssets.MakeGameObjectPickable(instantiatedObject);
         amount -= 1;
     }
     else
     {
         gameObject.name = "empty(Clone)";
         enabled         = false;
     }
 }
예제 #21
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);
        }
예제 #22
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);
        }
예제 #23
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);
        }
예제 #24
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>();
        }
예제 #25
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);
        }
예제 #26
0
        private async Task LoadAssets(LoadAssets payload, Action onCompleteCallback)
        {
            LoaderFunction loader;

            switch (payload.Source.ContainerType)
            {
            case AssetContainerType.GLTF:
                loader = LoadAssetsFromGLTF;
                break;

            default:
                throw new Exception(
                          $"Cannot load assets from unknown container type {payload.Source.ContainerType.ToString()}");
            }

            IList <Asset> assets         = null;
            string        failureMessage = null;

            // attempt to get cached assets instead of loading
            try
            {
                assets = await loader(payload.Source, payload.ContainerId, payload.ColliderType);

                ActiveContainers.Add(payload.ContainerId);
            }
            catch (Exception e)
            {
                failureMessage = UtilMethods.FormatException(
                    $"An unexpected error occurred while loading the asset [{payload.Source.Uri}].", e);
            }

            _app.Protocol.Send(new Message()
            {
                ReplyToId = payload.MessageId,
                Payload   = new AssetsLoaded()
                {
                    FailureMessage = failureMessage,
                    Assets         = assets?.ToArray()
                }
            });
            onCompleteCallback?.Invoke();
        }
예제 #27
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);
        }
예제 #28
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");
        }
        public override void OnLoad()
        {
            // Written, 23.09.2018
            // Called once, when mod is loading after game is fully loaded

            // Creating Game Object.
            this.truckEngine = LoadAssets.LoadOBJ(this, @"truck_engine.obj", true, true);
            // Loading and assigning the texture for the object.
            this.engineTexture = LoadAssets.LoadTexture(this, "Truck_Engine_Texture.png");
            this.truckEngine.GetComponent <Renderer>().material.mainTexture = this.engineTexture;
            // Naming the object. NOTE, name must follow naming convention of <ObjectName>(xxxxx) where <ObjectName> is the game objects name.
            this.truckEngine.name = "Truck Engine(xxxxx)";
            // Spawning the game object to home.
            this.truckEngine.transform.position = new Vector3(-20.7f, 10, 10.9f); // Home Location (Outside Garage)
            this.truckEngine.transform.rotation = new Quaternion(0, 90, 90, 0);   // The Rotation.
            // Allowing the object to be picked up.
            this.truckEngine.tag = "PART";
            // Sending object to it's own layer.
            this.truckEngine.layer = LayerMask.NameToLayer(this.truckEngine.name);
        }
예제 #30
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;
            }
        }