Exemple #1
0
        public void RandomizeCharacter()
        {
            if ((!PreGameController.instance || !PreGameController.instance.IsCharacterSwitchingCurrentlyAllowed() || !characterSelectController) && !eclipseRunScreenController)
            {
                return;
            }

            var localUser              = ((MPEventSystem)EventSystem.current).localUser;
            var currentIndex           = characterSelectController?.selectedSurvivorIndex ?? (SurvivorIndex)EclipseRun.cvEclipseSurvivorIndex.value;
            var canSelectSameCharacter = ConfigHelper.CanSelectSameCharacter.Value;
            var survivors              = SurvivorCatalog.orderedSurvivorDefs.Where(survivorDef => (canSelectSameCharacter || currentIndex != survivorDef.survivorIndex) && !survivorDef.hidden && SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorDef.survivorIndex));
            var randomIndex            = survivors.ElementAt(UnityEngine.Random.Range(0, survivors.Count())).survivorIndex;

            if (characterSelectController)
            {
                characterSelectController.SelectSurvivor(randomIndex);
                characterSelectController.SetSurvivorInfoPanelActive(true);
            }
            if (eclipseRunScreenController)
            {
                eclipseRunScreenController.SelectSurvivor(randomIndex);
            }
            if (RandomCharacterSelectionPlugin.ScrollableLobbyUILoaded)
            {
                ScrollableLobbyUISelectCharacter(randomIndex);
            }
            localUser.currentNetworkUser?.CallCmdSetBodyPreference(BodyCatalog.FindBodyIndex(SurvivorCatalog.GetSurvivorDef(randomIndex).bodyPrefab));
        }
Exemple #2
0
        // Token: 0x06003156 RID: 12630 RVA: 0x000D45DC File Offset: 0x000D27DC
        public virtual void OnImpactServer(Vector3 contactPoint)
        {
            string text = BodyCatalog.GetBodyName(base.characterBody.bodyIndex);

            text = text.Replace("Body", "");
            text = "iscBroken" + text;
            SpawnCard spawnCard = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/" + text);

            if (spawnCard != null)
            {
                DirectorPlacementRule placementRule = new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Direct,
                    position      = contactPoint
                };
                GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, placementRule, new Xoroshiro128Plus(0UL)));
                if (gameObject)
                {
                    PurchaseInteraction component = gameObject.GetComponent <PurchaseInteraction>();
                    if (component && component.costType == CostTypeIndex.Money)
                    {
                        component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost);
                    }
                }
            }
        }
Exemple #3
0
            // Token: 0x060023A6 RID: 9126 RVA: 0x0009B8F8 File Offset: 0x00099AF8
            private Row(LoadoutPanelController owner, int bodyIndex, string titleToken)
            {
                this.owner                          = owner;
                this.userProfile                    = owner.currentDisplayData.userProfile;
                this.rowPanelTransform              = (RectTransform)UnityEngine.Object.Instantiate <GameObject>(LoadoutPanelController.rowPrefab, owner.rowContainer).transform;
                this.buttonContainerTransform       = (RectTransform)this.rowPanelTransform.Find("ButtonContainer");
                this.choiceHighlightRect            = (RectTransform)this.rowPanelTransform.Find("ChoiceHighlightRect");
                UserProfile.onLoadoutChangedGlobal += this.OnLoadoutChangedGlobal;
                SurvivorDef survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(BodyCatalog.GetBodyPrefab(bodyIndex));

                if (survivorDef != null)
                {
                    this.primaryColor = survivorDef.primaryColor;
                }
                float num;
                float s;
                float v;

                Color.RGBToHSV(this.primaryColor, out num, out s, out v);
                num += 0.5f;
                if (num > 1f)
                {
                    num -= 1f;
                }
                this.complementaryColor = Color.HSVToRGB(num, s, v);
                RectTransform rectTransform = (RectTransform)this.rowPanelTransform.Find("SlotLabel");

                rectTransform.GetComponent <LanguageTextMeshController>().token = titleToken;
                rectTransform.GetComponent <HGTextMeshProUGUI>().color          = this.primaryColor;
                this.choiceHighlightRect.GetComponent <Image>().color           = this.complementaryColor;
            }
Exemple #4
0
        public static SurvivorIndex GetCurrentCharacter()
        {
            var bodyIndex     = BodyCatalog.FindBodyIndex(Main.LocalPlayerBody);
            var survivorIndex = SurvivorCatalog.GetSurvivorIndexFromBodyIndex(bodyIndex);

            return(survivorIndex);
        }
