public void EnqueueDeferred(IEntity source, ActionGraph g) { // Don't queue unimplemented cards if (g != null) { EnqueueDeferred(source, g.Unravel()); } }
public void ForceRun(IEntity owningEntity, ActionGraph g, IEntity target = null) { var actions = g.Unravel(); #if _TRIGGER_DEBUG DebugLog.WriteLine("Game " + Game.GameId + ": Running forced trigger for " + owningEntity.ShortDescription + " with actions: " + string.Join(" ", actions.Select(a => a.ToString()))); #endif QueuedTriggersCount++; Game.RunActionBlock(BlockType.TRIGGER, owningEntity, actions, target); }
// Compile all the ActionGraph fields in a Behaviour into lists of QueueActions internal static CardBehaviour FromGraph(CardBehaviourGraph b) { var compiled = new CardBehaviour(); var behaviourList = new List <string>(); // Find all the fields we can compile var behaviourClass = typeof(CardBehaviourGraph).GetFields(); foreach (var field in behaviourClass) { if (field.FieldType == typeof(ActionGraph)) { behaviourList.Add(field.Name); } } // Compile each field that exists foreach (var fieldName in behaviourList) { var field = b.GetType().GetField(fieldName); ActionGraph fieldValue = field.GetValue(b) as ActionGraph; if (fieldValue != null) { compiled.GetType().GetField(fieldName).SetValue(compiled, fieldValue.Unravel()); } else { compiled.GetType().GetField(fieldName).SetValue(compiled, new List <QueueAction>()); } } // Copy event triggers compiled.TriggersByZone = b.TriggersByZone; return(compiled); }
public static List <QueueAction> Then(this List <QueueAction> ql, ActionGraph act) { ql.AddRange(act.Unravel()); return(ql); }
public Trigger(ActionGraph action, Condition condition = null) { Condition = condition; Action = action.Unravel(); }
public Task <ActionResult> RunAsync(IEntity source, ActionGraph g) { return(g != null?RunAsync(source, g.Unravel()) : Task.FromResult(ActionResult.None)); }
public void StartBlock(IEntity source, ActionGraph g, BlockStart gameBlock = null) { if (g != null) StartBlock(source, g.Unravel(), gameBlock); }