Ejemplo n.º 1
0
 private static void YoinkGlobalSkillDefs()
 {
     Modules.Skills.AddPrimarySkill(bodyPrefab, SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarPrimaryReplacement")));
     Modules.Skills.AddSecondarySkill(bodyPrefab, SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarSecondaryReplacement")));
     Modules.Skills.AddUtilitySkill(bodyPrefab, SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarUtilityReplacement")));
     Modules.Skills.AddSpecialSkill(bodyPrefab, SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarDetonatorSpecialReplacement")));
 }
Ejemplo n.º 2
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));
        }
 public override void OnInstall()
 {
     base.OnInstall();
     this.fireProjIndex      = ProjectileCatalog.FindProjectileIndex("ManipulatorBlinkFire");
     this.lightningProjIndex = ProjectileCatalog.FindProjectileIndex("ManipulatorBlinkLightning");
     this.iceProjIndex       = ProjectileCatalog.FindProjectileIndex("ManipulatorBlinkIce");
     this.requiredSkillDef   = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("Manipulator.Venting Step"));
     GlobalEventManager.onCharacterDeathGlobal += onCharacterDeathGlobal;
     RoR2Application.onFixedUpdate             += FixedUpdate;
 }
Ejemplo n.º 4
0
 // Token: 0x0600139D RID: 5021 RVA: 0x00053C44 File Offset: 0x00051E44
 public GenericSkill FindSkillByFamilyName(string skillFamilyName)
 {
     for (int i = 0; i < this.allSkills.Length; i++)
     {
         if (SkillCatalog.GetSkillFamilyName(this.allSkills[i].skillFamily.catalogIndex) == skillFamilyName)
         {
             return(this.allSkills[i]);
         }
     }
     return(null);
 }
        // Token: 0x06001723 RID: 5923 RVA: 0x00064A78 File Offset: 0x00062C78
        private static void GenerateViewables()
        {
            StringBuilder stringBuilder = new StringBuilder();

            ViewablesCatalog.Node node   = new ViewablesCatalog.Node("Loadout", true, null);
            ViewablesCatalog.Node parent = new ViewablesCatalog.Node("Bodies", true, node);
            for (int i = 0; i < BodyCatalog.bodyCount; i++)
            {
                if (SurvivorCatalog.GetSurvivorIndexFromBodyIndex(i) != SurvivorIndex.None)
                {
                    string                bodyName             = BodyCatalog.GetBodyName(i);
                    GenericSkill[]        bodyPrefabSkillSlots = BodyCatalog.GetBodyPrefabSkillSlots(i);
                    ViewablesCatalog.Node parent2 = new ViewablesCatalog.Node(bodyName, true, parent);
                    for (int j = 0; j < bodyPrefabSkillSlots.Length; j++)
                    {
                        SkillFamily skillFamily = bodyPrefabSkillSlots[j].skillFamily;
                        if (skillFamily.variants.Length > 1)
                        {
                            string skillFamilyName = SkillCatalog.GetSkillFamilyName(skillFamily.catalogIndex);
                            uint   num             = 0U;
                            while ((ulong)num < (ulong)((long)skillFamily.variants.Length))
                            {
                                ref SkillFamily.Variant ptr = ref skillFamily.variants[(int)num];
                                string unlockableName       = ptr.unlockableName;
                                if (!string.IsNullOrEmpty(unlockableName))
                                {
                                    string skillName = SkillCatalog.GetSkillName(ptr.skillDef.skillIndex);
                                    stringBuilder.Append(skillFamilyName).Append(".").Append(skillName);
                                    string name = stringBuilder.ToString();
                                    stringBuilder.Clear();
                                    ViewablesCatalog.Node variantNode = new ViewablesCatalog.Node(name, false, parent2);
                                    ptr.viewableNode = variantNode;
                                    variantNode.shouldShowUnviewed = ((UserProfile userProfile) => !userProfile.HasViewedViewable(variantNode.fullName) && userProfile.HasUnlockable(unlockableName));
                                }
                                num += 1U;
                            }
                        }
                    }
                    SkinDef[] bodySkins = BodyCatalog.GetBodySkins(i);
                    if (bodySkins.Length > 1)
                    {
                        ViewablesCatalog.Node parent3 = new ViewablesCatalog.Node("Skins", true, parent2);
                        for (int k = 0; k < bodySkins.Length; k++)
                        {
                            string unlockableName = bodySkins[k].unlockableName;
                            if (!string.IsNullOrEmpty(unlockableName))
                            {
                                ViewablesCatalog.Node skinNode = new ViewablesCatalog.Node(bodySkins[k].name, false, parent3);
                                skinNode.shouldShowUnviewed = ((UserProfile userProfile) => !userProfile.HasViewedViewable(skinNode.fullName) && userProfile.HasUnlockable(unlockableName));
                            }
                        }
                    }
                }
            }
Ejemplo n.º 6
0
        private void Dump()
        {
            using (var writer = new StreamWriter("dump.txt"))
            {
                writer.WriteLine("Skill indices\nindex, skill name token, skill name (inspector)\n");
                var count = SkillCatalog.allSkillDefs.Count();
                for (var i = 0; i < count; i++)
                {
                    var skill = SkillCatalog.GetSkillDef(i);

                    writer.WriteLine($"{i}, {skill.skillNameToken}, {skill.skillName}");
                }

                writer.Flush();
            }
        }
Ejemplo n.º 7
0
 void Awake()
 {
     //playerBehavior = GameObject.FindGameObjectWithTag("player").GetComponent<PlayerBehavior>();
     craftingSystem   = GetComponent <CraftingSystem>();
     buildingCatalog  = GetComponent <BuildingsCatalog>();
     itemCatalog      = GetComponent <ItemCatalog>();
     inventoryCatalog = GetComponent <InventoryCatalog>();
     citizenCatalog   = GetComponent <CitizenCatalog>();
     townCatalog      = GetComponent <TownCatalog>();
     enemyCatalog     = GetComponent <EnemyCatalog>();
     abilityCatalog   = GetComponent <AbilityCatalog>();
     perkCatalog      = GetComponent <PerkCatalog>();
     skillCatalog     = GetComponent <SkillCatalog>();
     UI             = GetComponent <UI>();
     messageLogText = GameObject.FindGameObjectWithTag("MessageLogBarUI").GetComponentInChildren <MessageLogText>();
     clock          = GetComponent <Clock>();
     world          = GameObject.FindGameObjectWithTag("World").GetComponent <World>();
 }
Ejemplo n.º 8
0
        // Token: 0x0600139B RID: 5019 RVA: 0x00053B9C File Offset: 0x00051D9C
        public override void OnDeserialize(NetworkReader reader, bool initialState)
        {
            this.inDeserialize = true;
            uint num = reader.ReadPackedUInt32();

            for (int i = 0; i < this.allSkills.Length; i++)
            {
                if ((num & 1U << i) != 0U)
                {
                    GenericSkill genericSkill = this.allSkills[i];
                    SkillDef     skillDef     = SkillCatalog.GetSkillDef((int)(reader.ReadPackedUInt32() - 1U));
                    if (initialState || !this.hasEffectiveAuthority)
                    {
                        genericSkill.SetBaseSkill(skillDef);
                    }
                }
            }
            this.inDeserialize = false;
        }
Ejemplo n.º 9
0
        public void OverrideSurvivorBase()
        {
            Logger.LogInfo("Overriding " + CommonName);

            foreach (var customSkillDefinition in Skills.Values)
            {
                var def = SkillCatalog.GetSkillDef(customSkillDefinition.SkillIndex);
                customSkillDefinition.Apply(def);
                Logger.LogInfo("Skill: " + customSkillDefinition.CommonName +
                               " overwritten");
                customSkillDefinition.OnFieldChanged += OnSkillChanged;
            }

            var body = SurvivorDef.bodyPrefab.GetComponent <CharacterBody>();

            BodyDefinition.Apply(body);

            BodyDefinition.OnFieldChanged += OnBodyChanged;
        }
Ejemplo n.º 10
0
        private void OnSkillChanged(CustomSkillDefinition skillDef, IFieldChanger changed)
        {
            var def = SkillCatalog.GetSkillDef(skillDef.SkillIndex);

            changed.Apply(def);
            Logger.LogInfo("Skill '" + skillDef.CommonName + "' of Survivor '" + SurvivorDef.cachedName +
                           "' overwritten");

            foreach (var masterController in PlayerCharacterMasterController.instances)
            {
                var body = masterController.master.GetBody();
                foreach (var genericSkill in body.GetComponents <GenericSkill>())
                {
                    genericSkill.RecalculateValues();
                }

                Logger.LogInfo("Recalculated live skills of " + SurvivorDef.cachedName);
            }
        }
Ejemplo n.º 11
0
        private void SwapS(string slot, string name)
        {
            Init();
            var index   = SkillCatalog.FindSkillIndexByName(name);
            int slotNum = StringToSlot(slot);

            if (slotNum == -1 || slotNum > 3)
            {
                Chat.AddMessage("Invalid slot");
                return;
            }

            if (index < 0 || index > _skillDefCount)
            {
                Chat.AddMessage($"Couldn't find skill: {name}");
                return;
            }

            SetSkill(slotNum, index);
        }
Ejemplo n.º 12
0
        private void SetSkill(int slot, int index)
        {
            var def = SkillCatalog.GetSkillDef(index);

            if (def == null)
            {
                Chat.AddMessage($"Couldn't find a skill at index: {index}");
                return;
            }
            var skillSlot = GetSlot(slot);

            if (_skillReplacements[slot] != null)
            {
                Remove(this, skillSlot, _skillReplacements[slot]);
            }

            Override(this, skillSlot, def);
            _skillReplacementIndices[slot] = index;
            _skillReplacements[slot]       = def;

            Chat.AddMessage($"Swapped skill to \"{def.skillName}\"");
        }
        private void OnSkillChanged(CustomSkillDefinition skillDef, IFieldChanger changed)
        {
            var def = SkillCatalog.GetSkillDef(skillDef.SkillIndex);

            changed.Apply(def);
            Logger.LogInfo("Skill '" + skillDef.CommonName + "' of Survivor '" + SurvivorDef.name +
                           "' overwritten");

            GameObject[] liveBodies = GameObject.FindGameObjectsWithTag("Player");
            foreach (var liveBody in liveBodies)
            {
                if (liveBody.name == SurvivorDef.bodyPrefab.name + "(Clone)")
                {
                    foreach (GenericSkill genericSkill in liveBody.GetComponents <GenericSkill>())
                    {
                        genericSkill.RecalculateValues();
                    }

                    Logger.LogInfo("Recalculated live skills of " + SurvivorDef.name);
                }
            }
        }
        public void OverrideSurvivorBase(SurvivorDef survivor)
        {
            Logger.LogInfo("Overriding " + survivor.name);
            SurvivorDef = survivor;

            GenericSkill[] skills = survivor.bodyPrefab.GetComponents <GenericSkill>();

            foreach (var customSkillDefinition in Skills)
            {
                var def = SkillCatalog.GetSkillDef(customSkillDefinition.SkillIndex);
                customSkillDefinition.AllFields.ForEach(changer => { changer.Apply(def); });
                Logger.LogInfo("Skill: " + customSkillDefinition.CommonName +
                               " overwritten");
                customSkillDefinition.OnFieldChanged -= OnSkillChangedPlaceholder;
                customSkillDefinition.OnFieldChanged += OnSkillChanged;
            }

            CharacterBody body = survivor.bodyPrefab.GetComponent <CharacterBody>();

            BodyDefinition.AllFields.ForEach(changer => { changer.Apply(body); });

            BodyDefinition.OnFieldChanged -= OnBodyChangedPlaceholder;
            BodyDefinition.OnFieldChanged += OnBodyChanged;
        }
Ejemplo n.º 15
0
        private void Start()
        {
            body     = MotionControls.currentBody;
            animator = GetComponent <Animator>();

            if (!body || !animator)
            {
                return;
            }

            if (parameterType == ParameterType.OnExecuteTrigger)
            {
                body.onSkillActivatedAuthority += OnActivatedAuthority;
                body.onSkillActivatedServer    += OnActivatedServer;
            }
            else
            {
                if (forceSkillSlot == SkillSlot.None)
                {
                    associatedSkill = body.skillLocator.FindSkill(skillName);

                    if (!associatedSkill)
                    {
                        associatedSkill = body.skillLocator.allSkills.ToList().FirstOrDefault(x => x.skillDef.skillName == skillName || SkillCatalog.GetSkillName(x.skillDef.skillIndex) == skillName);
                    }
                }
                else
                {
                    associatedSkill = body.skillLocator.GetSkill(forceSkillSlot);
                }

                if (associatedSkill)
                {
                    foundSkill = true;
                    RoR2Application.onLateUpdate += UpdateBool;
                }
            }
        }
Ejemplo n.º 16
0
        private void UpdateBool()
        {
            bool available = associatedSkill != null && (associatedSkill.skillDef.skillName == skillName || associatedSkill.skillName == skillName || SkillCatalog.GetSkillName(associatedSkill.skillDef.skillIndex) == skillName) && associatedSkill.stock > 0;

            if (available != wasAvailable)
            {
                wasAvailable = available;

                animator.SetBool(parameterName, available);
            }
        }