Exemplo n.º 1
0
        protected override void ServerInitializeCharacter(ServerInitializeData data)
        {
            // don't call the base initialize
            // base.ServerInitializeCharacter(data);

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

            data.PrivateState.WeaponState.SharedSetWeaponProtoOnly(this.protoItemWeaponTurret);
            data.PublicState.SharedSetCurrentWeaponProtoOnly(this.protoItemWeaponTurret);

            this.ServerInitializeCharacterTurret(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;
            }
        }
Exemplo n.º 2
0
 protected virtual void ServerForceBuildFinalStatsCache(
     TPrivateState privateState,
     TPublicState publicState)
 {
     SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(
         this.ProtoCharacterDefaultEffects,
         publicState,
         privateState);
 }
Exemplo n.º 3
0
        public static void SharedRefreshFinalCacheIfNecessary(this ICharacter character)
        {
            var publicState  = character.GetPublicState <ICharacterPublicState>();
            var privateState = character.GetPrivateState <BaseCharacterPrivateState>();

            SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(
                ((IProtoCharacterCore)character.ProtoCharacter).ProtoCharacterDefaultEffects,
                publicState,
                privateState);
        }
Exemplo n.º 4
0
        protected void ServerRebuildFinalCacheIfNeeded(
            PlayerCharacterPrivateState privateState,
            PlayerCharacterPublicState publicState)
        {
            if (!privateState.FinalStatsCache.IsDirty &&
                publicState.ContainerEquipment.StateHash == privateState.ContainerEquipmentLastStateHash)
            {
                return;
            }

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