Ejemplo n.º 1
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, RoR2.Run self)
        {
            orig.Invoke(self);

            //Wait till all players loaded
            //Dont know if there is a better option for this
            if (RoR2.Run.instance.time < 5)
            {
                return;
            }

            //Compare this user with the host user
            bool isHost = LocalUserManager.GetFirstLocalUser().cachedMasterController == PlayerCharacterMasterController.instances[0];

            //If Not host unhook the update function and quit this function
            if (!isHost)
            {
                On.RoR2.Run.Update -= Run_Update;
                return;
            }

            //If Host send a Reset, so everything is setup correctly
            ExampleCommandClientCustom.Invoke(x =>
            {
                x.Write("Reset");
                //Send this to every client so its host dependend
                x.Write(config.Everything_Avaiable);
            });

            //Hook host specific stuff
            On.EntityStates.Barrel.Opening.OnEnter         += Opening_OnEnter;
            On.RoR2.PurchaseInteraction.OnInteractionBegin += PurchaseInteraction_OnInteractionBegin;
            //Unhook the Update function
            On.RoR2.Run.Update -= Run_Update;
        }
Ejemplo n.º 2
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            if (Input.GetKeyDown(KeyCode.F5))
            {
                Debug.Log("Spawn DIO");
                LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                Transform transform = localUser.cachedBodyObject.transform;

                PickupIndex dio = new PickupIndex(ItemIndex.ExtraLife);
                PickupDropletController.CreatePickupDroplet(dio, transform.position, Vector3.up * 5f);
            }

            if (Input.GetKeyDown(KeyCode.F6))
            {
                Debug.Log("Spawn Random");
                LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                Transform transform = localUser.cachedBodyObject.transform;

                List <PickupIndex> tier3Items = Run.instance.availableTier3DropList;
                int rng = random.Next(0, tier3Items.Count);

                ItemIndex rngItem = tier3Items[rng].itemIndex;

                PickupIndex dio = new PickupIndex(rngItem);
                PickupDropletController.CreatePickupDroplet(dio, transform.position, Vector3.up * 5f);
            }
        }
Ejemplo n.º 3
0
        public void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            orig.Invoke(self);

            //Check if player is moving in any Axis
            float vert = inputPlayer.GetAxis("MoveVertical");
            float horz = inputPlayer.GetAxis("MoveHorizontal");

            //Rework so it works better with controller
            float move = vert != 0 ? .5f : horz != 0 ? .5f : 0;

            float sprint = move == 0 ? 0f : characterBody.isSprinting ? .4f : 0;

            //Check if player is litteraly pressing moving button (Jumping, Skills)
            float skill = inputPlayer.GetButton("PrimarySkill") ? .75f :
                          inputPlayer.GetButton("SecondarySkill") ? .75f :
                          inputPlayer.GetButton("UtilitySkill") ? .75f :
                          inputPlayer.GetButton("SpecialSkill") ? .75f :
                          inputPlayer.GetButton("Jump") ? .75f :
                          inputPlayer.GetButton("Equipment") ? .75f : 0;

            float onGround = characterMotor.isGrounded ? 0f : .25f;

            //Calculate Time
            //Gotta rework this sheit
            float time = onGround + skill + move + sprint;

            if (time > 1f)
            {
                time = 1f;
            }

            ExampleCommandHostCustom.Invoke(x => { x.Write("Time"); x.Write((double)time); });
        }
Ejemplo n.º 4
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            orig.Invoke(self);

            //Wait till all players loaded
            //Dont know if there is a better option for this
            if (Run.instance.time < 5)
            {
                return;
            }

            bool isHost = LocalUserManager.GetFirstLocalUser().cachedMasterController == PlayerCharacterMasterController.instances[0];

            if (!isHost)
            {
                On.RoR2.Run.Update -= Run_Update;
                return;
            }

            ExampleCommandClientCustom.Invoke(x =>
            {
                x.Write("Reset");
            });

            On.RoR2.Run.Update -= Run_Update;
        }
Ejemplo n.º 5
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            var Models = PlayerCharacterMasterController.instances[0]?.master?.GetBody()?.modelLocator?.modelTransform?.gameObject.GetComponentsInChildren <Renderer>(true);

            if (Models != null)
            {
                if (FirstPerson.Value && Invisible.Value)
                {
                    foreach (var CharacterModel in Models)
                    {
                        if (CharacterModel.gameObject.activeSelf)
                        {
                            CharacterModel.gameObject.SetActive(false);
                        }
                    }
                }
                else
                {
                    foreach (var CharacterModel in Models)
                    {
                        if (!CharacterModel.gameObject.activeSelf)
                        {
                            CharacterModel.gameObject.SetActive(true);
                        }
                    }
                }
            }
            orig(self);
        }
