Exemplo n.º 1
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;
            }
        // Token: 0x060023FB RID: 9211 RVA: 0x000A8FCC File Offset: 0x000A71CC
        private void Rebuild()
        {
            SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.survivorIndex);

            if (survivorDef != null)
            {
                GameObject bodyPrefab = survivorDef.bodyPrefab;
                if (bodyPrefab)
                {
                    CharacterBody component = bodyPrefab.GetComponent <CharacterBody>();
                    if (component)
                    {
                        if (this.survivorIcon)
                        {
                            this.survivorIcon.texture = component.portraitIcon;
                        }
                        string viewableName = string.Format(CultureInfo.InvariantCulture, "/Survivors/{0}", this.survivorIndex.ToString());
                        if (this.viewableTag)
                        {
                            this.viewableTag.viewableName = viewableName;
                            this.viewableTag.Refresh();
                        }
                        if (this.viewableTrigger)
                        {
                            this.viewableTrigger.viewableName = viewableName;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public CustomSurvivor(SurvivorDef survivorDef, ConfigFile configFile, ManualLogSource logger)
        {
            Config = configFile;
            Logger = logger;

            SurvivorDef = survivorDef;

            CommonName = Regex.Replace(Language.english.GetLocalizedStringByToken(survivorDef.displayNameToken),
                                       @"[^A-Za-z]+", string.Empty);

            Enabled = Config.Bind(
                CommonName,
                CommonName + " Enabled",
                false,
                "If changes for this character are enabled. Set to true to generate options on next startup!");

            Enabled.SettingChanged += (sender, args) =>
            {
                if (!Enabled.Value)
                {
                    return;
                }
                LoadConfigs();
                OverrideSurvivorBase();
            };

            if (!Enabled.Value)
            {
                return;
            }

            LoadConfigs();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a SurvivorDef to your Mod's ContentPack
        /// <para>Requires the bodyPrefab to be assigned</para>
        /// <para>BodyPrefab requires a CharacterBody component</para>
        /// <para>Throws a warning if no displayPrefab is assigned</para>
        /// </summary>
        /// <param name="survivorDef">The SurvivorDef to Add</param>
        /// <returns>true if valid and added, false if one of the requirements is not met</returns>
        public static bool AddSurvivorDef(SurvivorDef survivorDef)
        {
            var asm = Assembly.GetCallingAssembly();

            if (CatalogBlockers.GetAvailability <SurvivorDef>())
            {
                if (!survivorDef.bodyPrefab)
                {
                    RejectContent(survivorDef, asm, "SurvivorDef", $"but it's bodyPrefab is not assigned!");
                    return(false);
                }
                if (!survivorDef.bodyPrefab.GetComponent <CharacterBody>())
                {
                    RejectContent(survivorDef, asm, "SurvivorDef", $"but it's bodyPrefab does not have a {nameof(CharacterBody)} component!");
                    return(false);
                }
                if (!survivorDef.displayPrefab)
                {
                    R2API.Logger.LogWarning($"Assembly {asm.GetName().Name} is adding an {survivorDef} that does not have a displayPrefab! is this intentional?");
                }
                R2APIContentManager.HandleContentAddition(asm, survivorDef);
                return(true);
            }
            RejectContent(survivorDef, asm, "SurvivorDef", "but the SurvivorCatalog has already initialized!");
            return(false);
        }
Exemplo n.º 5
0
        public static void RegisterSurvivors()
        {
            SurvivorDef survivorDef = ScriptableObject.CreateInstance <SurvivorDef>();

            survivorDef.displayNameToken    = "ROCKETEER_NAME";
            survivorDef.unlockableDef       = null;
            survivorDef.descriptionToken    = "ROCKETEER_DESCRIPTION";
            survivorDef.primaryColor        = characterColor;
            survivorDef.bodyPrefab          = characterPrefab;
            survivorDef.displayPrefab       = characterDisplay;
            survivorDef.outroFlavorToken    = "MINER_OUTRO_FLAVOR";
            survivorDef.hidden              = false;
            survivorDef.desiredSortPosition = 17f;

            bodyPrefabs.Add(characterPrefab);
            survivorDefs.Add(survivorDef);

            // now that the body prefab's set up, clone it here to make the display prefab
            characterDisplay = PrefabAPI.InstantiateClone(characterPrefab.GetComponent <ModelLocator>().modelBaseTransform.gameObject, "RocketeerDisplay", true, "C:\\Users\\Tinde\\Desktop\\Lurgypai\\ROR2\\mods\\Projects\\files\\ExampleSurvivor\\ExampleSurvivor\\ExampleSurvivor\\ExampleSurvivor\\Rocketeer.cs", "RegisterCharacter", 153);
            characterDisplay.AddComponent <NetworkIdentity>();

            // write a clean survivor description here!
            string desc = "Rocketeer.<color=#CCD3E0>" + Environment.NewLine + Environment.NewLine;

            desc = desc + "< ! > After jetting, the Rocketeer can activate a final secondary jet to negate fall damage." + Environment.NewLine + Environment.NewLine;
            desc = desc + "< ! > Remember that the Rocketeer's Big Booma Cannon does additional damage for each stored rocket." + Environment.NewLine + Environment.NewLine;
            desc = desc + "< ! > The Rocketeer spawns with a Shiny Jetpack." + Environment.NewLine + Environment.NewLine;

            // add the language tokens
            LanguageAPI.Add("ROCKETEER_NAME", "Rocketeer");
            LanguageAPI.Add("ROCKETEER_DESCRIPTION", desc);
            LanguageAPI.Add("ROCKETEER_SUBTITLE", "Flight of the boomble-bee.");
        }
Exemplo n.º 6
0
        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);
            };
        }
Exemplo n.º 7
0
        public static SurvivorDef Add(SurvivorTemplate survivorTemplate, String contentPackIdentifier = null)
        {
            contentPackIdentifier = contentPackIdentifier ?? Assembly.GetCallingAssembly().GetName().Name;
            if (!ContentPacks.assemblyDict.ContainsKey(contentPackIdentifier))
            {
                ContentPacks.assemblyDict[contentPackIdentifier] = Assembly.GetCallingAssembly();
            }
            SurvivorDef survivorDef = ScriptableObject.CreateInstance <SurvivorDef>();

            survivorDef.cachedName          = survivorTemplate.internalName;
            survivorDef.hidden              = survivorTemplate.hidden;
            survivorDef.desiredSortPosition = survivorTemplate.desiredSortPosition;
            survivorDef.unlockableDef       = survivorTemplate.unlockableDef;
            survivorDef.bodyPrefab          = survivorTemplate.bodyPrefab;
            survivorDef.displayPrefab       = survivorTemplate.displayPrefab;
            survivorDef.primaryColor        = survivorTemplate.primaryColor;


            survivorDef.displayNameToken = $"CHARACTER_{survivorTemplate.internalName.ToUpper()}_NAME";
            survivorDef.descriptionToken = $"CHARACTER_{survivorTemplate.internalName.ToUpper()}_DESC";
            survivorDef.mainEndingEscapeFailureFlavorToken = $"CHARACTER_{survivorTemplate.internalName.ToUpper()}_FAILUREFLAVOR";
            survivorDef.outroFlavorToken = $"CHARACTER_{survivorTemplate.internalName.ToUpper()}_OUTROFLAVOR";

            Languages.AddTokenString(survivorDef.displayNameToken, survivorTemplate.name);
            Languages.AddTokenString(survivorDef.descriptionToken, survivorTemplate.descriptionText);
            Languages.AddTokenString(survivorDef.mainEndingEscapeFailureFlavorToken, survivorTemplate.mainEndingEscapeFailureFlavor);
            Languages.AddTokenString(survivorDef.outroFlavorToken, survivorTemplate.outroFlavor);

            return(Add(survivorDef, contentPackIdentifier));
        }
Exemplo n.º 8
0
        internal static void RegisterSurvivor()
        {
            if (!SurvivorsCore.loaded)
            {
                Log.Fatal("Cannot add survivor");
                return;
            }
            var survivorDef = new SurvivorDef
            {
                bodyPrefab          = SniperMain.sniperBodyPrefab,
                descriptionToken    = Properties.Tokens.SNIPER_DESC,
                displayPrefab       = SniperMain.sniperDisplayPrefab,
                cachedName          = "Sniper",
                primaryColor        = new Color(0f, 0.3f, 0.1f, 1f),
                unlockableName      = "",
                outroFlavorToken    = Properties.Tokens.SNIPER_OUTRO_FLAVOR,
                displayNameToken    = Properties.Tokens.SNIPER_DISPLAY_NAME,
                desiredSortPosition = 11,
                unlockableDef       = null,
                hidden = false,
            };

            SurvivorsCore.AddSurvivor(survivorDef);
            SurvivorsCore.ManageEclipseUnlocks(survivorDef, ConfigModule._eclipseLevel);
            //SurvivorCatalog.getAdditionalSurvivorDefs += (list) => list.Add(survivorDef);
        }
Exemplo n.º 9
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
 }
Exemplo n.º 10
0
        public void Awake()
        {
            string pluginfolder = System.IO.Path.GetDirectoryName(GetType().Assembly.Location);

            //asset bundle to load
            string assetBundle = "talox";

            //prefab location inside asset bundle
            string prefab = "assets/prefabs/taloxbody.prefab";

            //load assetbundle then load the prefab
            _TaloxBody = AssetBundle.LoadFromFile($"{pluginfolder}/{assetBundle}").LoadAsset <GameObject>(prefab);

            R2API.SurvivorAPI.SurvivorCatalogReady += (s, e) =>
            {
                var survivor = new SurvivorDef
                {
                    bodyPrefab       = BodyCatalog.FindBodyPrefab("AssassinBody"),
                    descriptionToken = "TALOX_DESCRIPTION",
                    displayPrefab    = _TaloxBody,
                    primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                    unlockableName   = ""
                };

                R2API.SurvivorAPI.SurvivorDefinitions.Add(survivor);
            };
        }
        public void InitContent(SurvivorDef survivorDef)
        {
            SurvivorDef = survivorDef;

            CommonName = Regex.Replace(Language.english.GetLocalizedStringByToken(survivorDef.displayNameToken),
                                       @"[^A-Za-z]+", string.Empty);

            Enabled = Config.Bind(
                CommonName,
                CommonName + " Enabled",
                false,
                "If changes for this character are enabled. Set to true to generate options on next startup!");

            if (!Enabled.Value)
            {
                return;
            }

            UpdateVanillaValues = Config.Bind(
                CommonName,
                CommonName + " UpdateVanillaValues",
                true,
                "Write default values in descriptions of settings. Will flip to false after doing it once.");

            InitConfigValues();

            OverrideGameValues();
            WriteNewHooks();
        }
Exemplo n.º 12
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);
            };
        }
