예제 #1
0
        public static void DestroySpawnedInteractables()
        {
            var localUser  = LocalUserManager.GetFirstLocalUser();
            var controller = localUser.cachedMasterController;

            if (!controller)
            {
                return;
            }
            var body = controller.master.GetBody();

            if (!body)
            {
                return;
            }

            if (spawnedObjects != null)
            {
                foreach (var gameObject in spawnedObjects)
                {
                    UnityEngine.Object.Destroy(gameObject);
                    Chat.AddMessage($"<color=yellow>Destroyed {gameObject.name.Replace("(Clone)", "")} </color>");
                }
                spawnedObjects = new List <GameObject>();
            }
        }
예제 #2
0
    public static IEnumerator Setup() {
        ready = false;
        var hudConVar = RoR2.Console.instance.FindConVar("hud_scale");

        if (Config.UI.useHUDScale)
        {
            if (hudConVar != null && TextSerialization.TryParseInvariant(hudConVar.GetString(), out float num))
            {
                hudScale = num / 100f;
            }
        }
        else {
            hudScale = Config.UI.overrideHUDScale;
        }

        while (!ready) {
            yield return new WaitForSeconds(0.1f);
            if (LocalUserManager.GetFirstLocalUser() != null && LocalUserManager.GetFirstLocalUser()?.cameraRigController?.hud != null) {
                screenSize = LocalUserManager.GetFirstLocalUser()?.cameraRigController?.hud.GetComponent<RectTransform>().sizeDelta ?? new Vector2(0,0);
                if (!(screenSize.x <= 1 || screenSize.y <= 1)) {
                    ready = true;
                };
            }
        }
    }
예제 #3
0
        public void Awake()
        {
            SurvivorAPI.SurvivorCatalogReady += delegate(object s, EventArgs e)
            {
                BodyCatalog.FindBodyPrefab("MercBody").GetComponent <SkillLocator>().special.baseRechargeInterval  = 20;
                BodyCatalog.FindBodyPrefab("MercBody").GetComponent <SkillLocator>().special.skillNameToken        = "Shadow Clone";
                BodyCatalog.FindBodyPrefab("MercBody").GetComponent <SkillLocator>().special.skillDescriptionToken = "Summon two exact copies of yourself that <style=cIsUtility>inherit all your items</style> and live for 8 seconds ";
            };

            On.EntityStates.Merc.EvisDash.OnEnter += (orig, self) =>
            {
                self.outer.commonComponents.characterBody.AddTimedBuff(BuffIndex.Cloak, 2.5f);
                if (self.outer.commonComponents.characterBody.isPlayerControlled)
                {
                    var networkClient = NetworkClient.allClients.FirstOrDefault();
                    if (networkClient != null)
                    {
                        networkClient.RegisterHandlerSafe(HandleId, HandleDropItem);
                    }
                    var user = LocalUserManager.GetFirstLocalUser();

                    SendDropItem(user.cachedBody.gameObject, ItemIndex.Syringe);
                }
                else
                {
                    orig(self);
                }
            };
        }
예제 #4
0
        private string Util_GetBestBodyName(On.RoR2.Util.orig_GetBestBodyName orig, GameObject bodyObject)
        {
            var           origName      = orig(bodyObject);
            CharacterBody characterBody = null;

            if (bodyObject)
            {
                characterBody = bodyObject.GetComponent <CharacterBody>();
            }

            if (characterBody && characterBody.inventory && characterBody.inventory.currentEquipmentIndex != EquipmentIndex.None)
            {
                var firstLocalUser = LocalUserManager.GetFirstLocalUser();
                if (characterBody.teamComponent &&
                    firstLocalUser != null &&
                    firstLocalUser.cachedMaster &&
                    characterBody.teamComponent.teamIndex == LocalUserManager.GetFirstLocalUser().cachedMaster.teamIndex)
                {
                    if ((characterBody.master && characterBody.master.masterIndex == EquipmentDroneMasterIndex && cfgNameEquipmentMode.Value == NameEquipmentMode.EquipmentDrones) ||
                        cfgNameEquipmentMode.Value == NameEquipmentMode.Any)
                    {
                        origName += $" ({Language.GetString(EquipmentCatalog.GetEquipmentDef(characterBody.inventory.currentEquipmentIndex).nameToken)})";
                    }
                    //35 char limit ish before truncation
                }
            }
            return(origName);
        }
