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()); } } }
/// <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); } }
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); }
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); }
/// <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); } }
public override void SetValue(IVariable <int> value) { Value = value.GetValue(); }
public override void ApplyChange(IVariable <int> amount) { Value += amount.GetValue(); }
public override void SetValue(IVariable <KeyCode> value) { Value = value.GetValue(); }
public override void ApplyChange(IVariable <KeyCode> value) { Value = value.GetValue(); }
public override void SetValue(IVariable <Camera> value) { Value = value.GetValue(); }
public override void ApplyChange(IVariable <Camera> amount) { Value = amount.GetValue(); }
// Applies AND operator public override void ApplyChange(IVariable <bool> value) { Value = Value && value.GetValue(); }
public override void SetValue(IVariable <Vector3> value) { Value = value.GetValue(); }
/// <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 }