Exemplo n.º 13
0
        // Token: 0x060020EC RID: 8428 RVA: 0x0009A958 File Offset: 0x00098B58
        private void RebuildLocal()
        {
            SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.selectedSurvivorIndex);

            this.survivorName.text = survivorDef.displayNameToken;
            if (survivorDef.descriptionToken != null)
            {
                this.survivorDescription.text = Language.GetString(survivorDef.descriptionToken);
            }
            SkillLocator component = survivorDef.bodyPrefab.GetComponent <SkillLocator>();

            if (component)
            {
                this.RebuildStrip(this.primarySkillStrip, component.primary);
                this.RebuildStrip(this.secondarySkillStrip, component.secondary);
                this.RebuildStrip(this.utilitySkillStrip, component.utility);
                this.RebuildStrip(this.specialSkillStrip, component.special);
                this.RebuildStrip(this.passiveSkillStrip, component.passiveSkill);
            }
            Image[] array = this.primaryColorImages;
            for (int i = 0; i < array.Length; i++)
            {
                array[i].color = survivorDef.primaryColor;
            }
            TextMeshProUGUI[] array2 = this.primaryColorTexts;
            for (int i = 0; i < array2.Length; i++)
            {
                array2[i].color = survivorDef.primaryColor;
            }
        }