예제 #5
0
 private void RuleCategoryController_SetData(On.RoR2.UI.RuleCategoryController.orig_SetData orig, RoR2.UI.RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
 {
     if (categoryDef.displayToken == "RULE_HEADER_DIFFICULTY" && EDrule != null)
     {
         try
         {
             var localUser1 = LocalUserManager.GetFirstLocalUser();
             if (localUser1 != null)
             {
                 bool knowsED = AchievementManager.GetUserAchievementManager(localUser1).userProfile.HasAchievement("COMPLETE_MAINENDING_DILUVIAN");
                 if (knowsED)
                 {
                     Syzygy.Unlocked();
                 }
                 else
                 {
                     Syzygy.Locked();
                 }
                 EDrule.spritePath = assetString + Syzygy.def.IconPath;
                 ReloadLanguage();
             }
         }
         catch (Exception e)
         {
             Logger.LogWarning(e);
         }
     }
     orig(self, categoryDef, availability, ruleBook);
 }
예제 #6
0
        public static void GiveItem(ItemIndex itemIndex)
        {
            var localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
            {
                if (Items.isDropItemForAll)
                {
                    Items.DropItemMethod(itemIndex);
                }
                else if (Items.isDropItemFromInventory)
                {
                    if (Items.CurrentInventory().Contains(itemIndex))
                    {
                        UmbraMenu.LocalPlayerInv.RemoveItem(itemIndex, 1);
                        Items.DropItemMethod(itemIndex);
                    }
                    else
                    {
                        Chat.AddMessage($"<color=yellow> You do not have that item and therefore cannot drop it from your inventory.</color>");
                        Chat.AddMessage($" ");
                    }
                }
                else
                {
                    UmbraMenu.LocalPlayerInv.GiveItem(itemIndex, 1);
                }
            }
        }
예제 #7
0
        private static void CCSplitscreenModNoKeyboard(ConCommandArgs args)
        {
            int num = 2;
            int value;

            if (args.Count >= 1 && TextSerialization.TryParseInvariant(args[0], out value))
            {
                num = Mathf.Clamp(value, 1, 4);
            }
            if (!NetworkClient.active)
            {
                UserProfile mainProfile = LocalUserManager.GetFirstLocalUser().userProfile;
                LocalUserManager.ClearUsers();
                LocalUserManager.LocalUserInitializationInfo[] array = new LocalUserManager.LocalUserInitializationInfo[num];
                array[0].player  = ReInput.players.GetPlayer(2);
                array[0].profile = mainProfile;
                if (array[0].profile == null)
                {
                    array[0].profile = UserProfile.CreateGuestProfile();
                    print("SplitscreenMod: Profile could not be loaded. Using guest profile.");
                }
                for (int i = 1; i < num; i++)
                {
                    array[i] = new LocalUserManager.LocalUserInitializationInfo
                    {
                        player  = ReInput.players.GetPlayer(2 + i),
                        profile = UserProfile.CreateGuestProfile()
                    };
                }
                LocalUserManager.SetLocalUsers(array);
            }
        }
예제 #8
0
파일: RPGMod.cs 프로젝트: ben2882/RPGMod
        public void DisplayQuesting() // Handles the creation of UI elements
        {
            LocalUser localUser = LocalUserManager.GetFirstLocalUser();

            // Updates the local character body
            if (CachedCharacterBody == null && localUser != null)
            {
                CachedCharacterBody = localUser.cachedBody;
            }

            // Adds a new UI instance
            if (CachedCharacterBody != null)
            {
                for (int i = 0; i < Questing.ClientMessage.Instances.Count; i++)
                {
                    if (i >= Questing.UI.Instances.Count)
                    {
                        if (Core.debugMode)
                        {
                            Debug.Log(CachedCharacterBody);
                            Debug.Log(Screen.width * Questing.Config.xPositionUI);
                            Debug.Log(Screen.height * Questing.Config.yPositionUI);
                            Debug.Log(Questing.ClientMessage.Instances[i].description);
                        }

                        AddUIInstance(i);
                    }
                }
            }
        }
예제 #9
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);
            }
        }
