示例#1
0
 public void Compile()
 {
     if (!this.IsLoaded())
     {
         this.Load();
     }
     this.compiled = true;
     foreach (string r_expr in script.Split(';'))
     {
         if (r_expr == "" || r_expr == " ")
         {
             continue;
         }
         string expr = Regex.Replace(r_expr, "\r?\n+[ \t]*", " ");
         if (expr == "" || expr == " ")
         {
             continue;
         }
         int index = 0;
         tt.Value.Logger.Debug("Start Parsing Expr : " + expr);
         IVariable Value = Split.Parse(expr, ref index, ';');
         tt.Value.Logger.Debug("Parsed Expr to : " + Value.ToString());
         string vt = Value.GetType();
         if (vt == "Recipe")
         {
             recipes.Add((MLRecipe)Value);
         }
         else if (vt == "Remove")
         {
             removes.Add((MLItem)Value.GetValue());
         }
     }
 }
示例#2
0
        /// <summary>
        /// Updates the specified variable.
        /// If the value is at original/cloned container then updates value to the cloned value.
        /// </summary>
        /// <typeparam name="T">Type of the variable.</typeparam>
        /// <param name="variable">The variable to update.</param>
        /// <param name="clonedObjects">The original/cloned container.</param>
        private static void SetValue <T>(IVariable variable, IDictionary <T, T> clonedObjects) where T : class
        {
            T newValue;

            if (clonedObjects.TryGetValue(variable.GetValue() as T, out newValue))
            {
                variable.SetValue(newValue);
            }
        }
示例#3
0
        public MLTile GetTile(IVariable raw)
        {
            string name = raw.GetValue();

            this.isEnded = raw.isEnd();
            if (isVanilla)
            {
                return(new VTile(name));
            }
            MLTile item = new MLTile(ModContent.Find <ModTile>(this.Value.Name, name));

            item.isEnded = this.isEnded;
            return(item);
        }
示例#4
0
        public MLItem GetItem(IVariable raw)
        {
            string name = raw.GetValue();

            this.isEnded = raw.isEnd();
            if (isVanilla)
            {
                return(new VItem(name));
            }
            MLItem item = new MLItem(ModContent.Find <ModItem>(this.Value.Name, name));

            item.isEnded = this.isEnded;
            return(item);
        }
示例#5
0
 /// <summary>
 /// Updates the specified variable.
 /// When the variable is actor or path variable: checks if the value is at original/cloned container;
 /// if yes then updates value to the cloned value.
 /// When the variable is actor variable: checks if the value is <paramref name="actorOwner"/>; if yes then sets value to Owner.
 /// </summary>
 /// <param name="variable">The variable to update.</param>
 /// <param name="actorOwner">The owner of the variable.</param>
 /// <param name="clonedActors">The original/cloned actors container.</param>
 /// <param name="clonedPaths">The original/cloned paths container.</param>
 private static void UpdateVariable(IVariable variable, Actor actorOwner, Dictionary <Actor, Actor> clonedActors, Dictionary <Path, Path> clonedPaths)
 {
     // actor variable
     if (variable.VariableType == VariableType.Actor && variable.GetValue() != null)
     {
         // set as owner
         if (variable.GetValue() == actorOwner)
         {
             ((ActorVar)variable).Owner = true;
         }
         // set to cloned actor
         else
         {
             SetValue(variable, clonedActors);
         }
     }
     // path variable
     else if (variable.VariableType == VariableType.Path && variable.GetValue() != null)
     {
         // set to cloned path
         SetValue(variable, clonedPaths);
     }
 }
示例#6
0
 public override void SetValue(IVariable <int> value)
 {
     Value = value.GetValue();
 }
示例#7
0
 public override void ApplyChange(IVariable <int> amount)
 {
     Value += amount.GetValue();
 }
示例#8
0
 public override void SetValue(IVariable <KeyCode> value)
 {
     Value = value.GetValue();
 }
示例#9
0
 public override void ApplyChange(IVariable <KeyCode> value)
 {
     Value = value.GetValue();
 }
示例#10
0
 public override void SetValue(IVariable <Camera> value)
 {
     Value = value.GetValue();
 }
示例#11
0
 public override void ApplyChange(IVariable <Camera> amount)
 {
     Value = amount.GetValue();
 }
示例#12
0
 // Applies AND operator
 public override void ApplyChange(IVariable <bool> value)
 {
     Value = Value && value.GetValue();
 }
示例#13
0
 public override void SetValue(IVariable <Vector3> value)
 {
     Value = value.GetValue();
 }
示例#14
0
        /// <summary>
        /// Make a new variable.
        /// Throws an ArgumentException if a variable with the given name already exists
        /// </summary>
        /// <param name="name"></param>
        /// <param name="var"></param>
        public void CreateVariable(string name, IVariable var)
        {
            variables.Add(name, var);
#if DEBUG
            Console.WriteLine(DEBUG_TAG + " Created new variable named \"" + name + "\" with value \"" + var.GetValue <object> ().ToString() + "\"");
#endif
        }