Exemplo n.º 1
0
        // main actual spawn method
        internal Character InternalSpawn(Vector3 position, Vector3 rotation, string characterUID, string extraRpcData, bool loadingFromSave)
        {
            characterUID = characterUID ?? this.UID;

            if (CharacterManager.Instance.GetCharacter(characterUID) is Character existing)
            {
                SL.Log("Trying to spawn a character UID " + characterUID + " but one already exists with that UID!");
                return(existing);
            }

            return(CustomCharacters.SpawnCharacter(this, position, rotation, characterUID, extraRpcData, loadingFromSave).GetComponent <Character>());
        }
Exemplo n.º 2
0
        internal void Awake()
        {
            Instance = this;

            SetupBasicAIPrefab();
        }
Exemplo n.º 3
0
        public virtual void SetStats(Character character)
        {
            if (character.GetComponent <PlayerCharacterStats>())
            {
                CustomCharacters.FixStats(character);
            }

            var stats = character.GetComponent <CharacterStats>();

            if (!stats)
            {
                return;
            }

            if (Health != null)
            {
                var m_maxHealthStat = (Stat)At.GetField(stats, "m_maxHealthStat");
                m_maxHealthStat.AddStack(new StatStack(SL_STAT_ID, (float)Health - 100), false);
            }

            if (HealthRegen != null)
            {
                var m_healthRegenStat = (Stat)At.GetField(stats, "m_healthRegen");
                m_healthRegenStat.AddStack(new StatStack(SL_STAT_ID, (float)HealthRegen), false);
            }

            if (ImpactResist != null)
            {
                var m_impactResistance = (Stat)At.GetField(stats, "m_impactResistance");
                m_impactResistance.AddStack(new StatStack(SL_STAT_ID, (float)ImpactResist), false);
            }

            if (Protection != null)
            {
                var m_damageProtection = (Stat[])At.GetField(stats, "m_damageProtection");
                m_damageProtection[0].AddStack(new StatStack(SL_STAT_ID, (float)Protection), false);
            }

            if (this.Barrier != null)
            {
                var m_barrier = (Stat)At.GetField(stats, "m_barrierStat");
                m_barrier.AddStack(new StatStack(SL_STAT_ID, (float)Barrier), false);
            }

            if (Damage_Resists != null)
            {
                var m_damageResistance = (Stat[])At.GetField(stats, "m_damageResistance");
                for (int i = 0; i < 6; i++)
                {
                    m_damageResistance[i].AddStack(new StatStack(SL_STAT_ID, Damage_Resists[i]), false);
                }
            }

            if (Damage_Bonus != null)
            {
                var m_damageTypesModifier = (Stat[])At.GetField(stats, "m_damageTypesModifier");
                for (int i = 0; i < 6; i++)
                {
                    m_damageTypesModifier[i].AddStack(new StatStack(SL_STAT_ID, Damage_Bonus[i]), false);
                }
            }

            // status immunity
            if (this.Status_Immunity != null)
            {
                var immunities = new List <TagSourceSelector>();
                foreach (var tagName in this.Status_Immunity)
                {
                    if (CustomItems.GetTag(tagName) is Tag tag && tag != Tag.None)
                    {
                        immunities.Add(new TagSourceSelector(tag));
                    }
                }

                At.SetField(stats, "m_statusEffectsNaturalImmunity", immunities.ToArray());
            }
        }
Exemplo n.º 4
0
        // coroutine used for destroy-on-death

        private IEnumerator DestroyOnDeathCoroutine(Character character)
        {
            yield return(new WaitForSeconds(2.0f));

            CustomCharacters.DestroyCharacterRPC(character);
        }