Esempio n. 1
0
        public void Redo()
        {
            RedoOperation();

            AfterRedoAction?.Invoke();
            AfterAction?.Invoke();
        }
Esempio n. 2
0
        public void Undo()
        {
            UndoOperation();

            AfterUndoAction?.Invoke();
            AfterAction?.Invoke();
        }
 protected void FireOkClicked(EventArgs e)
 {
     if (ValidationFunc == null || ValidationFunc.Invoke(CalendarDate.Date))
     {
         Date = CalendarDate.Date;
         AfterAction?.Invoke();
     }
 }
Esempio n. 4
0
    protected bool HandleObjectTick(Player player, GameObjectInstance obj, TimeSpan totalTime, TimeSpan deltaTime)
    {
        var session = Sessions.Get(player);

        if (!session.Objects.HasAcquiredLock(obj, player))
        {
            StopAnimation(player, obj);
            return(true);
        }

        var skillLevel = statsProvider.GetLevel(player.Id, skillName);
        var chance     = 0.05f + skillLevel * 0.05f;

        if (random.NextDouble() <= chance)
        {
            StartAnimation(player, obj);
            return(false);
        }
        var gobj         = GameData.GetGameObject(obj.ObjectId);
        var levelsGaiend = statsProvider.AddExperience(player.Id, skillName, gobj.Experience);
        var itemDrops    = session.Objects.GetItemDrops(obj);

        foreach (var itemDrop in itemDrops)
        {
            if (random.NextDouble() > itemDrop.DropChance)
            {
                continue;
            }

            World.AddPlayerItem(player, GameData.GetItem(itemDrop.ItemId));
        }

        var exp = statsProvider.GetExperience(player.Id, skillName);

        World.UpdatePlayerStat(player, skillName, skillLevel + levelsGaiend, exp);

        if (levelsGaiend > 0)
        {
            World.PlayerStatLevelUp(player, skillName, levelsGaiend);
        }

        StopAnimation(player, obj);
        if (AfterAction != null)
        {
            AfterAction?.Invoke(this, new AfterActionEventArgs(player, obj));
        }
        return(true);
    }
Esempio n. 5
0
        public void FirePostActions(AbstractCommand command)
        {
            try
            {
                AfterAction?.Invoke(command);
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Failed to invoke action after command ran successfully.", exception);
            }

            try
            {
                if (ShouldPingAfter)
                {
                    IO.Http.Get(PingAfterUrl);
                }
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Ping failed for {PingAfterUrl} after command ran successfully.", exception);
            }

            var emailSubject  = $"Command completed: {command.Name}";
            var commandOutput = command.FlushBuffer();

            try
            {
                if (ShouldEmailOutput)
                {
                    new Mail()
                    {
                        Host     = MailSettings.Host,
                        Port     = MailSettings.Port,
                        Username = MailSettings.Username,
                        Password = MailSettings.Password,
                    }
                }
                .Send(MailSettings.From, EmailOutputToAddress, emailSubject, commandOutput);
            }