Exemplo n.º 14
0
 public static void Init(SurvivorDef survivorDef)
 {
     ModifyBody(survivorDef);
     SetupInteractable(survivorDef);
     Hooks();
     AddLang();
     ModifyPod(survivorDef);
 }
        protected override void OverrideGameValues()
        {
            var assembly = SurvivorDef.GetType().Assembly;

            var firePistol = assembly.GetClass("EntityStates.Commando.CommandoWeapon", "FirePistol2");

            _doubleTapFields.Apply(firePistol);
        }
 public void UpdateInstance(SurvivorDef survivorDef)
 {
     if (survivorDefInstance != survivorDef)
     {
         Destroy(bodyInstance);
         survivorDefInstance = survivorDef;
         SpawnInstance();
     }
 }
        private bool ShouldDisplaySurvivor(SurvivorDef survivorDef)
        {
            if (!isEclipseRun)
            {
                return(survivorDef != null && !survivorDef.hidden);
            }

            return((SurvivorIndex)EclipseRun.cvEclipseSurvivorIndex.value == survivorDef.survivorIndex);
        }
Exemplo n.º 18
0
        private void RegisterSephiroth()
        {
            // gather our prefabs
            var sephPrefab        = Resources.Load <GameObject>("prefabs/characterbodies/commandobody").InstantiateClone("SephBody");
            var commandoPrefab    = Resources.Load <GameObject>("prefabs/characterbodies/commandobody");
            var sephDisplayPrefab = Resources.Load <GameObject>("prefabs/characterdisplays/commandodisplay").InstantiateClone("SephDisplay", false);

            // swap the models
            RegisterModelSwap(sephPrefab, sephDisplayPrefab);

            // Register sephs Skills
            RegisterSkills(sephPrefab);

            // register in body catalog
            var sephBody = sephPrefab.GetComponentInChildren <CharacterBody>();

            BodyCatalog.getAdditionalEntries += (list) => list.Add(sephPrefab);
            sephBody.baseNameToken            = "Sephiroth";

            // Register sephs stats
            RegisterStats(sephBody);

            // character needs pod?
            if (sephBody.preferredPodPrefab == null)
            {
                sephBody.preferredPodPrefab = commandoPrefab.GetComponentInChildren <CharacterBody>().preferredPodPrefab;
            }

            // register sephs genericcharactermain
            var stateMachine = sephBody.GetComponent <EntityStateMachine>();

            stateMachine.mainStateType = new EntityStates.SerializableEntityStateType(typeof(EntityStates.Sephiroth.Sephiroth));

            // register icon
            sephBody.portraitIcon = Assets.SephIcon.texture;

            // register survivor info
            SurvivorDef item = new SurvivorDef
            {
                name             = "SEPHIROTH_BODY",
                bodyPrefab       = sephPrefab,
                descriptionToken = "Kingdom Hearts, is light...",
                displayPrefab    = sephDisplayPrefab,
                primaryColor     = new Color(0.0f, 0.0f, 0.0f),
                unlockableName   = "Sephiroth",
                survivorIndex    = SurvivorIndex.Count + 1
            };

            SurvivorAPI.AddSurvivor(item);
            On.RoR2.BodyCatalog.Init += orig =>
            {
                orig();
                var bodyIndex = BodyCatalog.FindBodyIndex("SephBody");
                BodyCatalog.GetBodyPrefab(bodyIndex).GetComponent <CharacterBody>().baseNameToken = "Sephiroth";
            };
        }
