public ValidationResult ValidateInteraction(ClientGameState currentState, InteractionBase interaction)
        {
            switch (interaction.Type)
            {
            case InteractionType.Attack:
                return(attackProcessor.ValidateAttack(currentState, interaction as InteractionAttack));

            case InteractionType.PlayCard:
                return(playCardProcessor.ValidatePlayCard(currentState, interaction as InteractionPlayCard));

            case InteractionType.EndTurn:
                return(endTurnProcessor.ValidateEndTurn(currentState));
            }

            return(new ValidationResult()
            {
                IsOk = false,
                Messages = new List <string>()
                {
                    $"Unknown Interaction of type {interaction.GetType()} encountered"
                }
            });
        }
Exemple #2
0
 public static bool Activate(InteractionBase __instance, Character _character)
 {
     // Activate > OnActivate > ActivationDone
     try
     {
         //WorkInProgress.Instance.MyLogger.LogDebug("Activate=" + __instance.GetType().Name);
         if (__instance.GetType() != typeof(InteractionSleep))
         {
             return(true);
         }
         var ds = (__instance as InteractionSleep).Item.GetComponent <CustomDurable>();
         if (ds == null)
         {
             return(true);
         }
         //WorkInProgress.Instance.MyLogger.LogDebug($"RestrictUsageOfTents[{(__instance as InteractionSleep).Item.name}]={ds.CurrentDurability}");
         //var list = Resources.FindObjectsOfTypeAll<GameObject>().Where(g => g.name.StartsWith("5000021_Bedroll_")
         //    && g.GetComponent<Item>() != null
         //    && g.GetComponent<Item>().CurrentDurability == 100
         //    ).ToList();
         //foreach (var go in list)
         //{
         //    AccessTools.Field(typeof(Item), "m_currentDurability").SetValue(go.GetComponent<Item>(), 42);
         //    WorkInProgress.Instance.MyLogger.LogDebug($" > {go.name} ({go.GetComponent<Item>().CurrentDurability})");
         //}
         if (_character.Inventory.HasABag)
         {
             _character.CharacterUI.ShowInfoNotification("You must remove your bagpack before sleep!");
             return(false);
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("Activate: " + ex.Message);
     }
     return(true);
 }
Exemple #3
0
 private static void SetupInteractionData()
 {
     text.Visible  = false;
     save.Visible  = false;
     group.Visible = false;
     group.Controls.Clear();
     toolButton.DropDown.Items[0].Visible = false;
     toolButton.DropDown.Items[2].Visible = false;
     toolButton.DropDown.Items[3].Visible = false;
     if (currentObject.GetType() == typeof(InteractionChoice))
     {
         toolButton.DropDown.Items[3].Visible = true;
     }
     else if (currentObject.GetType() == typeof(InteractionQuests))
     {
         toolButton.DropDown.Items[3].Visible = true;
         group.Visible = true;
         CheckBox bux = new CheckBox()
         {
             Location = new Point(5, 15),
             Text     = "Immediate Mode",
             Checked  = ((InteractionQuests)currentObject).immediateMode
         };
         bux.CheckedChanged += new EventHandler((object sender, EventArgs e) => {
             ((InteractionQuests)currentObject).immediateMode = bux.Checked;
         });
         group.Controls.Add(bux);
     }
     else if (currentObject.GetType() == typeof(InteractionDialogue))
     {
         text.Visible = true;
         text.Text    = ((InteractionDialogue)currentObject).displayText;
         save.Visible = true;
     }
     else if (currentObject.GetType() == typeof(InteractionPath))
     {
         toolButton.DropDown.Items[0].Visible = true;
         toolButton.DropDown.Items[2].Visible = true;
         group.Visible = true;
         save.Visible  = true;
         //If under a quest, set quest flags and stuff
         if (nodeBase[displayTree.SelectedNode.Parent].GetType() == typeof(InteractionQuests))
         {
             InteractionQuests que = (InteractionQuests)nodeBase[displayTree.SelectedNode.Parent];
             tmpInt = que.paths.IndexOf((InteractionPath)currentObject);
             pars   = new TextBox[3];
             TextBox val = new TextBox()
             {
                 Location = new Point(0, 35),
                 Size     = new Size(200, 20),
                 Text     = displayTree.SelectedNode.Text
             };
             group.Controls.Add(new Label()
             {
                 Text = "Path Name: ", Location = new Point(0, 15), Size = new Size(200, 20)
             });
             group.Controls.Add(val);
             TextBox vall = new TextBox()
             {
                 Location = new Point(0, 75),
                 Size     = new Size(200, 20),
                 Text     = (que.questTags.Count > tmpInt && tmpInt != -1) ? que.questTags[tmpInt] : ""
             };
             group.Controls.Add(new Label()
             {
                 Text = "Quest Name: ", Location = new Point(0, 55), Size = new Size(200, 20)
             });
             group.Controls.Add(vall);
             TextBox valll = new TextBox()
             {
                 Location = new Point(0, 115),
                 Size     = new Size(200, 20),
                 Text     = (que.questInts.Count > tmpInt && tmpInt != -1) ? que.questInts[tmpInt].ToString() : "0"
             };
             group.Controls.Add(new Label()
             {
                 Text = "Checked Int: ", Location = new Point(0, 95), Size = new Size(200, 20)
             });
             group.Controls.Add(valll);
             pars[0] = val;
             pars[1] = vall;
             pars[2] = valll;
         }
         else
         {
             pars = new TextBox[1];
             TextBox val = new TextBox()
             {
                 Location = new Point(0, 35),
                 Size     = new Size(200, 20),
                 Text     = displayTree.SelectedNode.Text
             };
             group.Controls.Add(new Label()
             {
                 Text = "Path Name: ", Location = new Point(0, 15), Size = new Size(200, 20)
             });
             group.Controls.Add(val);
             pars[0] = val;
         }
     }
 }