예제 #1
0
        /// <summary>
        /// Initialize MinorObjects class
        /// </summary>
        public Items()
        {
            instance         = this;
            cashRegisterHook = GameObject.Find("STORE/StoreCashRegister/Register").AddComponent <CashRegisterHook>();

            // Car parts order bill hook.
            GameObject           postOrder = GameObject.Find("STORE").transform.Find("LOD/ActivateStore/PostOffice/PostOrderBuy").gameObject;
            EnvelopeOrderBuyHook h         = postOrder.AddComponent <EnvelopeOrderBuyHook>();

            h.Initialize(cashRegisterHook);

            // Fish trap spawner.
            FsmHook.FsmInject(GameObject.Find("fish trap(itemx)").transform.Find("Spawn").gameObject, "Create product", cashRegisterHook.Fishes);

            InitializeList();

            // Uncle's beer case bottle despawner
            Transform uncleBeerCaseTransform = GameObject.Find("YARD").transform.Find("UNCLE/Home/UncleDrinking/Uncle/beer case(itemx)");

            if (uncleBeerCaseTransform == null)
            {
                ModConsole.Print("[MOP] Couldn't find uncle's beer case, so it will be skipped...");
                return;
            }

            uncleBeerCaseTransform.gameObject.AddComponent <UncleBeerCaseHook>();
        }
