Example #1
0
        internal RantPattern(string name, RantPatternSource type, string code)
        {
            Name = name;
            Type = type;
            Code = code;
	        Action = RantCompiler.Compile(name, code);
        }
Example #2
0
	    private static IEnumerator<RantAction> Branch(Sandbox sb, string id, RantAction branchAction)
	    {
		    sb.RNG.Branch(id.Hash());
		    yield return branchAction;
		    sb.RNG.Merge();
	    }
Example #3
0
 private static IEnumerator<RantAction> Else(Sandbox sb, RantAction conditionFailPattern)
 {
     if (sb.Engine.Flags.Any(flag => sb.ConditionFlags.Contains(flag) != sb.FlagConditionExpectedResult))
     {
         yield return conditionFailPattern;
     }
 }
Example #4
0
 private static IEnumerator<RantAction> Then(Sandbox sb, RantAction conditionPassPattern)
 {
     if (sb.Engine.Flags.All(flag => sb.ConditionFlags.Contains(flag) == sb.FlagConditionExpectedResult))
     {
         yield return conditionPassPattern;
     }
 }
Example #5
0
	    private static IEnumerator<RantAction> Chan(Sandbox sb, string channelName, ChannelVisibility visibility, RantAction pattern)
	    {
			sb.Output.OpenChannel(channelName, visibility);
		    yield return pattern;
		    sb.Output.CloseChannel();
	    }
Example #6
0
        /// <summary>
        /// Creates a new RantObject instance from the specified object.
        /// </summary>
        /// <param name="obj">The value to assign to the object.</param>
		public RantObject(object obj)
		{
			if (obj == null) return;

			if (obj is string)
			{
				_string = obj.ToString();
				Type = RantObjectType.String;
			}
			else if (obj is bool)
			{
				_boolean = (bool)obj;
				Type = RantObjectType.Boolean;
			}
			else if (IsNumber(obj))
			{
				_number = (double)obj;
				Type = RantObjectType.Number;
			}
			else if (obj is List<RantObject>)
			{
				_list = (List<RantObject>)obj;
				Type = RantObjectType.List;
			}
			else if (obj.GetType().IsArray)
			{
				_list = ((object[])obj).Select(o => new RantObject(o)).ToList();
				Type = RantObjectType.List;
			}
			else if (obj is RantPattern)
			{
				_pattern = (RantPattern)obj;
			}
			else if (obj is RantAction)
			{
				_action = (RantAction)obj;
				Type = RantObjectType.Action;
			}
		}
Example #7
0
		internal RantObject(RantAction action)
		{
			Type = RantObjectType.Action;
			_action = action;
		}
Example #8
0
		internal void AddActionFunction(string name, RantAction body)
		{
			_objects[name] = new RantObject(body);
		}
Example #9
0
        protected void AddToOutput(RantAction action)
        {
            // NOTE: kinda sucks we can't include the caller's name here because this method's signature must stay just as it is
            if (!outputDelegates.Any())
                throw new RantInternalException($"{GetType().Name}.AddToOutput({action.GetType().Name}): Output delegate stack is empty.");

            outputDelegates.Peek()(action);
        }
Example #10
0
 public RAReplacer(Stringe range, Regex regex, RantAction sourceAction, RantAction matchEvalAction) : base(range)
 {
     _regex           = regex;
     _sourceAction    = sourceAction;
     _matchEvalAction = matchEvalAction;
 }
Example #11
0
		public RAReplacer(Stringe range, Regex regex, RantAction sourceAction, RantAction matchEvalAction) : base(range)
		{
			_regex = regex;
			_sourceAction = sourceAction;
			_matchEvalAction = matchEvalAction;
		}