Exemplo n.º 19
0
 /// <summary>
 /// Add a SurvivorDef to the list of available survivors. Will add the survivor on SurvivorCatalogReady event.
 /// ATTENTION: SET A VALUE FOR SURVIVORINDEX! DEFAULT IS 0 AND YOU WILL OVERWRITE COMMANDO.
 /// Any value is okay, but note:
 ///
 /// Behaviour of this function differs, depending on the SurvivorIndex specified in the SurvivorDef:
 /// - SurvivorIndex between SurvivorIndex.None and SurvivorIndex.Count
 ///     Function will try to replace an existing Survivor with this index. Use to replace existing survivors.
 ///
 /// - Other SurvivorIndex
 ///     SurvivorIndex will be set as low as possible, but will not replace other default or custom survivors.
 /// </summary>
 /// <param name="survivor">The survivor to add.</param>
 public static void AddSurvivorOnReady(SurvivorDef survivor)
 {
     if (_wasReady)
     {
         AddSurvivor(survivor);
     }
     else
     {
         SurvivorCatalogReady += (sender, args) => { AddSurvivor(survivor); }
     };
 }
Exemplo n.º 20
0
 public static SurvivorDef Add(SurvivorDef survivorDef, String contentPackIdentifier = null)
 {
     contentPackIdentifier = contentPackIdentifier ?? Assembly.GetCallingAssembly().GetName().Name;
     if (!ContentPacks.assemblyDict.ContainsKey(contentPackIdentifier))
     {
         ContentPacks.assemblyDict[contentPackIdentifier] = Assembly.GetCallingAssembly();
     }
     ContentPacks.Packs[contentPackIdentifier].survivorDefs.Add(survivorDef);
     BodyPrefabs.Add(survivorDef.bodyPrefab);
     return(survivorDef);
 }