Exemple #5
0
    public void OnStart()
    {
        SurvivorModInfo survivorModInfo = new SurvivorModInfo {
            bodyPrefabString       = "BanditBody",
            descriptionTokenString = "BANDIT_DESCRIPTION",
            portraitPrefabString   = "Prefabs/Characters/BanditDisplay",
            usedColor                      = new Color(0.8039216f, 0.482352942f, 0.843137264f),
            toReplace                      = 3,
            unlockableNameString           = "",
            primarySkillNameToken          = "Blast",
            primarySkillDescriptionToken   = "Fire a powerful slug for <style=cIsDamage>150% damage</style>.",
            secondarySkillNameToken        = "Lights Out",
            secondarySkillDescriptionToken = "Take aim for a headshot, dealing <style=cIsDamage>600% damage</style>. If the ability <style=cIsDamage>kills an enemy</style>, the Bandit's <style=cIsUtility>Cooldowns are all reset to 0</style>.",
            utilitySkillNameToken          = "Smokebomb",
            utilitySkillDescriptionToken   = "Turn invisible for <style=cIsDamage>3 seconds</style>, gaining <style=cIsUtility>increased movement speed</style>.",
            specialSkillNameToken          = "Thermite Toss",
            specialSkillDescriptionToken   = "Fire off a burning Thermite grenade, dealing <style=cIsDamage>damage over time</style>.",
        };
        var org_secondary = BodyCatalog.FindBodyPrefab(survivorModInfo.bodyPrefabString).GetComponents <GenericSkill>()[1];

        survivorModInfo.Primary = org_secondary;
        survivorModInfo.Primary.baseMaxStock = 6;
        var mult_secondary = BodyCatalog.FindBodyPrefab("ToolbotBody").GetComponents <GenericSkill>()[1];

        survivorModInfo.Secondary = mult_secondary;
        survivorModInfo.Secondary.activationState = mult_secondary.activationState;
        ModLoader.SurvivorMods.Add(survivorModInfo);
    }
Exemple #6
0
        private void RebuildLocal_Il(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            var label = default(ILLabel);

            c.GotoNext(MoveType.Before,
                       x => x.MatchStloc(7),
                       x => x.MatchLdloc(2),
                       x => x.MatchLdcI4(-1),
                       x => x.MatchBeq(out label)
                       );

            c.GotoLabel(label);
            c.Emit(OpCodes.Ldloc_2);
            c.Emit(OpCodes.Ldarg_0);

            c.EmitDelegate <Action <Int32, CharacterSelectController> >((bodyIndex, controller) =>
            {
                if (bodyIndex == BodyCatalog.FindBodyIndex(this.RW_body))
                {
                    ApplyMenuEdits(bodyIndex, controller);
                }
                else
                {
                    RemoveMenuEdits(controller);
                }
            });
        }
        private void CharacterMaster_TransformBody(On.RoR2.CharacterMaster.orig_TransformBody orig, RoR2.CharacterMaster self, string bodyName)
        {
            var baseAI = self.GetComponent <BaseAI>();

            if (baseAI)
            {
                //Chat.AddMessage($"baseAI found");
                var masterPrefab = MasterCatalog.FindMasterPrefab(bodyName);
                if (masterPrefab)
                {
                    //Chat.AddMessage($"1");
                    ReplaceSkillDrivers(self, baseAI, masterPrefab);
                }
                if (!masterPrefab)
                {
                    var bodyPrefab = BodyCatalog.FindBodyPrefab(bodyName);
                    if (bodyPrefab)
                    {
                        var masterIndex = MasterCatalog.FindAiMasterIndexForBody(bodyPrefab.GetComponent <CharacterBody>().bodyIndex);
                        masterPrefab = MasterCatalog.GetMasterPrefab(masterIndex);
                        if (masterPrefab)
                        {
                            //Chat.AddMessage($"2");
                            ReplaceSkillDrivers(self, baseAI, masterPrefab);
                        }
                    }
                }
            }
            orig(self, bodyName);
        }
