protected void AddSkill(string commonName, int skillIndex)
        {
            CustomSkillDefinition skill = new CustomSkillDefinition(this, skillIndex, commonName);

            skill.OnFieldChanged += OnSkillChangedPlaceholder;
            Skills.Add(skill);
        }
Beispiel #2
0
        private void LoadConfigs()
        {
            if (_configsLoaded)
            {
                return;
            }
            _configsLoaded      = true;
            UpdateVanillaValues = Config.Bind(
                CommonName,
                CommonName + " UpdateVanillaValues",
                true,
                "Write default values in descriptions of settings. Will flip to false after doing it once.");

            BodyDefinition = new CustomBodyDefinition(this, CommonName);


            var skills = SurvivorDef.bodyPrefab.GetComponents <GenericSkill>();

            foreach (var genericSkill in skills)
            {
                foreach (var variant in genericSkill.skillFamily.variants)
                {
                    if (Skills.ContainsKey(variant.skillDef.skillIndex))
                    {
                        continue;
                    }

                    var skill = new CustomSkillDefinition(this, variant.skillDef.skillIndex,
                                                          Regex.Replace(Language.english.GetLocalizedStringByToken(variant.skillDef.skillNameToken),
                                                                        @"[^A-Za-z]+", string.Empty)
                                                          );
                    Skills.Add(skill.SkillIndex, skill);
                }
            }
        }
Beispiel #3
0
        public void InitBaseConfigValues()
        {
            PrimarySkill   = new CustomSkillDefinition(this, PrimarySkillName);
            SecondarySkill = new CustomSkillDefinition(this, SecondarySkillName);
            UtilitySkill   = new CustomSkillDefinition(this, UtilitySkillName);
            SpecialSkill   = new CustomSkillDefinition(this, SpecialSkillName);
            foreach (string skillName in ExtraSkillNames)
            {
                ExtraSkills.Add(new CustomSkillDefinition(this, skillName));
            }

            BodyDefinition = new CustomBodyDefinition(this, CharacterName);
        }
Beispiel #4
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);
            }
        }
        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);
                }
            }
        }
 private void OnSkillChangedPlaceholder(CustomSkillDefinition skillDef, IFieldChanger changed)
 {
 }