Exemplo n.º 21
0
 // Token: 0x060020F0 RID: 8432 RVA: 0x0009AB60 File Offset: 0x00098D60
 private SurvivorIndex GetSelectedSurvivorIndexFromBodyPreference()
 {
     if (this.networkUser)
     {
         SurvivorDef survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(BodyCatalog.GetBodyPrefab(this.networkUser.bodyIndexPreference));
         if (survivorDef != null && survivorDef.survivorIndex != SurvivorIndex.None)
         {
             return(survivorDef.survivorIndex);
         }
     }
     return(SurvivorIndex.Commando);
 }
Exemplo n.º 22
0
        private ModelSkinController AddDefaultSkin(SurvivorDef def)
        {
            base.Logger.LogInfo("Adding default skin to " + def);

            ModelSkinController component = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.gameObject.AddComponent <ModelSkinController>();
            CharacterModel      model     = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.GetComponent <CharacterModel>();

            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins             = new SkinDef[0];
            skinDefInfo.Icon                  = LoadoutAPI.CreateSkinIcon(Color.black, Color.white, Color.black, Color.white);
            skinDefInfo.NameToken             = "Default";
            skinDefInfo.UnlockableName        = "";
            skinDefInfo.RootObject            = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.gameObject;
            skinDefInfo.RendererInfos         = model.baseRendererInfos;
            skinDefInfo.MeshReplacements      = new SkinDef.MeshReplacement[0];
            skinDefInfo.GameObjectActivations = new SkinDef.GameObjectActivation[1] {
                new SkinDef.GameObjectActivation()
                {
                    gameObject = def.bodyPrefab, shouldActivate = true
                }
            };
            skinDefInfo.Name = "SKIN_" + def.bodyPrefab.name + "_DEFAULT";


            if (model)
            {
                skinDefInfo.RendererInfos = model.baseRendererInfos;

                for (int i = 0; i < skinDefInfo.RendererInfos.Length; i++)
                {
                    skinDefInfo.RendererInfos[i].defaultMaterial.enableInstancing         = true;
                    skinDefInfo.RendererInfos[i].renderer.material.enableInstancing       = true;
                    skinDefInfo.RendererInfos[i].renderer.sharedMaterial.enableInstancing = true;
                }

                SkinDef skinDef3 = LoadoutAPI.CreateNewSkinDef(skinDefInfo);
                component.skins = new SkinDef[1] {
                    skinDef3
                };

                SkinDef[] skins = component.skins;

                SkinDef[][] newSkins = typeof(BodyCatalog).GetFieldValue <SkinDef[][]>("skins");
                newSkins[SurvivorCatalog.GetBodyIndexFromSurvivorIndex(def.survivorIndex)] = skins;
                typeof(BodyCatalog).SetFieldValue <SkinDef[][]>("skins", newSkins);
            }
            else
            {
                base.Logger.LogError("Unable to create new skin for " + def);
            }

            return(component);
        }
        private static SkillFamily[] ExtendSurvivor(SurvivorDef survivorDef)
        {
            var survivorName = survivorDef.displayNameToken;

            try
            {
                var bodyPrefab = survivorDef.bodyPrefab;

                if (bodyPrefab.GetComponent <ExtraSkillLocator>())
                {
                    return(Array.Empty <SkillFamily>());
                }

                var skillMap = new SkillMapConfigSection(Instance.Config, english.GetLocalizedStringByToken(survivorDef.displayNameToken));

                var skillLocator      = bodyPrefab.GetComponent <SkillLocator>();
                var extraSkillLocator = bodyPrefab.AddComponent <ExtraSkillLocator>();

                extraSkillLocator.extraFirst  = CopySkill(bodyPrefab, survivorName, "First", skillLocator.primary, skillMap.FirstRowSkills.Value);
                extraSkillLocator.extraSecond = CopySkill(bodyPrefab, survivorName, "Second", skillLocator.secondary, skillMap.SecondRowSkills.Value);
                extraSkillLocator.extraThird  = CopySkill(bodyPrefab, survivorName, "Third", skillLocator.utility, skillMap.ThirdRowSkills.Value);
                extraSkillLocator.extraFourth = CopySkill(bodyPrefab, survivorName, "Fourth", skillLocator.special, skillMap.FourthRowSkills.Value);

                var families = new List <SkillFamily>();

                if (extraSkillLocator.extraFirst)
                {
                    families.Add(extraSkillLocator.extraFirst.skillFamily);
                }
                if (extraSkillLocator.extraSecond)
                {
                    families.Add(extraSkillLocator.extraSecond.skillFamily);
                }
                if (extraSkillLocator.extraThird)
                {
                    families.Add(extraSkillLocator.extraThird.skillFamily);
                }
                if (extraSkillLocator.extraFourth)
                {
                    families.Add(extraSkillLocator.extraFourth.skillFamily);
                }

                return(families.ToArray());
            }
            catch (Exception e)
            {
                InstanceLogger.LogWarning($"Failed adding extra skill slots for \"{survivorName}\"");
                InstanceLogger.LogError(e);
            }

            return(Array.Empty <SkillFamily>());
        }
