Пример #1
0
        protected override void ServerInitializeCharacter(ServerInitializeData data)
        {
            // don't call the base initialize
            // base.ServerInitializeCharacter(data);

            var character    = data.GameObject;
            var publicState  = data.PublicState;
            var privateState = data.PrivateState;

            this.ServerInitializeCharacterMob(data);

            SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(
                this.ProtoCharacterDefaultEffects,
                data.PublicState,
                privateState,
                // always rebuild the mob character state
                // as the game doesn't store current HP for mobs
                isFirstTime: true);

            var weaponState = privateState.WeaponState;

            WeaponSystem.SharedRebuildWeaponCache(character, weaponState);
            privateState.AttackRange = weaponState.WeaponCache?.RangeMax ?? 0;

            if (data.IsFirstTimeInit)
            {
                privateState.SpawnPosition = character.TilePosition;
            }
            else if (publicState.IsDead)
            {
                // should never happen as the ServerCharacterDeathMechanic should properly destroy the character
                Logger.Error("(Should never happen) Destroying dead mob character: " + character);
                this.ServerOnDeath(character);
            }
        }
Пример #2
0
 /// <summary>
 /// This method is invoked when the character is completely prepared and initialized.
 /// </summary>
 protected virtual void ServerInitializeCharacter(ServerInitializeData data)
 {
     SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(this.ProtoCharacterDefaultEffects,
                                                                data.PublicState,
                                                                data.PrivateState,
                                                                isFirstTime: data.IsFirstTimeInit);
 }
Пример #3
0
        protected override void ServerInitializeCharacter(ServerInitializeData data)
        {
            // don't call the base initialize
            // base.ServerInitializeCharacter(data);

            this.ServerInitializeCharacterMob(data);

            var character    = data.GameObject;
            var privateState = data.PrivateState;

            SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(this.ProtoCharacterDefaultEffects,
                                                                       data.PublicState,
                                                                       privateState,
                                                                       isFirstTime: data.IsFirstTimeInit);

            var weaponState = privateState.WeaponState;

            WeaponSystem.RebuildWeaponCache(character, weaponState);
            privateState.AttackRange = weaponState.WeaponCache?.RangeMax ?? 0;

            if (data.IsFirstTimeInit)
            {
                privateState.SpawnPosition = character.TilePosition;
            }
        }
Пример #4
0
        private void ServerRebuildFinalCacheIfNeeded(
            ICharacter character,
            BaseCharacterPrivateState privateState,
            ICharacterPublicState publicState)
        {
            if (!privateState.FinalStatsCache.IsDirty)
            {
                return;
            }

            // rebuild stats cache
            SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(this.ProtoCharacterDefaultEffects,
                                                                       publicState,
                                                                       privateState);
        }