Exemple #8
0
        //The Awake() method is run at the very start when the game is initialized.
        public void Awake()
        {
            //Here we are subscribing to the SurvivorCatalogReady event, which is run when the subscriber catalog can be modified.
            //We insert Bandit as a new character here, which is then automatically added to the internal game catalog and reconstructed.
            R2API.SurvivorAPI.SurvivorCatalogReady += (s, e) =>
            {
                var survivor = new SurvivorDef
                {
                    bodyPrefab       = BodyCatalog.FindBodyPrefab("BanditBody"),
                    descriptionToken = "BANDIT_DESCRIPTION",
                    displayPrefab    = Resources.Load <GameObject>("Prefabs/Characters/BanditDisplay"),
                    primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                    unlockableName   = ""
                };

                var skill = survivor.bodyPrefab.GetComponent <SkillLocator>();

                skill.primary.skillNameToken        = "Blast";
                skill.primary.skillDescriptionToken = "Fire a powerful slug for <style=cIsDamage>150% damage</style>.";

                skill.secondary.skillNameToken        = "Lights Out";
                skill.secondary.skillDescriptionToken = "Take aim for a headshot, dealing <style=cIsDamage> 600 % damage </style>.If the ability <style=cIsDamage> kills an enemy </style>, the Bandit's <style=cIsUtility>Cooldowns are all reset to 0</style>.";

                skill.utility.skillNameToken        = "Smokebomb";
                skill.utility.skillDescriptionToken = "Turn invisible for <style=cIsDamage>3 seconds</style>, gaining <style=cIsUtility>increased movement speed</style>.";

                skill.special.skillNameToken        = "Thermite Toss";
                skill.special.skillDescriptionToken = "Fire off a burning Thermite grenade, dealing <style=cIsDamage>damage over time</style>.";

                R2API.SurvivorAPI.SurvivorDefinitions.Insert(3, survivor);
            };
        }
Exemple #9
0
        public void LoadPlayer()
        {
            var player = ProperSave.GetPlayerFromUsername(username);

            if (player == null)
            {
                Debug.Log("Could not find player: " + username);
                return;
            }

            foreach (var minion in minions)
            {
                minion.LoadMinion(player.master);
            }

            var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName);

            player.master.bodyPrefab = bodyPrefab;

            player.master.loadout.Clear();
            player.master.loadout.FromXml(XElement.Parse(loadoutXML));

            inventory.LoadInventory(player.master);

            player.master.money = (uint)money;

            ProperSave.Instance.StartCoroutine(WaitForStart(player));
        }
        public static void AssemblySetup()
        {
            var PodTypes  = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(PodBase)));
            int podAmount = 0;

            foreach (var podType in PodTypes)
            {
                PodBase podBase = (PodBase)Activator.CreateInstance(podType);
                if (ValidatePod(instance.Config, podBase))
                {
                    podBase.Init(instance.Config);
                    _logger.LogMessage("Added pod for " + podBase.BodyName);
                    podAmount++;
                }
            }
            _logger.LogMessage($"Amount of pod types added: " + podAmount);

            var survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(BodyCatalog.FindBodyPrefab("EnforcerBody"));

            if (survivorDef)
            {
                _logger.LogMessage("Enforcer is loaded, setting him up.");
                //Enfucker.Init(survivorDef);
                return;
            }
        }
        private void Awake()
        {
            Instance = this;

            logbookBodyOptions = MapBodiesToOptions(
                SurvivorCatalog.orderedSurvivorDefs.Select(survivorDef => BodyCatalog.GetBodyPrefabBodyComponent(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorDef.survivorIndex)))
                .Union(BodyCatalog.allBodyPrefabBodyBodyComponents.Where(characterBody => characterBody && characterBody.GetComponent <DeathRewards>()?.logUnlockableDef)));

            allBodyOptions = MapBodiesToOptions(BodyCatalog.allBodyPrefabBodyBodyComponents);

            dropdown.Options = logbookBodyOptions;

            (dropdown.OnItemSelected ?? (dropdown.OnItemSelected = new SearchableDropdown.DropdownEvent())).AddListener(SelectModel);

            List <SearchableDropdown.OptionData> MapBodiesToOptions(IEnumerable <CharacterBody> bodies)
            {
                return(bodies
                       .Select(characterBody => (characterBody, characterModel: characterBody.GetComponentInChildren <CharacterModel>()))
                       .Where(el => el.characterModel)
                       .Select(el =>
                {
                    var modelInfo = new ModelPrefabInfo
                    {
                        modelPrefab = el.characterModel.gameObject,
                        bodyName = el.characterBody.name,
                        modelName = el.characterModel.name,
                        localizedBodyName = Language.GetString(el.characterBody.baseNameToken),
                        characterBody = el.characterBody
                    };
                    return new SearchableDropdown.OptionData(modelInfo, $"{modelInfo.localizedBodyName} || {modelInfo.bodyName} || {modelInfo.modelName}");
                })
                       .ToList());
            }
        }
