Beispiel #1
0
        public static async void ClientInvitationAccept(string clanTag)
        {
            if (NewbieProtectionSystem.ClientIsNewbie)
            {
                NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(null);
                return;
            }

            if (ClientCheckIsUnderJoinCooldown(showErrorNotification: true))
            {
                return;
            }

            var timeRemains = await Instance.CallServer(
                _ => _.ServerRemote_GetCooldownRemainsToJoinReturnToFaction(clanTag));

            if (timeRemains > 0)
            {
                var factionEmblem =
                    await ClientFactionEmblemTextureProvider.GetEmblemTextureAsync(clanTag, useCache : true);

                NotificationSystem.ClientShowNotification(
                    title: CoreStrings.Faction_ErrorUnderJoinCooldown,
                    // TODO: consider using a separate text constant here
                    message: string.Format(CoreStrings.ShieldProtection_CooldownRemains_Format,
                                           ClientTimeFormatHelper.FormatTimeDuration(timeRemains)),
                    NotificationColor.Bad,
                    icon: factionEmblem);
                return;
            }

            DialogWindow.ShowDialog(
                title: CoreStrings.Faction_Join,
                text: string.Format(CoreStrings.Faction_DialogJoinConfirmation_Message_Format,
                                    @$ "\[{clanTag}\]")
Beispiel #2
0
        protected override double SharedCalculateDamageByWeapon(
            WeaponFinalCache weaponCache,
            double damagePreMultiplier,
            IStaticWorldObject targetObject,
            out double obstacleBlockDamageCoef)
        {
            var serverTime = IsServer
                                 ? Server.Game.FrameTime
                                 : Client.CurrentGame.ServerFrameTimeApproximated;

            if (serverTime < GetPublicState(targetObject).CooldownUntilServerTime)
            {
                // too hot for mining - no damage to it
                if (IsClient &&
                    weaponCache.ProtoWeapon is IProtoItemToolMining)
                {
                    NotificationSystem.ClientShowNotification(CoreStrings.Meteorite_CooldownMessage_TooHotForMining,
                                                              color: NotificationColor.Bad,
                                                              icon: this.Icon);
                }

                if (IsServer &&
                    weaponCache.ProtoWeapon is IProtoItemWeaponMelee &&
                    !weaponCache.Character.IsNpc)
                {
                    weaponCache.Character.ServerAddStatusEffect <StatusEffectHeat>(intensity: 0.5);
                }

                obstacleBlockDamageCoef = this.ObstacleBlockDamageCoef;
                return(0);
            }

            // meteorite cooldown finished
            if (NewbieProtectionSystem.SharedIsNewbie(weaponCache.Character))
            {
                // don't allow mining meteorite while under newbie protection
                if (IsClient)
                {
                    NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(this);
                }

                obstacleBlockDamageCoef = 0;
                return(0);
            }

            return(base.SharedCalculateDamageByWeapon(weaponCache,
                                                      damagePreMultiplier,
                                                      targetObject,
                                                      out obstacleBlockDamageCoef));
        }
Beispiel #3
0
        public static void ClientApplicantSubmitApplication(string clanTag)
        {
            if (NewbieProtectionSystem.ClientIsNewbie)
            {
                NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(null);
                return;
            }

            if (ClientCheckIsUnderJoinCooldown(showErrorNotification: true))
            {
                return;
            }

            DialogWindow.ShowDialog(
                title: CoreStrings.Faction_SubmitApplication,
                string.Format(CoreStrings.Faction_DialogSubmitApplication_Message_Format,
                              @$ "\[{clanTag}\]")
Beispiel #4
0
        public override bool SharedCanInteract(ICharacter character, IStaticWorldObject worldObject, bool writeToLog)
        {
            if (!base.SharedCanInteract(character, worldObject, writeToLog))
            {
                return(false);
            }

            if (NewbieProtectionSystem.SharedIsNewbie(character))
            {
                // don't allow hacking while under newbie protection
                if (writeToLog && IsClient)
                {
                    NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(this);
                }

                return(false);
            }

            return(true);
        }
Beispiel #5
0
        protected override double SharedCalculateDamageByWeapon(
            WeaponFinalCache weaponCache,
            double damagePreMultiplier,
            IStaticWorldObject targetObject,
            out double obstacleBlockDamageCoef)
        {
            if (NewbieProtectionSystem.SharedIsNewbie(weaponCache.Character))
            {
                // don't allow mining a boss loot while under newbie protection
                if (IsClient)
                {
                    NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(this);
                }

                obstacleBlockDamageCoef = 0;
                return(0);
            }

            return(base.SharedCalculateDamageByWeapon(weaponCache,
                                                      damagePreMultiplier,
                                                      targetObject,
                                                      out obstacleBlockDamageCoef));
        }
        public override bool SharedOnDamage(
            WeaponFinalCache weaponCache,
            IWorldObject targetObject,
            double damagePreMultiplier,
            double damagePostMultiplier,
            out double obstacleBlockDamageCoef,
            out double damageApplied)
        {
            var byCharacter = weaponCache.Character;

            if (NewbieProtectionSystem.SharedIsNewbie(byCharacter))
            {
                // don't allow attacking a boss while under newbie protection
                if (IsClient)
                {
                    NewbieProtectionSystem.ClientNotifyNewbieCannotPerformAction(this);
                }

                obstacleBlockDamageCoef = 0;
                damageApplied           = 0;
                return(false);
            }

            if (IsServer)
            {
                // apply the difficulty coefficient
                damagePostMultiplier /= ServerBossDifficultyCoef;

                if (weaponCache.ProtoExplosive != null)
                {
                    // the boss is massive so it will take x2 damage from explosives (such as grenades)
                    damagePostMultiplier *= 2;
                }
            }

            var result = base.SharedOnDamage(weaponCache,
                                             targetObject,
                                             damagePreMultiplier,
                                             damagePostMultiplier,
                                             out obstacleBlockDamageCoef,
                                             out damageApplied);

            if (IsServer &&
                result &&
                byCharacter != null &&
                !byCharacter.IsNpc)
            {
                var privateState = GetPrivateState((ICharacter)targetObject);

                // record the damage dealt by player
                privateState.DamageTracker.RegisterDamage(byCharacter, damageApplied);

                if (damageApplied > 1 / ServerBossDifficultyCoef)
                {
                    // record the last time a significant damage is dealt
                    privateState.LastDamageTime = Server.Game.FrameTime;
                }
            }

            return(result);
        }