예제 #10
0
파일: UI.cs 프로젝트: ben2882/RPGMod
            private void Update()
            {
                if (!validLocalUser)
                {
                    LocalUser localUser = LocalUserManager.GetFirstLocalUser();
                    if (localUser.cameraRigController.hud.objectivePanelController != null)
                    {
                        parent = localUser.cameraRigController.hud.GetComponent <Canvas>().transform;
                        questUI.transform.SetParent(parent);
                        validLocalUser = true;
                        questUI.transform.localScale = new Vector3(hudScale, hudScale, hudScale);
                    }
                }

                if (!animFinished)
                {
                    UpdateProgressAnim();
                }

                if (questUI == null)
                {
                    Destroy(this);
                    return;
                }

                float num = (Time.time - startTime) / 0.8f;

                if (num < 1)
                {
                    questRect.transform.localPosition = new Vector3(Mathf.SmoothStep(Screen.width * 1.3f, (Screen.width * Questing.Config.xPositionUI), num), (Screen.height * Questing.Config.yPositionUI) - (questRect.sizeDelta.y * index * hudScale), parent.position.z * 1.35f);
                }
            }
예제 #11
0
        private static void ChangeHUDAnchors(object sender, EventArgs e)
        {
            AnchorMin = new Vector2((1 - Mathf.Clamp(LeftAnchor.Value, 0, 1)) / 2, (1 - Mathf.Clamp(BottomAnchor.Value, 0, 1)) / 2);
            AnchorMax = new Vector2((1 + Mathf.Clamp(RightAnchor.Value, 0, 1)) / 2, (1 + Mathf.Clamp(TopAnchor.Value, 0, 1)) / 2);

            if (Run.instance)
            {
                CameraRigController localCameraRig = LocalUserManager.GetFirstLocalUser().cameraRigController;

                if (localCameraRig && localCameraRig.hud)
                {
                    RoR2.UI.HUD hud = localCameraRig.hud;

                    RectTransform springCanvas = hud.mainUIPanel.transform.Find("SpringCanvas") as RectTransform;
                    springCanvas.anchorMin = ModConfig.AnchorMin;
                    springCanvas.anchorMax = ModConfig.AnchorMax;

                    RectTransform notificationArea = hud.mainContainer.transform.Find("NotificationArea") as RectTransform;
                    notificationArea.anchorMin = new Vector2(0.5f, ModConfig.AnchorMin.y);
                    notificationArea.anchorMax = new Vector2(0.5f, ModConfig.AnchorMin.y);

                    RectTransform mapNameCluster = hud.mainContainer.transform.Find("MapNameCluster") as RectTransform;
                    mapNameCluster.anchorMin = new Vector2(0.5f, (ModConfig.AnchorMax.y - 0.5f) * 0.54f + 0.5f);
                    mapNameCluster.anchorMax = new Vector2(0.5f, (ModConfig.AnchorMax.y - 0.5f) * 0.54f + 0.5f);
                }
            }
        }
예제 #12
0
            public void OnReceived()
            {
                GameObject   clientGameObject = LocalUserManager.GetFirstLocalUser().cachedBodyObject;
                GameObject   gameObject       = Util.FindNetworkObject(this.targetId);
                ModelLocator modelLocator     = gameObject.GetComponent <ModelLocator>();
                ChildLocator childLocator     = modelLocator.modelTransform.GetComponent <ChildLocator>();

                ParticleSystem.EmissionModule particleSystemEmission = childLocator.FindChild("OverpowerParticles").GetComponent <ParticleSystem>().emission;

                if (!gameObject)
                {
                    UrsaPlugin.logger.LogMessage("Error syncing Ursa's glowing hands effect: target id game object was not found!");
                    return;
                }
                if (clientGameObject == gameObject)
                {
                    return;
                }

                if (glow)
                {
                    childLocator.FindChild("R_Hand").GetComponent <Light>().enabled = true;
                    childLocator.FindChild("L_Hand").GetComponent <Light>().enabled = true;
                    particleSystemEmission.enabled = true;
                }
                else
                {
                    childLocator.FindChild("R_Hand").GetComponent <Light>().enabled = false;
                    childLocator.FindChild("L_Hand").GetComponent <Light>().enabled = false;
                    particleSystemEmission.enabled = false;
                }
            }