Exemple #12
0
        private bool OnCharCommand(string userName, string[] pieces)
        {
            if (pieces.Length >= 2)
            {
                int prefabIndex = -1;
                if (!Int32.TryParse(pieces[1], out prefabIndex))
                {
                    prefabIndex = BodyCatalog.FindBodyIndexCaseInsensitive(pieces[1]);
                }
                if (prefabIndex != -1)
                {
                    GameObject prefab = BodyCatalog.GetBodyPrefab(prefabIndex);

                    if (prefab != null)
                    {
                        if (FrogtownShared.ChangePrefab(userName, prefab))
                        {
                            FrogtownShared.SendChat(userName + " morphed into " + prefab.name);
                        }
                        else
                        {
                            FrogtownShared.SendChat(userName + " couldn't morph into " + prefab.name);
                        }
                    }
                    else
                    {
                        FrogtownShared.SendChat("Prefab not found");
                    }
                }
            }

            return(true);
        }
Exemple #13
0
        void SetCharacter(int num)
        {
            CharacterBody body = BodyCatalog.GetBodyPrefabBodyComponent(BodyCatalog.FindBodyIndex(CharacterDropdown.options[num].text));

            Settings.PlayableCharactersList[Slot] = body.name;
            CharacterIcon.sprite = Sprite.Create((Texture2D)body.portraitIcon, new Rect(0.0f, 0.0f, body.portraitIcon.width, body.portraitIcon.height), new Vector2(0.5f, 0.5f), 100.0f);
        }
        public override void OnEnter()
        {
            base.OnEnter();
            if (base.isAuthority)
            {
                //this.targetTracker = base.GetComponent<TargetTracker>();
                this.ownerPrefab = base.gameObject;
                CharacterBody   targetBody      = this.targetPrefab.GetComponent <CharacterBody>();
                CharacterBody   ownerBody       = this.ownerPrefab.GetComponent <CharacterBody>();
                GameObject      bodyPrefab      = BodyCatalog.FindBodyPrefab(targetBody);
                CharacterMaster characterMaster = MasterCatalog.allAiMasters.FirstOrDefault((CharacterMaster master) => master.bodyPrefab == bodyPrefab);
                this.masterSummon         = new MasterSummon();
                masterSummon.masterPrefab = characterMaster.gameObject;
                masterSummon.position     = ownerBody.footPosition;
                CharacterDirection component = ownerBody.GetComponent <CharacterDirection>();
                masterSummon.rotation           = (component ? Quaternion.Euler(0f, component.yaw, 0f) : ownerBody.transform.rotation);
                masterSummon.summonerBodyObject = (ownerBody ? ownerBody.gameObject : null);

                CharacterMaster characterMaster2 = masterSummon.Perform();

                GameObject       trackingTargetAsGO = this.targetTracker.GetTrackingTargetAsGO();
                RoR2.Console.Log log = new RoR2.Console.Log();
                if (trackingTargetAsGO != null)
                {
                    log.message = "REEE";
                    RoR2.Console.logs.Add(log);
                }
                else
                {
                    log.message = "YEET";
                    RoR2.Console.logs.Add(log);
                }
            }
        }
 private void UpdateGurrenPassive()
 {
     checkGurrenPassiveStopWatch += Time.fixedDeltaTime;
     if (checkGurrenPassiveStopWatch > checkGurrenPassiveInterval)
     {
         checkGurrenPassiveStopWatch = 0f;
         if (this.body)
         {
             int buffCounts      = 0;
             var gurrenBodyIndex = BodyCatalog.FindBodyIndex("GurrenBody");
             var allies          = TeamComponent.GetTeamMembers(TeamIndex.Player);
             foreach (var ally in allies)
             {
                 var allyBody = ally.body;
                 if (allyBody && allyBody != this.body &&
                     allyBody.bodyIndex == gurrenBodyIndex &&
                     (Vector3.Distance(allyBody.transform.position, this.body.transform.position) <= Components.GurrenController.passiveDistance))
                 {
                     buffCounts++;
                 }
             }
             this.body.SetBuffCount(Buffs.kaminaBuff.buffIndex, buffCounts);
         }
     }
 }