Exemplo n.º 24
0
        public void Awake()
        {
            myCharacter = Resources.Load <GameObject>("Prefabs/CharacterBodies/BrotherBody").InstantiateClone("BrotherPlayerBody");
            GameObject gameObject = myCharacter.GetComponent <ModelLocator>().modelBaseTransform.gameObject;

            gameObject.transform.localScale *= 0.45f;
            gameObject.transform.Translate(new Vector3(0, 3, 0));
            myCharacter.GetComponent <CharacterBody>().aimOriginTransform.Translate(new Vector3(0, -3, 0));

            BodyCatalog.getAdditionalEntries += delegate(List <GameObject> list)
            {
                list.Add(myCharacter);
            };

            gameObject.AddComponent <Animation>();

            CharacterBody component = myCharacter.GetComponent <CharacterBody>();

            component.baseJumpPower  = Resources.Load <GameObject>("Prefabs/CharacterBodies/LoaderBody").GetComponent <CharacterBody>().baseJumpPower;
            component.baseMoveSpeed  = Resources.Load <GameObject>("Prefabs/CharacterBodies/LoaderBody").GetComponent <CharacterBody>().baseMoveSpeed;
            component.levelMoveSpeed = Resources.Load <GameObject>("Prefabs/CharacterBodies/LoaderBody").GetComponent <CharacterBody>().levelMoveSpeed;
            component.baseDamage     = 18f;
            component.levelDamage    = 0.6f;
            component.baseCrit       = 2f;
            component.levelCrit      = 1f;
            component.baseMaxHealth  = 300f;
            component.levelMaxHealth = 25f;
            component.baseArmor      = 20f;
            component.baseRegen      = 1f;
            component.levelRegen     = 0.4f;
            component.baseMoveSpeed  = 8f;
            //component.levelMoveSpeed = 0.25f;
            component.baseAttackSpeed = 5f;
            component.name            = "PlayableMithrixBody";

            myCharacter.tag = "Player";

            myCharacter.AddComponent <ItemDisplay>();
            myCharacter.GetComponent <CharacterBody>().preferredPodPrefab = Resources.Load <GameObject>("Prefabs/CharacterBodies/toolbotbody").GetComponent <CharacterBody>().preferredPodPrefab;

            SurvivorDef survivorDef = new SurvivorDef
            {
                bodyPrefab       = myCharacter,
                descriptionToken = "MyDescription",
                displayPrefab    = gameObject,
                primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                name             = "ScavPlayerBody",
                unlockableName   = ""// "Logs.Stages.limbo"
            };

            SurvivorAPI.AddSurvivor(survivorDef);
        }
