예제 #1
0
        private void AssociateEvent(Dictionary <Event, List <Action> > rootEvents)
        {
            foreach (var e in rootEvents)
            {
                if (!e.Key.Active)
                {
                    continue;
                }
                Events.Add(e.Key, e.Value);
                var evAbnormalities = e.Key as AbnormalityEvent;
                if (evAbnormalities != null)
                {
                    if (evAbnormalities.Trigger == AbnormalityTriggerType.MissingDuringFight || evAbnormalities.Trigger == AbnormalityTriggerType.Ending)
                    {
                        MissingAbnormalities.Add(e.Key, e.Value);
                    }
                    else
                    {
                        AddedRemovedAbnormalities.Add(e.Key, e.Value);
                    }
                }

                var evCooldown = e.Key as CooldownEvent;
                if (evCooldown != null)
                {
                    Cooldown.Add(e.Key, e.Value);
                }

                var evAFK = e.Key as CommonAFKEvent;
                if (evAFK != null)
                {
                    AFK = new Tuple <Event, List <Action> >(e.Key, e.Value);
                }
            }
        }
예제 #2
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            var player   = src.ToPlayer();
            var playerId = player.CSteamId;

            if (Cooldown.Has(playerId))
            {
                return(CommandResult.Lang(EssLang.USE_COOLDOWN,
                                          TimeUtil.FormatSeconds((uint)Cooldown.GetRemaining(playerId))));
            }

            Vector3 position;
            byte    angle;

            if (player.RocketPlayer.Stance == EPlayerStance.DRIVING ||
                player.RocketPlayer.Stance == EPlayerStance.SITTING)
            {
                return(CommandResult.Lang(EssLang.CANNOT_TELEPORT_DRIVING));
            }

            if (!BarricadeManager.tryGetBed(player.CSteamId, out position, out angle))
            {
                return(CommandResult.Lang(EssLang.WITHOUT_BED));
            }

            var homeCommand = UEssentials.Config.HomeCommand;
            var delay       = homeCommand.Delay;
            var cooldown    = homeCommand.Cooldown;

            if (player.HasPermission("essentials.bypass.homecooldown"))
            {
                delay    = 0;
                cooldown = 0;
            }

            if (delay > 0)
            {
                EssLang.TELEPORT_DELAY.SendTo(src, TimeUtil.FormatSeconds((uint)delay));
            }

            var task = Tasks.New(t => {
                Delay.Remove(playerId.m_SteamID);
                if (!player.IsOnline)
                {
                    return;
                }
                player.Teleport(position, angle);
                EssLang.TELEPORTED_BED.SendTo(src);
            }).Delay(delay * 1000);

            task.Go();

            Delay.Add(playerId.m_SteamID, task);
            Cooldown.Add(playerId, cooldown);

            return(CommandResult.Success());
        }