예제 #13
0
        private void GiveEquipment(EquipmentIndex equipIndex)
        {
            var localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
            {
                if (Items.isDropItemForAll)
                {
                    Items.DropEquipmentMethod(equipIndex);
                }
                else if (Items.isDropItemFromInventory)
                {
                    if (UmbraMenu.LocalPlayerInv.currentEquipmentIndex == equipIndex)
                    {
                        UmbraMenu.LocalPlayerInv.SetEquipmentIndex(EquipmentIndex.None);
                        Items.DropEquipmentMethod(equipIndex);
                    }
                    else
                    {
                        Chat.AddMessage($"<color=yellow> You do not have that equipment and therefore cannot drop it.</color>");
                        Chat.AddMessage($" ");
                    }
                }
                else
                {
                    UmbraMenu.LocalPlayerInv.SetEquipmentIndex(equipIndex);
                }
            }
        }
예제 #14
0
        public static List <HurtBox> GetHurtBoxes()
        {
            var localUser  = LocalUserManager.GetFirstLocalUser();
            var controller = localUser.cachedMasterController;

            if (!controller)
            {
                return(null);
            }
            var body = controller.master.GetBody();

            if (!body)
            {
                return(null);
            }
            var inputBank      = body.GetComponent <InputBankTest>();
            var aimRay         = new Ray(inputBank.aimOrigin, inputBank.aimDirection);
            var bullseyeSearch = new BullseyeSearch();
            var team           = body.GetComponent <TeamComponent>();

            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.filterByLoS       = false;
            bullseyeSearch.maxDistanceFilter = 125;
            bullseyeSearch.maxAngleFilter    = 40f;
            bullseyeSearch.teamMaskFilter    = TeamMask.all;
            bullseyeSearch.teamMaskFilter.RemoveTeam(team.teamIndex);
            bullseyeSearch.RefreshCandidates();
            var hurtBoxList = bullseyeSearch.GetResults().ToList();

            return(hurtBoxList);
        }
예제 #15
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;
        }
예제 #16
0
        public static void ChangeCharacter(GUIStyle buttonStyle, GUIStyle Highlighted, string buttonName)
        {
            int buttonPlacement = 1;

            foreach (var prefab in Main.bodyPrefabs)
            {
                if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), prefab.name.Replace("Body", ""), Navigation.HighlighedCheck(buttonStyle, Highlighted, 1.1f, buttonPlacement)))
                {
                    GameObject newBody = BodyCatalog.FindBodyPrefab(prefab.name);
                    if (newBody == null)
                    {
                        return;
                    }
                    var localUser = LocalUserManager.GetFirstLocalUser();
                    if (localUser == null || localUser.cachedMasterController == null || localUser.cachedMasterController.master == null)
                    {
                        return;
                    }
                    var master = localUser.cachedMasterController.master;

                    master.bodyPrefab = newBody;
                    master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
                    Utility.SoftResetMenu();
                }
                buttonPlacement++;
            }
        }
예제 #17
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;
        }
예제 #18
0
            public void CreateTemporaryNetworkUsers()
            {
                if (!debug)
                {
                    return;
                }
                GameObject    meUser          = LocalUserManager.GetFirstLocalUser().currentNetworkUser.gameObject;
                List <string> bodyNamesToCopy = new List <string>(DD2LobbySetupComponent.debug_characters);

                bodyNamesToCopy.RemoveAt(0);
                foreach (string bodyName in bodyNamesToCopy)
                {
                    if (InstanceTracker.GetInstancesList <FakeNetworkUserMarker>().Count == 3)
                    {
                        break;
                    }
                    var copy = Instantiate(meUser);
                    var nU   = copy.GetComponent <NetworkUser>();
                    nU.SetBodyPreference(BodyCatalog.FindBodyIndex(bodyName));
                    nU.id = new NetworkUserId()
                    {
                        value = GetNetworkName(bodyName)
                    };
                    copy.name = bodyName;
                    copy.AddComponent <FakeNetworkUserMarker>();
                    Debug.Log($"Adding fake NetworkUser as {bodyName}");
                }
            }