Exemple #16
0
        public static void ConvertBodyNamesToBodyIndices()
        {
            foreach (var entry in characterNames_to_teamName)
            {
                List <BodyIndex> bodyIndices = new List <BodyIndex>();
                foreach (var bodyName in entry.Key)
                {
                    bodyIndices.Add(BodyCatalog.FindBodyIndex(bodyName));
                }
                bodyIndices_to_teamName.Add(bodyIndices.ToArray(), entry.Value);
            }

            var index = 0;

            foreach (var a in bodyIndices_to_teamName)
            {
                var text = $"{index} : ";
                foreach (var b in a.Key)
                {
                    text += $"{b}, ";
                }
                text += $"{a.Value}";
                Debug.Log(text);
            }
            Debug.Log($"Team Count: {bodyIndices_to_teamName.Count}");
        }
Exemple #17
0
 // Token: 0x06002892 RID: 10386 RVA: 0x000AC8FC File Offset: 0x000AAAFC
 public override void OnInstall()
 {
     base.OnInstall();
     this.clayBossBodyIndex = BodyCatalog.FindBodyIndex("ClayBossBody");
     this.requiredSceneDef  = SceneCatalog.GetSceneDefFromSceneName("goolake");
     GlobalEventManager.onCharacterDeathGlobal += this.OnCharacterDeathGlobal;
 }
Exemple #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}");
                }
            }
Exemple #19
0
        private void ChangeOrSetCharacter(NetworkUser player, GameObject bodyPrefab, bool firstTimeJoining)
        {
            var master  = player.master;
            var oldBody = master.GetBody();

            master.bodyPrefab = bodyPrefab;
            _fallenFriends?.Instance?.InvokeMethod("setOldPrefab", master);

            CharacterBody body;

            if (firstTimeJoining)
            {
                var spawnTransform = Stage.instance.GetPlayerSpawnTransform();
                body = master.SpawnBody(bodyPrefab, spawnTransform.position + _spawnOffset, spawnTransform.rotation);
                Run.instance.HandlePlayerFirstEntryAnimation(body, spawnTransform.position + _spawnOffset, spawnTransform.rotation);
            }
            else
            {
                if (BodyCatalog.GetBodyName(oldBody.bodyIndex) == "CaptainBody")
                {
                    master.inventory.RemoveItem(ItemIndex.CaptainDefenseMatrix, 1);
                }

                if (bodyPrefab.name == "CaptainBody")
                {
                    master.inventory.GiveItem(ItemIndex.CaptainDefenseMatrix, 1);
                }
                body = master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
            }

            AddChatMessage($"{player.userName} is spawning as {body.GetDisplayName()}!");
        }
Exemple #20
0
        private static void SetRandomSkin(CharacterMaster master, GameObject bodyPrefab)
        {
            int bodyIndex = bodyPrefab.GetComponent <CharacterBody>().bodyIndex;

            SkinDef[] skins = BodyCatalog.GetBodySkins(bodyIndex);
            master.loadout.bodyLoadoutManager.SetSkinIndex(bodyIndex, (uint)UnityEngine.Random.Range(0, skins.Length));
        }
Exemple #21
0
 private static void SceneDirector_PopulateScene(On.RoR2.SceneDirector.orig_PopulateScene orig, SceneDirector self)
 {
     if (gurrenInteractSpawnCard && Run.instance.userMasters.Values.Any((x) =>
     {
         if (x != null && x.bodyPrefab != null)
         {
             var body = x.bodyPrefab.GetComponent <CharacterBody>();
             if (body)
             {
                 var found = body.bodyIndex == BodyCatalog.FindBodyIndex("LagannBody");
                 if (found)
                 {
                     var gurrenMinionCache = GurrenMinionCache.GetOrSetGurrenStatusCache(x);
                     if (!gurrenMinionCache.gurrenMinion)
                     {
                         return(true);
                     }
                 }
             }
         }
         return(false);
     }))
     {
         TTGL_SurvivorPlugin.instance.Logger.LogMessage("Added Gurren On Level");
         DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(gurrenInteractSpawnCard, new DirectorPlacementRule
         {
             placementMode = DirectorPlacementRule.PlacementMode.Random
         }, self.rng));
     }
     orig(self);
 }
