private Trigger ParseTrigger(XElement triggerNode) { try { string conditionString; if (triggerNode.Attribute("condition") != null) { conditionString = triggerNode.RequireAttribute("condition").Value; } else { conditionString = triggerNode.Element("Condition").Value; } Condition condition = EffectParser.ParseCondition(conditionString); Effect effect = EffectParser.LoadTriggerEffect(triggerNode.Element("Effect")); return(new Trigger { Condition = condition, Effect = effect }); } catch (Exception e) { throw new GameXmlException(triggerNode, "There was an error parsing a trigger. There may be a syntax error in your condition expression.\n\nThe error message was:\n\n\t" + e.Message); } }
private void ConditionCommand(SceneConditionCommandInfo command) { var condition = EffectParser.ParseCondition(command.ConditionExpression); var entity = Entities.GetAll().FirstOrDefault(e => e.Name == command.ConditionEntity); if (condition(entity)) { RunCommands(command.Commands); } }
private Trigger ParseTrigger(TriggerInfo info) { try { var condition = EffectParser.ParseCondition(info.Condition); var effect = EffectParser.LoadTriggerEffect(info.Effect); var elseEffect = (info.Else != null) ? EffectParser.LoadTriggerEffect(info.Else) : null; return(new Trigger { Condition = condition, Effect = effect, Else = elseEffect, ConditionString = info.Condition, Priority = info.Priority ?? 0 }); } catch (Exception e) { throw new GameRunException("There was an error parsing a trigger. There may be a syntax error in your condition expression.\n\nThe error message was:\n\n\t" + e.Message); } }