Ejemplo n.º 6
0
        private static void SetBodyInvisible(On.RoR2.Run.orig_Update orig, Run self)
        {
            CharacterBody cachedBody = Utils.localBody;

            if (cachedBody)
            {
                Renderer[] renderers = cachedBody.modelLocator?.modelTransform?.gameObject.GetComponentsInChildren <Renderer>();

                if (forcedVisibleRenderers != null)
                {
                    string currentBodyName = cachedBody.name.Substring(0, cachedBody.name.IndexOf("(Clone)"));

                    ForcedVisibleRenderer[] visibleBodyRenderers = forcedVisibleRenderers.Where(x => x.bodyName == currentBodyName).ToArray();

                    renderers = renderers.Where(x => !Array.Exists(visibleBodyRenderers, vren => vren.rendererObjectName == x.gameObject.name)).ToArray();
                }

                if (renderers != null)
                {
                    foreach (Renderer renderer in renderers)
                    {
                        if (renderer.gameObject.activeSelf)
                        {
                            renderer.gameObject.SetActive(false);
                        }
                    }
                }
            }

            orig(self);
        }
Ejemplo n.º 7
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            if (Input.GetKeyDown(KeyCode.F5))
            {
                LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                Transform transform = localUser.cachedBodyObject.transform;

                PickupIndex dio = new PickupIndex(ItemIndex.Bear);
                PickupDropletController.CreatePickupDroplet(dio, transform.position, Vector3.up * 5f);
            }
        }
Ejemplo n.º 8
0
        private void Run_Update(On.RoR2.Run.orig_Update orig, Run self)
        {
            orig.Invoke(self);

            //Debug.Log(PlayerCharacterMasterController.instances.Count != FindObjectsOfType<CA_Manager>().Length);
            //Debug.Log(string.Format("Player count: {0}; Manager Count: {1}", PlayerCharacterMasterController.instances.Count, FindObjectsOfType<CA_Manager>().Length));


            if (!Run.instance || Run.instance.time < 1 || !RoR2Application.isInSinglePlayer)
            {
                return;
            }

            LocalUser localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser == null || localUser.cachedBody == null)
            {
                return;
            }

            characterBody = localUser.cachedBody;

            //Check if every player has an CA_Manager and check master
            if (masterNotification == null)
            {
                PlayerCharacterMasterController player = PlayerCharacterMasterController.instances[0];
                if (player.gameObject.GetComponent <CA_Manager>() == null)
                {
                    CA_Manager manager = player.gameObject.AddComponent <CA_Manager>();
                    manager.config = this.config;
                    manager.random = this.random;
                }

                if (player.gameObject.GetComponent <Notification>() == null)
                {
                    Notification notification;
                    masterNotification = notification = player.gameObject.AddComponent <Notification>();

                    notification.SetItemsIconSize(config.NotiIconSize);
                    notification.SetItemsInLine(config.NotiItemsInLine);
                    notification.transform.SetParent(player.gameObject.transform);
                    notification.SetPosition(new Vector3((float)(Screen.width * 50) / 100f, (float)(Screen.height * 50) / 100f, 0f));
                    notification.SetSize(new Vector2(config.NotiSizeX, config.NotiSizeY));

                    notification.GetTitle = (() => string.Format("Item Selector. Press {0} to continue", config.SelectButton.ToString()));

                    notification.GenericNotification.fadeTime = 1f;
                    notification.GenericNotification.duration = 10000f;
                    player.gameObject.GetComponent <CA_Manager>().HideSelectMenu();
                }
            }

            //If player was destroyed, remove all leftovers
            if (characterBody == null && masterNotification != null)
            {
                CA_Manager[] allManagers = FindObjectsOfType <CA_Manager>();

                for (int i = 0; i < allManagers.Length; i++)
                {
                    Destroy(allManagers[i]);
                }

                Notification[] allSelectors = FindObjectsOfType <Notification>();

                for (int i = 0; i < allSelectors.Length; i++)
                {
                    Destroy(allSelectors[i]);
                }

                //Destroy(masterNotification);
                masterNotification = null;
            }
        }