예제 #19
0
    public bool IsAuthorized(string securityContext)
    {
        IAuthorizationProvider ruleProvider = AuthorizationFactory.GetAuthorizationProvider("MyAuthorizationProvider");
        //bool ret = ruleProvider.Authorize(LocalUserManager.GetThreadPrinciple(), securityContext);
        bool ret = ruleProvider.Authorize(LocalUserManager.GetCurrentPrinciple(), securityContext);

        return(ret);
    }
예제 #20
0
        private static void DisableOnClientSceneChange(UnityEngine.Networking.NetworkManager instance, string newSceneName, bool forceReload)
        {
            if (IsActivated)
            {
                Console.instance.SubmitCmd(LocalUserManager.GetFirstLocalUser().currentNetworkUser, "noclip");
            }

            origClientChangeScene(instance, newSceneName, forceReload);
        }
예제 #21
0
        private static void DisableOnServerSceneChange(UnityEngine.Networking.NetworkManager instance, string newSceneName)
        {
            if (IsActivated)
            {
                Console.instance.SubmitCmd(LocalUserManager.GetFirstLocalUser().currentNetworkUser, "noclip");
            }

            origServerChangeScene(instance, newSceneName);
        }
예제 #22
0
        private void ApplyBuff(BuffIndex buffIndex)
        {
            var localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
            {
                UmbraMenu.LocalPlayerBody.AddBuff(buffIndex);
            }
        }
예제 #23
0
 // Token: 0x060020EA RID: 8426 RVA: 0x0009A924 File Offset: 0x00098B24
 private void SetEventSystem(MPEventSystem newEventSystem)
 {
     if (newEventSystem == this.eventSystem)
     {
         return;
     }
     this.eventSystem = newEventSystem;
     this.localUser   = LocalUserManager.FindLocalUser(newEventSystem.player);
 }
예제 #24
0
        public void Update()
        {
            LocalUser localUser = LocalUserManager.GetFirstLocalUser();

            if (localUser != null && localUser.cachedBody != null && ui == null)
            {
                ui = localUser.cachedBody.gameObject.AddComponent <RecountContainer>();
            }
        }
예제 #25
0
 public static void CCunlockPrismAchievements(ConCommandArgs _)
 {
     if (LocalUserManager.isAnyUserSignedIn)
     {
         var scythe = UnlockableCatalog.GetUnlockableDef("Items.HealOnCrit");
         var merc   = UnlockableCatalog.GetUnlockableDef("Skills.Merc.EvisProjectile");
         LocalUserManager.GetFirstLocalUser().currentNetworkUser.CallCmdReportUnlock(scythe.index);
         LocalUserManager.GetFirstLocalUser().currentNetworkUser.CallCmdReportUnlock(merc.index);
     }
 }
예제 #26
0
        private void FindStateMachine()
        {
            CharacterBody body = LocalUserManager.GetFirstLocalUser().cachedBody;

            if (body)
            {
                stateMachines             = body.GetComponents <EntityStateMachine>().ToList();
                foundStateMachine         = true;
                RoR2Application.onUpdate -= FindStateMachine;
            }
        }
예제 #27
0
        private void HUD_Start(On.RoR2.UI.HUD.orig_Start orig, HUD self)
        {
            orig.Invoke(self);

            PlayerScript playerScript = LocalUserManager.GetFirstLocalUser().cachedMasterController.GetComponent <PlayerScript>();

            if (playerScript)
            {
                playerScript.AddKillCounter();
            }
        }
예제 #28
0
        public static void DropItemMethod(ItemIndex itemIndex)
        {
            var user          = LocalUserManager.GetFirstLocalUser();
            var networkClient = NetworkClient.allClients.FirstOrDefault();

            if (networkClient != null)
            {
                networkClient.RegisterHandlerSafe(HandleItemId, HandleDropItem);
            }
            SendDropItem(user.cachedBody.gameObject, itemIndex);
        }
예제 #29
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);
            }
        }
예제 #30
0
 // Token: 0x06002639 RID: 9785 RVA: 0x000A60F8 File Offset: 0x000A42F8
 private void SetMainProfile(UserProfile profile)
 {
     LocalUserManager.SetLocalUsers(new LocalUserManager.LocalUserInitializationInfo[]
     {
         new LocalUserManager.LocalUserInitializationInfo
         {
             profile = profile
         }
     });
     this.myMainMenuController.desiredMenuScreen = this.myMainMenuController.titleMenuScreen;
 }