Exemplo n.º 25
0
        private static void ModifyPod(SurvivorDef survivorDef)
        {
            var enforcerPodPrefab = PrefabAPI.InstantiateClone(genericPodPrefab, "EnforcerSurvivorPod");

            //var pod = enforcerPodPrefab.transform.Find("Base/mdlEscapePod/EscapePodArmature/Base/");
            //var attachedDoor = pod.Find("Door");
            //var fallDoor = pod.Find("ReleaseExhaustFX/Door,Physics").gameObject;


            enforcerPodPrefab.AddComponent <PodComponentEnforcer>();

            survivorDef.bodyPrefab.GetComponent <CharacterBody>().preferredPodPrefab = enforcerPodPrefab;
        }
Exemplo n.º 26
0
        protected void RegisterNewSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string namePrefix, UnlockableDef unlockableDef, float desiredSortPosition)
        {
            SurvivorDef survivorDef = ScriptableObject.CreateInstance <SurvivorDef>();

            survivorDef.cachedName          = TTGL_SurvivorPlugin.developerPrefix + "_" + namePrefix + "_BODY_NAME";
            survivorDef.descriptionToken    = TTGL_SurvivorPlugin.developerPrefix + "_" + namePrefix + "_BODY_DESCRIPTION";
            survivorDef.primaryColor        = charColor;
            survivorDef.bodyPrefab          = bodyPrefab;
            survivorDef.displayPrefab       = displayPrefab;
            survivorDef.outroFlavorToken    = TTGL_SurvivorPlugin.developerPrefix + "_" + namePrefix + "_BODY_OUTRO_FLAVOR";
            survivorDef.desiredSortPosition = desiredSortPosition;
            survivorDef.unlockableDef       = unlockableDef;
            TTGL_SurvivorPlugin.survivorDefinitions.Add(survivorDef);
        }
Exemplo n.º 27
0
        private static void RegisterSurvivor()
        {
            SurvivorDef survivorDef = new SurvivorDef
            {
                name             = "SONGSTRESS_NAME",
                descriptionToken = "SONGSTRESS_DESC",
                bodyPrefab       = bodyPrefab,
                displayPrefab    = displayPrefab,
                primaryColor     = ColorMaster.ZeroColor,
                unlockableName   = ""
            };

            SurvivorAPI.AddSurvivor(survivorDef);
        }
Exemplo n.º 28
0
        public void Awake()
        {
            var banditDisplay = Resources.Load <GameObject>("prefabs/characterbodies/banditbody").GetComponent <ModelLocator>().modelTransform.gameObject;

            banditDisplay.AddComponent <MenuAnimComponent>();
            SurvivorDef item = new SurvivorDef
            {
                bodyPrefab       = Resources.Load <GameObject>("prefabs/characterbodies/banditbody"),
                descriptionToken = "The Bandit is a hit-and-run survivor who excels at assassinating single targets.<color=#CCD3E0>\n\n< ! > Blast fires faster if you click faster!\n\n< ! > Dealing a killing blow with Lights Out allows you to chain many skills together, allowing for maximum damage AND safety.\n\n< ! > Use Smokebomb to either run away or to stun many enemies at once.\n\n< ! > Grenade Toss can trigger item effects.</color>",
                displayPrefab    = banditDisplay,
                primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                unlockableName   = ""
            };

            SurvivorAPI.AddSurvivor(item);

            On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) =>
            {
                orig(self, damageInfo);
                if (damageInfo.inflictor != null && (damageInfo.inflictor.name == "BanditBody(Clone)") &&
                    (damageInfo.damageType == (DamageType.ResetCooldownsOnKill | DamageType.BypassArmor) || damageInfo.damageType == DamageType.ResetCooldownsOnKill))
                {
                    if (self.alive)
                    {
                        if (LightsOutExecute.Value)
                        {
                            float executeThreshold = LightsOutExecutePercentageBase.Value;
                            if (self.body.isElite)
                            {
                                executeThreshold += damageInfo.inflictor.GetComponent <CharacterBody>().executeEliteHealthFraction;
                            }
                            if (self.isInFrozenState && executeThreshold < (0.3f + LightsOutExecutePercentageBase.Value))
                            {
                                executeThreshold = 0.3f + LightsOutExecutePercentageBase.Value;
                            }

                            if (self.alive && (self.combinedHealthFraction < executeThreshold))
                            {
                                damageInfo.damage          = self.health;
                                damageInfo.damageType      = (DamageType.ResetCooldownsOnKill | DamageType.BypassArmor);
                                damageInfo.procCoefficient = 0f;
                                damageInfo.crit            = true;
                                orig(self, damageInfo);
                            }
                        }
                    }
                }
            };
            base.StartCoroutine(this.FixIce());
        }