Exemple #22
0
        private new void Start()
        {
            defaultMasterIndex = MasterCatalog.FindAiMasterIndexForBody(BodyCatalog.FindBodyIndex("CommandoBody"));

            base.Start();
            this.isEnabled = base.run.selectedDifficulty >= DifficultyIndex.Eclipse3 /* is EclipseRun && EclipseRun.cvEclipseLevel.value >= 3*/;
        }
Exemple #23
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++;
            }
        }
Exemple #24
0
        private static System.Xml.Linq.XElement BodyLoadout_ToXml(On.RoR2.Loadout.BodyLoadoutManager.BodyLoadout.orig_ToXml orig, System.Object self, String elementName)
        {
            var bodyIndex          = self.GetFieldValue <int>("bodyIndex");
            var bodySkinController = BodyCatalog.GetBodyPrefab(bodyIndex).GetComponent <ModelLocator>().modelTransform.GetComponent <ModelSkinController>();
            var skinPreference     = self.GetFieldValue <uint>("skinPreference");

            if (addedSkins.Contains(bodySkinController.skins[skinPreference]))
            {
                self.SetFieldValue <uint>("skinPreference", 0u);
            }
            var skillPreferences    = self.GetFieldValue <uint[]>("skillPreferences");
            var allBodyInfosObj     = typeof(Loadout.BodyLoadoutManager).GetFieldValue <object>("allBodyInfos");
            var allBodyInfos        = ((Array)allBodyInfosObj).Cast <object>().ToArray();
            var currentInfo         = allBodyInfos[bodyIndex];
            var prefabSkillSlotsObj = currentInfo.GetFieldValue <object>("prefabSkillSlots");
            var prefabSkillSlots    = ((Array)prefabSkillSlotsObj).Cast <object>().ToArray();
            var skillFamilyIndices  = currentInfo.GetFieldValue <int[]>("skillFamilyIndices");

            for (int i = 0; i < prefabSkillSlots.Length; i++)
            {
                var         skillFamilyIndex = skillFamilyIndices[i];
                SkillFamily family           = SkillCatalog.GetSkillFamily(skillFamilyIndex);
                SkillDef    def = family.variants[skillPreferences[i]].skillDef;
                if (addedSkills.Contains(def))
                {
                    skillPreferences[i] = 0u;
                }
            }
            return(orig(self, elementName));
        }
Exemple #25
0
        /// <summary>
        /// Attempts to look up a name in the BodyCatalog, then find the SkillFamily instance used for one of its slots (by slot enum type). Returns null on failure.
        /// </summary>
        /// <param name="bodyName">The body name to search for. Case sensitive.</param>
        /// <param name="slot">The skillslot name to search for.</param>
        /// <returns>The resultant SkillFamily if lookup was successful, null otherwise.</returns>
        public static SkillFamily FindSkillFamilyFromBody(string bodyName, SkillSlot slot)
        {
            var targetBodyIndex = BodyCatalog.FindBodyIndex(bodyName);

            if (targetBodyIndex == BodyIndex.None)
            {
                AncientScepterMain._logger.LogError($"FindSkillFamilyFromBody: Couldn't find body with name {bodyName}");
                return(null);
            }
            var allSlots = BodyCatalog.GetBodyPrefabSkillSlots(targetBodyIndex);
            var skLoc    = BodyCatalog.GetBodyPrefab(targetBodyIndex).GetComponentInChildren <SkillLocator>();

            if (!skLoc)
            {
                AncientScepterMain._logger.LogError($"FindSkillFamilyFromBody: Body with name {bodyName} has no SkillLocator");
                return(null);
            }
            foreach (var skillInstance in BodyCatalog.GetBodyPrefabSkillSlots(targetBodyIndex))
            {
                var targetSlot = skLoc.FindSkillSlot(skillInstance);
                if (targetSlot == slot)
                {
                    return(skillInstance.skillFamily);
                }
            }
            AncientScepterMain._logger.LogError($"FindSkillFamilyFromBody: Body with name {bodyName} has no skill in slot {slot}");
            return(null);
        }
        public void Awake()
        {
            R2API.SurvivorAPI.SurvivorCatalogReady += (s, e) =>
            {
                var survivor = new SurvivorDef
                {
                    bodyPrefab       = BodyCatalog.FindBodyPrefab("BanditBody"),
                    descriptionToken = "BANDIT_DESCRIPTION",
                    displayPrefab    = Resources.Load <GameObject>("Prefabs/Characters/BanditDisplay"),
                    primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                    unlockableName   = ""
                };

                /*
                 * var newsurvivor = new SurvivorDef
                 * {
                 *  bodyPrefab = BodyCatalog.FindBodyPrefab("BanditBody"),
                 *  descriptionToken = "NEW_SURVIVOR_DESCRIPTION",
                 *  displayPrefab = Resources.Load<GameObject>("Prefabs/Characters/BanditDisplay"),
                 *  primaryColor = new Color(0.1f, 0.4f, 0.8f),
                 *  unlockableName = "",
                 *
                 * };
                 * R2API.SurvivorAPI.SurvivorDefinitions.Insert(7, newsurvivor);*/

                R2API.SurvivorAPI.SurvivorDefinitions.Insert(3, survivor);
            };
        }