예제 #2
0
        /// <summary>
        /// Find all new objects, and add ObjectHook to them.
        /// Also, find shopping bags, inject TriggerMinorObjectRefresh into them.
        /// </summary>
        void InjectNewItems()
        {
            // Find shopping bags in the list
            GameObject[] items = FindObjectsOfType <GameObject>()
                                 .Where(gm => gm.name.ContainsAny(MinorObjects.instance.listOfMinorObjects) && gm.name.ContainsAny("(itemx)", "(Clone)"))
                                 .ToArray();

            if (items.Length > 0)
            {
                for (int i = 0; i < items.Length; i++)
                {
                    // Object already ObjectHook attached? Ignore it.
                    if (items[i].GetComponent <ObjectHook>() != null)
                    {
                        continue;
                    }

                    items[i].AddComponent <ObjectHook>();

                    // Hook the TriggerMinorObjectRefresh to Confirm and Spawn all actions
                    if (items[i].name.Contains("shopping bag"))
                    {
                        FsmHook.FsmInject(items[i], "Confirm", TriggerMinorObjectRefresh);
                        FsmHook.FsmInject(items[i], "Spawn all", TriggerMinorObjectRefresh);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Further initialization
        /// For example injects hooks to the tool/hand that defines if the user has a tool in his hand
        /// Some of the values are loaded as static and used for each and every instance of the logic to improve performance
        /// </summary>
        void Start()
        {
            if (spanner == null || ratchet == null)
            {
                initAlreadyRun = false;
            }
            if (!initAlreadyRun)
            {
                try
                {
                    GameObject selectedItem    = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/SelectItem");
                    GameObject twoSpanner      = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera").transform.Find("2Spanner").gameObject;
                    GameObject twoSpannerPivot = twoSpanner.transform.Find("Pivot").gameObject;
                    GameObject twoSpannerPick  = twoSpanner.transform.Find("Pick").gameObject;

                    spanner = twoSpannerPivot.transform.Find("Spanner").gameObject;
                    ratchet = twoSpannerPivot.transform.Find("Ratchet").gameObject;

                    ratchetSwitch = Helper.FindFsmOnGameObject(ratchet, "Switch").FsmVariables.FindFsmBool("Switch");
                    FsmHook.FsmInject(selectedItem, "Hand", new Action(delegate() { isToolInHand = false; }));
                    FsmHook.FsmInject(selectedItem, "Tools", new Action(delegate() { isToolInHand = true; }));
                    initAlreadyRun = true;
                }
                catch
                {
                    initAlreadyRun = false;
                }
            }

            _boltingSpeed = PlayMakerGlobals.Instance.Variables.GetFsmFloat("BoltingSpeed");
            _wrenchSize   = PlayMakerGlobals.Instance.Variables.GetFsmFloat("ToolWrenchSize");
        }
예제 #4
0
        void Start()
        {
            FsmHook.FsmInject(gameObject, "State 2", () => isActive        = true);
            FsmHook.FsmInject(gameObject, "Mouse off", () => isActive      = false);
            FsmHook.FsmInject(gameObject, "Open hood 2", () => isHoodOpen  = true);
            FsmHook.FsmInject(gameObject, "Close hood 2", () => isHoodOpen = false);

            useFsm = gameObject.GetPlayMakerFSM("Use");
        }
예제 #5
0
파일: RepairShop.cs 프로젝트: Athlon007/MOP
        /// <summary>
        /// Initialize the RepairShop class
        /// </summary>
        public RepairShop() : base("REPAIRSHOP", 250)
        {
            // Set junk car objects parent to null.
            for (int i = 1; transform.Find($"JunkCar{i}") != null; i++)
            {
                Transform junk = transform.Find($"JunkCar{i}");
                if (junk != null)
                {
                    junk.parent = null;
                }
            }

            GameObjectBlackList.AddRange(blackList);
            DisableableChilds = GetDisableableChilds();

            // Fix for Satsuma parts on shelves
            List <Transform> productsMesh = DisableableChilds.FindAll(t => t.name == "mesh" && t.parent.name.Contains("Product"));

            foreach (Transform product in productsMesh)
            {
                DisableableChilds.Remove(product);
            }

            // Fix Sphere Collider of the cash register.
            SphereCollider registerCollider = transform.Find("LOD/Store/ShopCashRegister/Register").gameObject.GetComponent <SphereCollider>();

            registerCollider.radius = 70;
            Vector3 newBounds = registerCollider.center;

            newBounds.x             = 5;
            registerCollider.center = newBounds;

            // Add collider to Fury.
            BoxCollider collBox0 = transform.Find("LOD/Vehicle/FURY").gameObject.AddComponent <BoxCollider>();
            BoxCollider collBox1 = transform.Find("LOD/Vehicle/FURY").gameObject.AddComponent <BoxCollider>();

            collBox0.center = new Vector3(0, 0, -.2f);
            collBox0.size   = new Vector3(2.2f, 1.3f, 5);
            collBox1.center = new Vector3(0, 0, -.25f);
            collBox1.size   = new Vector3(1.4f, 2.3f, 1.1f);

            // Hooks a trigger for when Satsuma has been moved by the Fleetari, so it won't get teleported back.
            try
            {
                FsmHook.FsmInject(transform.Find("Order").gameObject, "Move Satsuma", Satsuma.Instance.FleetariIsMovingCar);
            }
            catch
            {
                throw new System.Exception("Couldn't FsmHook RepairShop/Order object.");
            }

            // Fix door resetting.
            transform.Find("LOD/Door/Handle").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;

            Compress();
        }
예제 #6
0
        // This script hooks to unkkel alkohol beer case

        void Start()
        {
            if (GetComponent <PlayMakerFSM>() == null)
            {
                return;
            }

            FsmHook.FsmInject(this.gameObject, "Remove bottle", DestroyBeerBottles);
            FsmHook.FsmInject(this.gameObject, "Remove bottle", HookBottles);
        }
예제 #7
0
        /// <summary>
        /// Injects the newly bought store items.
        /// </summary>
        /// <returns></returns>
        IEnumerator PurchaseCoroutine()
        {
            // Wait for few seconds to let all objects to spawn, and then inject the objects.
            yield return(new WaitForSeconds(2));

            // Find shopping bags in the list
            GameObject[] items = FindObjectsOfType <GameObject>()
                                 .Where(gm => gm.name.ContainsAny(Items.instance.BlackList) && gm.name.ContainsAny("(itemx)", "(Clone)"))
                                 .ToArray();

            if (items.Length > 0)
            {
                int half = items.Length / 2;
                for (int i = 0; i < items.Length; i++)
                {
                    // Skip frame
                    if (i == half)
                    {
                        yield return(null);
                    }

                    // Object already has ObjectHook attached? Ignore it.
                    if (items[i].GetComponent <ItemHook>() != null)
                    {
                        continue;
                    }

                    items[i].AddComponent <ItemHook>();

                    // Hook the TriggerMinorObjectRefresh to Confirm and Spawn all actions
                    if (items[i].name.Equals("shopping bag(itemx)"))
                    {
                        FsmHook.FsmInject(items[i], "Confirm", TriggerMinorObjectRefresh);
                        FsmHook.FsmInject(items[i], "Spawn all", TriggerMinorObjectRefresh);
                    }
                    else if (items[i].name.EqualsAny("spark plug box(Clone)", "car light bulb box(Clone)"))
                    {
                        FsmHook.FsmInject(items[i], "Create Plug", WipeUseLoadOnSparkPlugs);
                    }
                    else if (items[i].name.EqualsAny("alternator belt(Clone)", "oil filter(Clone)", "battery(Clone)"))
                    {
                        PlayMakerFSM          fanbeltUse   = items[i].GetPlayMakerByName("Use");
                        FsmState              loadFanbelt  = fanbeltUse.FindFsmState("Load");
                        List <FsmStateAction> emptyActions = new List <FsmStateAction> {
                            new CustomNullState()
                        };
                        loadFanbelt.Actions = emptyActions.ToArray();
                        loadFanbelt.SaveActions();
                    }
                }
                WipeUseLoadOnSparkPlugs();
            }
            currentRoutine = null;
        }
예제 #8
0
        private void InitHandDetection()
        {
            selectedItem    = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/SelectItem");
            selectedItemFSM = selectedItem.GetComponent <PlayMakerFSM>();

            FsmHook.FsmInject(selectedItem, "Hand", new Action(ChangedToHand));
            FsmHook.FsmInject(selectedItem, "Tools", new Action(ChangedToTools));

            _boltingSpeed = PlayMakerGlobals.Instance.Variables.GetFsmFloat("BoltingSpeed");
            _wrenchSize   = PlayMakerGlobals.Instance.Variables.GetFsmFloat("ToolWrenchSize");
        }
예제 #9
0
        IEnumerator PackagesCoroutine()
        {
            yield return(new WaitForSeconds(2));

            GameObject[] packages = Resources.FindObjectsOfTypeAll <GameObject>()
                                    .Where(g => g.name == "amis-auto ky package(xxxxx)" && g.activeSelf).ToArray();

            foreach (GameObject package in packages)
            {
                FsmHook.FsmInject(package, "State 1", TriggerMinorObjectRefresh);
            }
        }
예제 #10
0
        /// <summary>
        /// Occurs when mono starts.
        /// </summary>
        private void Start()
        {
            // Written, 17.04.2019

            FsmHook.FsmInject(this.gameObject, "Purchase", this.playerPurchasedItems);

            PlayMakerFSM playMakerFSM = this.gameObject.GetComponent <PlayMakerFSM>();

            this.brakefluidQuantity    = playMakerFSM.FsmVariables.FindFsmInt("QBrakeFluid");
            this.motorOilQuantity      = playMakerFSM.FsmVariables.FindFsmInt("QMotorOil");
            this.coolantQuantity       = playMakerFSM.FsmVariables.FindFsmInt("QCoolant");
            this.twoStrokeFuelQuantity = playMakerFSM.FsmVariables.FindFsmInt("QTwoStroke");
        }
예제 #11
0
        /// <summary>
        /// Occurs when a purchase contains one or more vaild fluid containers.
        /// </summary>
        private void fluidContainerSpawned()
        {
            // Written, 02.05.2019

            Thread spawnThread = new Thread(delegate()
            {
                Thread.Sleep(delay); // 2.5f second delay (allows time for items to spawn).

                if (this.shoppingBagSpawn)
                {
                    GameObject shoppingBagSpawn = GameObject.Find("STORE/LOD/Shop/ShoppingBagSpawn"); // Location of all shopping bags in game.

                    for (int i = 0; i < shoppingBagSpawn.transform.childCount; i++)                   // enumerating over all child gameobjets (a shopping bag) of bag spawn.
                    {
                        GameObject shoppingBag = shoppingBagSpawn.transform.GetChild(i).gameObject;
                        GameObject spawnBag    = shoppingBag.transform.GetChild(shoppingBag.transform.childCount - 1).gameObject; // SpawnBag child contains all items purchased (with an id).

                        for (int j = 0; j < spawnBag.transform.childCount; j++)
                        {
                            GameObject child = spawnBag.transform.GetChild(j).gameObject; // maybe brake fluid conatiner.

                            if (child.name.Contains("brakefluid"))
                            {
                                FsmHook.FsmInject(shoppingBag, "Play anim", this.fluidContainerSpawned);
#if DEBUG
                                ModConsole.Print(string.Format("<b>[fluidContainerSpawned] -</b> Injected shopping bag, (index: {0}).", i));
#endif
                                break;
                            }
                        }
                    }
                    this.shoppingBagSpawn = false;
                }
                EnchancedFluidContainersMod.setFluidContainers();
            });

            spawnThread.Start();
#if DEBUG
            ModConsole.Print("<b>[fluidContainerSpawned] -</b> One or more vaild fluid container/s purchased; efcm component addition delayed by, " + delay + "ms");
            if (this.shoppingBagSpawn)
            {
                ModConsole.Print("<b>[fluidContainerSpawned] -</b> Shopping bag will be injected.");
            }
#endif
        }
예제 #12
0
        public void Initialize(Vector3 position, Vector3 scale, GameObject triggerObject)
        {
            gameObject.transform.parent           = GameObject.Find("SATSUMA(557kg, 248)").transform;
            gameObject.transform.localPosition    = position;
            gameObject.transform.localEulerAngles = Vector3.zero;
            gameObject.transform.localScale       = scale;

            BoxCollider collider = gameObject.AddComponent <BoxCollider>();

            collider.isTrigger = true;

            rb             = gameObject.AddComponent <Rigidbody>();
            rb.isKinematic = false;
            rb.useGravity  = true;
            rb.mass        = .1f;

            trunkContent = new List <GameObject>();

            storageOpen = triggerObject.GetComponent <PlayMakerFSM>().FsmVariables.GetFsmBool("Open");

            bool disableAfterHook = false;

            if (!triggerObject.activeSelf)
            {
                disableAfterHook = true;
                triggerObject.SetActive(true);
            }

            FsmHook.FsmInject(triggerObject, "Mouse off", OnBootAction);

            if (disableAfterHook)
            {
                triggerObject.SetActive(false);
            }

            rearSeatPivot = GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Interior/pivot_seat_rear");

            FixedJoint joint = gameObject.AddComponent <FixedJoint>();

            joint.connectedBody       = transform.parent.root.gameObject.GetComponent <Rigidbody>();
            joint.breakForce          = Mathf.Infinity;
            joint.breakTorque         = Mathf.Infinity;
            joint.enablePreprocessing = true;
        }
예제 #13
0
        IEnumerator InitializationRoutine(bool noDelay = false)
        {
            if (noDelay)
            {
                yield return(null);
            }
            else
            {
                yield return(new WaitForSeconds(2));
            }

            this.initialLocalRotation = this.transform.localRotation;
            this.initialLocalPosition = this.transform.localPosition;

            if (!initialHookDone)
            {
                FsmHook.FsmInject(GameObject.Find("SATSUMA(557kg, 248)").transform.Find("Body/trigger_hood").gameObject, "Assemble 2", UpdateInitialRotation);
                initialHookDone = true;
            }
        }
예제 #14
0
        public ObjectHook()
        {
            // Add self to the MinorObjects.objectHooks list
            MinorObjects.instance.Add(this);

            // Get the current rotation and position.
            position = gm.transform.position;
            rotation = gm.transform.rotation;

            // Get PlayMakerFSM
            playMakerFSM = gm.GetComponent <PlayMakerFSM>();

            // Get rigidbody
            rb = GetComponent <Rigidbody>();

            // From PlayMakerFSM, find states that contain one of the names that relate to destroying object,
            // and inject RemoveSelf void.
            foreach (var st in playMakerFSM.FsmStates)
            {
                switch (st.Name)
                {
                case "Destroy self":
                    FsmHook.FsmInject(this.gameObject, "Destroy self", RemoveSelf);
                    break;

                case "Destroy":
                    FsmHook.FsmInject(this.gameObject, "Destroy", RemoveSelf);
                    break;

                case "Destroy 2":
                    FsmHook.FsmInject(this.gameObject, "Destroy 2", RemoveSelf);
                    break;
                }
            }

            isBeerCase = gm.name.Contains("beer case");
        }
예제 #15
0
파일: KruFPS.cs 프로젝트: Krutonium/KruFPS
 private void HookAllSavePoints()
 {
     //Here we hook into all save points
     //So we can do stuff Before SaveGame event is fired,
     //In PrepareForSaveGame() function.
     FsmHook.FsmInject(GameObject.Find("REPAIRSHOP").transform.Find("LOD/SHITHOUSE/SavePivot").GetChild(0).gameObject, "Mute audio", PrepareForSaveGame);
     if (!GameObject.Find("STORE").transform.Find("LOD/SHITHOUSE/SavePivot").GetChild(0).gameObject.activeSelf)
     {
         GameObject.Find("STORE").transform.Find("LOD/SHITHOUSE/SavePivot").GetChild(0).gameObject.SetActive(true);
     }
     FsmHook.FsmInject(GameObject.Find("STORE").transform.Find("LOD/SHITHOUSE/SavePivot").GetChild(0).gameObject, "Mute audio", PrepareForSaveGame);
     FsmHook.FsmInject(GameObject.Find("COTTAGE").transform.Find("SHITHOUSE/SavePivot").GetChild(0).gameObject, "Mute audio", PrepareForSaveGame);
     if (!GameObject.Find("CABIN").transform.Find("SHITHOUSE/SavePivot").GetChild(0).gameObject.activeSelf)
     {
         GameObject.Find("CABIN").transform.Find("SHITHOUSE/SavePivot").GetChild(0).gameObject.SetActive(true);
     }
     FsmHook.FsmInject(GameObject.Find("CABIN").transform.Find("SHITHOUSE/SavePivot").GetChild(0).gameObject, "Mute audio", PrepareForSaveGame);
     FsmHook.FsmInject(GameObject.Find("LANDFILL").transform.Find("SHITHOUSE/SavePivot").GetChild(0).gameObject, "Mute audio", PrepareForSaveGame);
     FsmHook.FsmInject(GameObject.Find("YARD").transform.Find("Building/LIVINGROOM/LOD_livingroom/SAVEGAME").gameObject, "Mute audio", PrepareForSaveGame);
     if (GameObject.Find("JAIL") != null)
     {
         FsmHook.FsmInject(GameObject.Find("JAIL/SAVEGAME"), "Mute audio", PrepareForSaveGame);
     }
 }
예제 #16
0
 void Start()
 {
     FsmHook.FsmInject(this.gameObject, "State 3", cashRegisterHook.Packages);
 }
예제 #17
0
 public CashRegisterHook()
 {
     FsmHook.FsmInject(this.gameObject, "Purchase", TriggerMinorObjectRefresh);
     InjectNewItems();
 }
예제 #18
0
        // This script hooks up to all vehicles that can drive the player as a passenger to his house.
        // Uppon entering the car, parent of the object is set to null.

        void Start()
        {
            FsmHook.FsmInject(transform.Find("PlayerTrigger/DriveTrigger").gameObject, "Player in car", () => transform.parent = null);
        }
예제 #19
0
        /// <summary>
        /// Generates the Screws for a part and makes them detectable using the DetectBolting method
        /// <para>Dont ever change the name of the BOLT GameObject that gets created, which is always parentGameObject.name + "_BOLT + boltNumber</para>
        /// <para>example: Racing Turbocharger_BOLT1</para>
        /// <para>the constructor will auto find the correct gameObject to create the screws on (if names did not change)</para>
        /// </summary>
        /// <param name="screwsListSave">SortedList of saved information for ALL Parts!</param>
        /// <param name="parentGameObject">The "parentGameObject" GameObject on which bolts should be placed. This should always be the ModAPI part.rigidPart when using modapi!!!</param>
        /// <param name="screwsPositionsLocal">The position where each screw should be placed on the parentGameObject GameObject</param>
        /// <param name="screwsRotationLocal">The rotation the screws should have when placed on parentGameObject GameObject</param>
        /// <param name="screwsSizeForAll">The size for all screws to be used as a single value if it is set to 8 you need to use the wrench size 8 to install the parts</param>
        /// <param name="assets">The assets bundle to use. this will by default load the model as 'bolt_nut.prefab' and the material as 'bolt-texture.mat make sure those are inside your prefab</param>
        public ScrewablePart(SortedList <String, Screws> screwsListSave, GameObject parentGameObject, Vector3[] screwsPositionsLocal, Vector3[] screwsRotationLocal, int screwsSizeForAll, AssetBundle assets)
        {
            this.assets = assets;

            this.selectedItem    = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/SelectItem");
            this.selectedItemFSM = selectedItem.GetComponent <PlayMakerFSM>();
            FsmHook.FsmInject(selectedItem, "Hand", new Action(ChangedToHand));
            FsmHook.FsmInject(selectedItem, "Tools", new Action(ChangedToTools));

            this._wrenchSize      = selectedItemFSM.Fsm.GetFsmFloat("OldWrench");
            this.bolt_material    = assets.LoadAsset <Material>("bolt-texture.mat");
            this.boltModelToUse   = (assets.LoadAsset("bolt_nut.prefab") as GameObject);
            this.parentGameObject = parentGameObject;

            this.screwsDefaultPositionLocal = screwsPositionsLocal;
            this.screwsDefaultRotationLocal = screwsRotationLocal;


            if (screwsListSave != null)
            {
                Screws loadedScrews;
                bool   successWhenLoading = screwsListSave.TryGetValue(parentGameObject.name, out loadedScrews);
                if (successWhenLoading)
                {
                    //Save provided and found in file
                    this.screws = loadedScrews;
                }
                else
                {
                    this.screws = new Screws();
                }
            }

            if (this.screws == null)
            {
                //No Save provided
                this.screws = new Screws();


                //Initialize boltSize
                int[] boltSize = new int[screwsPositionsLocal.Length];
                for (int i = 0; i < boltSize.Length; i++)
                {
                    boltSize[i] = screwsSizeForAll;
                }

                for (int i = 0; i < boltSize.Length; i++)
                {
                    if (boltSize[i] < 5)
                    {
                        boltSize[i] = 5;
                    }
                    else if (boltSize[i] > 15)
                    {
                        boltSize[i] = 15;
                    }
                }

                //Initialize boltTightness
                int[] boltTightness = new int[screwsPositionsLocal.Length];
                for (int i = 0; i < boltTightness.Length; i++)
                {
                    boltTightness[i] = 0;
                }

                this.screws.partName             = parentGameObject.name;
                this.screws.screwsPositionsLocal = screwsPositionsLocal;
                this.screws.screwsRotationLocal  = screwsRotationLocal;
                this.screws.screwsSize           = boltSize;
                this.screws.screwsTightness      = boltTightness;
            }
            MakePartScrewable(this.screws);
        }
예제 #20
0
파일: Teimo.cs 프로젝트: MSCOTeam/MOP
        /// <summary>
        /// Initialize the Store class
        /// </summary>
        public Teimo() : base("STORE")
        {
            // Fix for items bought via envelope
            GetTransform().Find("Boxes").parent = null;

            // Fix for advertisement pile disappearing when taken
            GetTransform().Find("AdvertSpawn").transform.parent = null;

            // We're nulling the parent of the f*****g video poker game,
            // because that's much easier than hooking it...
            Transform videoPoker = GetTransform().Find("LOD/VideoPoker/HookSlot");

            if (videoPoker != null)
            {
                FsmHook.FsmInject(videoPoker.gameObject, "Activate cable", RemoveVideoPokerParent);
            }

            GameObjectBlackList.AddRange(blackList);
            DisableableChilds = GetDisableableChilds();

            // Remove video poker meshes.
            DisableableChilds.Remove(GetTransform().Find("LOD/VideoPoker/Hatch/Pivot/mesh"));

            // Fix for Z-fighting of slot machine glass.
            GetTransform().Find("LOD/GFX_Store/SlotMachine/slot_machine 1/slot_machine_glass")
            .gameObject.GetComponent <Renderer>().material.renderQueue = 3001;

            PlayMakers.AddRange(GetTransform().Find("TeimoInShop").GetComponents <PlayMakerFSM>());
            PlayMakers.AddRange(GetTransform().Find("TeimoInShop").GetComponents <PlayMakerFSM>());

            List <Transform> teimoShit = new List <Transform>();

            teimoShit.Add(GetTransform().Find("TeimoInShop/Pivot/Speak"));
            teimoShit.Add(GetTransform().Find("TeimoInShop/Pivot/FacePissTrigger"));
            teimoShit.Add(GetTransform().Find("TeimoInShop/Pivot/TeimoCollider"));
            teimoShit.Add(GetTransform().Find("GasolineFire"));
            DisableableChilds.AddRange(teimoShit);

            // Disable resetting of the breakable windows.
            Transform storeBreakableWindow = GameObject.Find("STORE").transform.Find("LOD/GFX_Store/BreakableWindows/BreakableWindow");

            if (storeBreakableWindow != null)
            {
                foreach (PlayMakerFSM fsm in storeBreakableWindow.gameObject.GetComponents <PlayMakerFSM>())
                {
                    fsm.Fsm.RestartOnEnable = false;
                }
            }
            Transform storeBreakableWindowPub = GameObject.Find("STORE").transform.Find("LOD/GFX_Pub/BreakableWindowsPub/BreakableWindowPub");

            if (storeBreakableWindowPub != null)
            {
                foreach (PlayMakerFSM fsm in storeBreakableWindowPub.gameObject.GetComponents <PlayMakerFSM>())
                {
                    fsm.Fsm.RestartOnEnable = false;
                }
            }

            // Disables the idiotic distance limit, below which if player is too close to the Teimo's, the restocking won't be executed.
            FloatCompare checkDistance = GetTransform().Find("Inventory").gameObject.GetComponent <PlayMakerFSM>().FindFsmState("Check distance").Actions[1] as FloatCompare;

            checkDistance.float2 = 0;
        }
예제 #21
0
        public ItemHook()
        {
            Toggle = ToggleActive;

            IgnoreRule rule = Rules.instance.IgnoreRules.Find(f => f.ObjectName == this.gameObject.name);

            if (rule != null)
            {
                Toggle = ToggleActiveOldMethod;

                if (rule.TotalIgnore)
                {
                    Destroy(this);
                    return;
                }
            }

            // Use the old method, if for some reason item cannot be disabled.
            if (this.gameObject.name.EqualsAny("fish trap(itemx)", "bucket(itemx)", "pike(itemx)", "envelope(xxxxx)", "lottery ticket(xxxxx)"))
            {
                Toggle = ToggleActiveOldMethod;
            }

            // Add self to the MinorObjects.objectHooks list
            Items.instance.Add(this);

            // Get object's components
            rb = GetComponent <Rigidbody>();
            PlayMakerFSM playMakerFSM = GetComponent <PlayMakerFSM>();

            renderer = GetComponent <Renderer>();

            // From PlayMakerFSM, find states that contain one of the names that relate to destroying object,
            // and inject RemoveSelf void.
            if (playMakerFSM != null)
            {
                foreach (var st in playMakerFSM.FsmStates)
                {
                    switch (st.Name)
                    {
                    case "Destroy self":
                        FsmHook.FsmInject(this.gameObject, "Destroy self", RemoveSelf);
                        break;

                    case "Destroy":
                        FsmHook.FsmInject(this.gameObject, "Destroy", RemoveSelf);
                        break;

                    case "Destroy 2":
                        FsmHook.FsmInject(this.gameObject, "Destroy 2", RemoveSelf);
                        break;
                    }
                }
            }

            // If the item is a shopping bag, hook the RemoveSelf to "Is garbage" FsmState
            if (gameObject.name.Contains("shopping bag"))
            {
                FsmHook.FsmInject(this.gameObject, "Is garbage", RemoveSelf);

                // Destroys empty shopping bags appearing at the back of the yard.
                PlayMakerArrayListProxy list = gameObject.GetComponent <PlayMakerArrayListProxy>();
                if (list.arrayList.Count == 0)
                {
                    Items.instance.Remove(this);
                    Destroy(this.gameObject);
                }
            }

            // If the item is beer case, hook the DestroyBeerBottles void uppon removing a bottle.
            if (gameObject.name.StartsWith("beer case"))
            {
                FsmHook.FsmInject(this.gameObject, "Remove bottle", DestroyBeerBottles);
                FsmHook.FsmInject(this.gameObject, "Remove bottle", HookBottles);
            }

            // If ignore, disable renderer
            if (rule != null)
            {
                renderer = null;
            }

            position = transform.position;

            // Fixes a bug which would prevent player from putting on the helmet, after taking it off.
            if (this.gameObject.name == "helmet(itemx)")
            {
                return;
            }

            if (this.gameObject.name.EqualsAny("floor jack(itemx)", "car jack(itemx)"))
            {
                floorJackTriggerY = gameObject.transform.Find("Trigger").gameObject.GetComponent <PlayMakerFSM>().FsmVariables.GetFsmFloat("Y");
            }

            // We're preventing the execution of State 1 and Load,
            // because these two reset the variables of the item
            // (such as position, state or rotation).
            FsmFixes();

            // HACK: For some reason the trigger that's supposed to fix tire job not working doesn't really work on game load,
            // toggle DontDisable to true, if tire is close to repair shop cash register.
            if (this.gameObject.name.StartsWith("wheel_") && Vector3.Distance(gameObject.transform.position, GameObject.Find("REPAIRSHOP").transform.Find("LOD/Store/ShopCashRegister").position) < 5)
            {
                DontDisable = true;
            }

            if (gameObject.name.Equals("empty plastic can(itemx)"))
            {
                if (Vector3.Distance(position, WorldManager.instance.GetCanTrigger().position) < 2)
                {
                    position = WorldManager.instance.GetLostSpawner().position;
                    return;
                }
            }
        }
예제 #22
0
        /// <summary>
        /// Looks for gamobject named SAVEGAME, and hooks PreSaveGame into them.
        /// </summary>
        void HookPreSaveGame()
        {
            try
            {
                GameObject[] saveGames = Resources.FindObjectsOfTypeAll <GameObject>()
                                         .Where(obj => obj.name.Contains("SAVEGAME")).ToArray();

                int i = 0;
                for (; i < saveGames.Length; i++)
                {
                    bool useInnactiveFix = false;
                    bool isJail          = false;

                    if (!saveGames[i].activeSelf)
                    {
                        useInnactiveFix = true;
                        saveGames[i].SetActive(true);
                    }

                    if (saveGames[i].transform.parent != null && saveGames[i].transform.parent.name == "JAIL" && saveGames[i].transform.parent.gameObject.activeSelf == false)
                    {
                        useInnactiveFix = true;
                        isJail          = true;
                        saveGames[i].transform.parent.gameObject.SetActive(true);
                    }

                    FsmHook.FsmInject(saveGames[i], "Mute audio", PreSaveGame);

                    if (useInnactiveFix)
                    {
                        if (isJail)
                        {
                            saveGames[i].transform.parent.gameObject.SetActive(false);
                            continue;
                        }

                        saveGames[i].SetActive(false);
                    }
                }

                // Hooking up on death save.
                GameObject onDeathSaveObject = new GameObject("MOP_OnDeathSave");
                onDeathSaveObject.transform.parent = GameObject.Find("Systems").transform.Find("Death/GameOverScreen");
                OnDeathBehaviour behaviour = onDeathSaveObject.AddComponent <OnDeathBehaviour>();
                behaviour.Initialize(PreSaveGame);
                i++;

                // Adding custom action to state that will trigger PreSaveGame, if the player picks up the phone with large Suski.
                PlayMakerFSM          useHandleFSM     = GameObject.Find("Telephone").transform.Find("Logic/UseHandle").GetComponent <PlayMakerFSM>();
                FsmState              phoneFlip        = useHandleFSM.GetState("Pick phone");
                List <FsmStateAction> phoneFlipActions = phoneFlip.Actions.ToList();
                phoneFlipActions.Insert(0, new CustomSuskiLargeFlip());
                phoneFlip.Actions = phoneFlipActions.ToArray();
                i++;

                ModConsole.Log($"[MOP] Hooked {i} save points!");
            }
            catch (Exception ex)
            {
                ExceptionManager.New(ex, true, "SAVE_HOOK_ERROR");
            }
        }
예제 #23
0
        /// <summary>
        /// Lists all the game objects in the game's world and that are on the whitelist,
        /// then it adds ObjectHook to them
        /// </summary>
        void InitializeList()
        {
            // Get all minor objects from the game world (like beer cases, sausages)
            // Only items that are in the listOfMinorObjects list, and also contain "(itemx)" in their name will be loaded
            GameObject[] items = Object.FindObjectsOfType <GameObject>()
                                 .Where(gm => gm.name.ContainsAny(BlackList) && gm.name.ContainsAny("(itemx)", "(Clone)") && gm.activeSelf).ToArray();

            for (int i = 0; i < items.Length; i++)
            {
                try
                {
                    items[i].AddComponent <ItemHook>();

                    // Hook the TriggerMinorObjectRefresh to Confirm and Spawn all actions
                    if (items[i].name.Equals("shopping bag(itemx)"))
                    {
                        FsmHook.FsmInject(items[i], "Confirm", cashRegisterHook.TriggerMinorObjectRefresh);
                        FsmHook.FsmInject(items[i], "Spawn all", cashRegisterHook.TriggerMinorObjectRefresh);
                    }
                    else if (items[i].name.EqualsAny("spark plug box(Clone)", "car light bulb box(Clone)"))
                    {
                        FsmHook.FsmInject(items[i], "Create Plug", cashRegisterHook.WipeUseLoadOnSparkPlugs);
                    }
                    else if (items[i].name.EqualsAny("alternator belt(Clone)", "oil filter(Clone)", "battery(Clone)"))
                    {
                        PlayMakerFSM          fanbeltUse   = items[i].GetPlayMakerByName("Use");
                        FsmState              loadFanbelt  = fanbeltUse.FindFsmState("Load");
                        List <FsmStateAction> emptyActions = new List <FsmStateAction> {
                            new CustomNullState()
                        };
                        loadFanbelt.Actions = emptyActions.ToArray();
                        loadFanbelt.SaveActions();
                    }
                }
                catch (System.Exception ex)
                {
                    ExceptionManager.New(ex, "ITEM_LIST_LOAD_ERROR");
                }
            }
            cashRegisterHook.WipeUseLoadOnSparkPlugs();

            // CD Player Enhanced compatibility
            if (ModLoader.IsModPresent("CDPlayer"))
            {
                GameObject[] cdEnchancedObjects = Object.FindObjectsOfType <GameObject>()
                                                  .Where(gm => gm.name.ContainsAny("cd case(itemy)", "CD Rack(itemy)", "cd(itemy)") && gm.activeSelf).ToArray();

                for (int i = 0; i < cdEnchancedObjects.Length; i++)
                {
                    cdEnchancedObjects[i].AddComponent <ItemHook>();
                }

                // Create shop table check, for when the CDs are bought
                GameObject itemCheck = new GameObject("MOP_ItemAreaCheck");
                itemCheck.transform.position = GameObject.Find("SpawnItemStore").transform.position;
                itemCheck.AddComponent <ShopModItemSpawnCheck>();
            }
            else
            {
                GameObject[] cdItems = Resources.FindObjectsOfTypeAll <GameObject>().Where(g => g.name.ContainsAny("cd case(item", "cd(item")).ToArray();
                foreach (GameObject cd in cdItems)
                {
                    cd.AddComponent <ItemHook>();
                }
            }

            // Get items from ITEMS object.
            GameObject itemsObject = GameObject.Find("ITEMS");

            for (int i = 0; i < itemsObject.transform.childCount; i++)
            {
                GameObject item = itemsObject.transform.GetChild(i).gameObject;
                if (item.name == "CDs")
                {
                    continue;
                }

                try
                {
                    if (item.GetComponent <ItemHook>() != null)
                    {
                        continue;
                    }

                    item.AddComponent <ItemHook>();
                }
                catch (System.Exception ex)
                {
                    ExceptionManager.New(ex, "ITEM_LIST_AT_ITEMS_LOAD_ERROR");
                }
            }

            // Also disable the restart for that sunnuva bitch.
            itemsObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;

            // F*****g wheels.
            GameObject[] wheels = Object.FindObjectsOfType <GameObject>().
                                  Where(gm => gm.name.EqualsAny("wheel_regula", "wheel_offset") && gm.activeSelf).ToArray();
            foreach (GameObject wheel in wheels)
            {
                wheel.AddComponent <ItemHook>();
            }

            // Tires trigger at Fleetari's.
            GameObject wheelTrigger = new GameObject("MOP_WheelTrigger");

            wheelTrigger.transform.localPosition    = new Vector3(1555.49f, 4.8f, 737);
            wheelTrigger.transform.localEulerAngles = new Vector3(1.16f, 335, 1.16f);
            wheelTrigger.AddComponent <WheelRepairJobTrigger>();

            // Hook up the envelope.
            GameObject[] envelopes = Resources.FindObjectsOfTypeAll <GameObject>().Where(g => g.name.EqualsAny("envelope(xxxxx)", "lottery ticket(xxxxx)")).ToArray();
            foreach (var g in envelopes)
            {
                g.AddComponent <ItemHook>();
            }

            // Unparent all childs of CDs object.
            Transform cds = GameObject.Find("ITEMS").transform.Find("CDs");

            if (cds != null)
            {
                for (int i = 0; i < cds.childCount; i++)
                {
                    cds.GetChild(i).parent = null;
                }
            }
        }