Exemplo n.º 29
0
        void RegisterCharacter()
        {
            myCharacterDisplay = PrefabAPI.InstantiateClone(characterPrefab.GetComponent <ModelLocator>().modelBaseTransform.gameObject, "ExecutionerDisplay", true);
            myCharacterDisplay.AddComponent <NetworkIdentity>();

            BodyCatalog.getAdditionalEntries += delegate(List <GameObject> list)
            {
                list.Add(characterPrefab);
            };

            CharacterBody component = characterPrefab.GetComponent <CharacterBody>();

            component.baseDamage      = 10f;
            component.baseCrit        = 1f;
            component.levelCrit       = 0f;
            component.baseMaxHealth   = 400f;
            component.levelMaxHealth  = 40f;
            component.baseArmor       = 20f;
            component.baseRegen       = 2f;
            component.levelRegen      = 0.2f;
            component.baseMoveSpeed   = 8f;
            component.levelMoveSpeed  = 0.25f;
            component.baseAttackSpeed = 1f;
            component.name            = "Executioner";

            characterPrefab.GetComponent <CharacterBody>().preferredPodPrefab = Resources.Load <GameObject>("Prefabs/CharacterBodies/toolbotbody").GetComponent <CharacterBody>().preferredPodPrefab;
            LanguageAPI.Add("EXECUTIONER_DESCRIPTION"
                            , @"The Executioner is a high risk high reward survivor that's all about racking up an endless kill count.

< ! > Use Service Pistol to score some kills, and use those to charge up Ion Burst for massive damage.

< ! > Saving up Ion Burst charges is a risky move, but can pay off if you can get a bunch of shots off on a boss.

< ! > If you find yourself getting swarmed, Crowd Dispersion can get enemies off your back fast.

< ! > Execution is a great crowd control AND single target tool, don't forget its damage depends on how many targets it hits!");

            var mySurvivorDef = new SurvivorDef
            {
                bodyPrefab       = characterPrefab,
                descriptionToken = "EXECUTIONER_DESCRIPTION",
                displayPrefab    = myCharacterDisplay,
                primaryColor     = new Color(0.8039216f, 0.482352942f, 0.843137264f),
                name             = "Executioner",
                unlockableName   = "",
            };

            SurvivorAPI.AddSurvivor(mySurvivorDef);
        }
Exemplo n.º 30
0
        internal static void RegisterNewSurvivor(GameObject bodyPrefab, GameObject displayPrefab, Color charColor, string namePrefix, string unlockString)
        {
            SurvivorDef survivorDef = new SurvivorDef
            {
                name             = HenryPlugin.developerPrefix + "_" + namePrefix + "_BODY_NAME",
                unlockableName   = unlockString,
                descriptionToken = HenryPlugin.developerPrefix + "_" + namePrefix + "_BODY_DESCRIPTION",
                primaryColor     = charColor,
                bodyPrefab       = bodyPrefab,
                displayPrefab    = displayPrefab,
                outroFlavorToken = HenryPlugin.developerPrefix + "_" + namePrefix + "_BODY_OUTRO_FLAVOR",
            };

            SurvivorAPI.AddSurvivor(survivorDef);
        }