Exemple #27
0
 public void Awake()
 {
     #region survivor
     SurvivorAPI.SurvivorCatalogReady += delegate(object s, EventArgs e)
     {
         {
             var         bandit = BodyCatalog.FindBodyPrefab("BanditBody");
             SurvivorDef item   = new SurvivorDef
             {
                 bodyPrefab       = bandit,
                 descriptionToken = "test",
                 displayPrefab    = Resources.Load <GameObject>("prefabs/characterbodies/banditbody").GetComponent <ModelLocator>().modelTransform.gameObject,
                 primaryColor     = new Color(0.87890625f, 0.662745098f, 0.3725490196f),
                 unlockableName   = "",
                 survivorIndex    = SurvivorIndex.Count
             };
             #region skills
             #if skills
             Primary.SetPrimary(bandit);
             PrepSecondary.SetSecondary(bandit);
             Banditspecial(bandit);
             EntityStates.Bandit.Utility.SetUtility(bandit);
             #endif
             #endregion skills
             SkillManagement.banditskilldescriptions(bandit);
             SurvivorAPI.AddSurvivor(item);
         }
     };
     #endregion
     #region timer
     #if timer
     Timer.Init();
     #endif
     #endregion
 }
Exemple #28
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);
                }
            };
        }
Exemple #29
0
        public static void SetupDictionary()
        {
            _logger.LogMessage("Setting up!");

            //Delimiter credit: https://github.com/KomradeSpectre/AetheriumMod/blob/c6fe6e8a30c3faf5087802ad7e5d88020748a766/Aetherium/Items/AccursedPotion.cs#L349
            TeamIndex teamIndex = TeamIndex.None;

            foreach (var value in new string[] { cfgNone.Value, cfgNeutral.Value, cfgPlayer.Value, cfgMonster.Value, cfgLunar.Value })
            {
                _logger.LogMessage($"Adding bodies to TeamIndex: {teamIndex}");
                var valueArray = value.Split(',');
                if (valueArray.Length > 0)
                {
                    foreach (string valueToTest in valueArray)
                    {
                        var bodyIndex = BodyCatalog.FindBodyIndex(valueToTest);
                        if (bodyIndex == BodyIndex.None)
                        {
                            continue;
                        }
                        bodyIndex_to_teamIndex.Add(bodyIndex, teamIndex);
                        _logger.LogMessage(valueToTest);
                    }
                }
                teamIndex++;
            }

            //bodyIndex_to_teamIndex.Add(BodyCatalog.FindBodyIndex("ImpBody"), TeamIndex.Lunar);
            //bodyIndex_to_teamIndex.Add(BodyCatalog.FindBodyIndex("ImpBossBody"), TeamIndex.Lunar);
        }
Exemple #30
0
        private static void CCSpawnBody(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Log.MessageNetworked(Lang.SPAWNBODY_ARGS, args, LogLevel.MessageClientOnly);
                return;
            }
            if (args.sender == null)
            {
                Log.Message(Lang.DS_NOTYETIMPLEMENTED, LogLevel.Error);
                return;
            }

            string character = StringFinder.Instance.GetBodyName(args[0]);

            if (character == null)
            {
                Log.MessageNetworked(string.Format(Lang.SPAWN_ERROR, args[0]), args, LogLevel.MessageClientOnly);
                return;
            }

            GameObject body       = BodyCatalog.FindBodyPrefab(character);
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(body, args.sender.master.GetBody().transform.position, Quaternion.identity);

            NetworkServer.Spawn(gameObject);
            Log.MessageNetworked(string.Format(Lang.SPAWN_ATTEMPT_1, character), args);
        }