public override void ToWorkshop(WorkshopBuilder b, ToWorkshopContext context) { b.AppendKeyword(Localized ? "String" : "Custom String"); b.Append("(\"" + (Localized ? b.Kw(Value) : Value) + "\""); if (ParameterValues.Length > 0) { b.Append(", "); ParametersToWorkshop(b); } b.Append(")"); }
public void ToWorkshop(WorkshopBuilder builder) { string result = string.Empty; // Add a comment and newline if (Comment != null) { builder.AppendLine($"\"{Comment}\"\n"); } Value1.ToWorkshop(builder, ToWorkshopContext.ConditionValue); builder.Append(" "); CompareOperator.ToWorkshop(builder, ToWorkshopContext.Other); builder.Append(" "); Value2.ToWorkshop(builder, ToWorkshopContext.ConditionValue); builder.Append(";"); builder.AppendLine(); }
public virtual void ToWorkshop(WorkshopBuilder b, ToWorkshopContext context) { var action = Function as ElementJsonAction; if (action != null && (action.Indentation == "outdent" || action.Indentation == "drop")) { b.Outdent(); } // Add a comment and newline if (Comment != null) { b.AppendLine($"\"{Comment}\""); } // Add the disabled tag if the element is disabled. if (Function is ElementJsonAction && Disabled) { b.AppendKeyword("disabled").Append(" "); } // Add the name of the element. b.AppendKeyword(Function.Name); // Add the parameters. AddMissingParameters(); if (ParameterValues.Length > 0) { b.Append("("); ParametersToWorkshop(b); b.Append(")"); } if (action != null) { b.AppendLine(";"); if (action.Indentation == "indent" || action.Indentation == "drop") { b.Indent(); } } }
protected void ParametersToWorkshop(WorkshopBuilder b) { for (int i = 0; i < ParameterValues.Length; i++) { ParameterValues[i].ToWorkshop(b, ToWorkshopContext.NestedValue); if (i != ParameterValues.Length - 1) { b.Append(", "); } } }
public void ToWorkshop(WorkshopBuilder b, ToWorkshopContext context) { if (_keyword) { b.AppendKeyword(Value); } else { b.Append(Value); } }
public void ToWorkshop(WorkshopBuilder builder) { if (globalLimitReached || playerLimitReached || extGlobalLimitReached || extPlayerLimitReached) { List <string> collectionLimitsReached = new List <string>(); // Add names of the collections that exceed their variable limit. if (globalLimitReached) { collectionLimitsReached.Add("global"); } if (playerLimitReached) { collectionLimitsReached.Add("player"); } if (extGlobalLimitReached) { collectionLimitsReached.Add("ext. global"); } if (extPlayerLimitReached) { collectionLimitsReached.Add("ext. player"); } builder.AppendLine(string.Format( "// The {0} reached the variable limit. Only a maximum of 128 variables and 1000 extended variables can be assigned.", Extras.ListJoin("variable collection", collectionLimitsReached.ToArray()) )); builder.AppendLine(); } builder.AppendKeywordLine("variables"); builder.AppendLine("{"); builder.Indent(); builder.AppendKeyword("global"); builder.Append(":"); builder.AppendLine(); builder.Indent(); WriteCollection(builder, variableList(true)); builder.Unindent(); builder.AppendKeyword("player"); builder.Append(":"); builder.AppendLine(); builder.Indent(); WriteCollection(builder, variableList(false)); builder.Unindent(); builder.Unindent(); builder.AppendLine("}"); bool anyExtendedGlobal = ExtendedVariableList(true).Any(v => v != null); bool anyExtendedPlayer = ExtendedVariableList(false).Any(v => v != null); if (anyExtendedGlobal || anyExtendedPlayer) { builder.AppendLine(); builder.AppendLine($"// Extended collection variables:"); foreach (var ex in ExtendedVariableList(true)) { builder.AppendLine($"// global [{ex.Index}]: {ex.DebugName}"); } foreach (var ex in ExtendedVariableList(false)) { builder.AppendLine($"// player [{ex.Index}]: {ex.DebugName}"); } } }
public virtual void ToWorkshop(WorkshopBuilder b, ToWorkshopContext context) => b.Append(Name);
public void ToWorkshop(WorkshopBuilder builder) { if (Disabled) { builder.AppendKeyword("disabled") .Append(" "); } builder.AppendKeyword("rule") .AppendLine("(\"" + Name + "\")") .AppendLine("{") .AppendLine() .Indent() .AppendKeywordLine("event") .AppendLine("{") .Indent(); ElementRoot.Instance.GetEnumValue("Event", RuleEvent.ToString()).ToWorkshop(builder, ToWorkshopContext.Other); builder.Append(";").AppendLine(); // Add attributes. switch (RuleType) { case RuleType.PlayerBased: // Player based attributes ElementEnumMember.Team(Team).ToWorkshop(builder, ToWorkshopContext.Other); // Team attribute builder.Append(";").AppendLine(); ElementRoot.Instance.GetEnumValue("Player", Player.ToString()).ToWorkshop(builder, ToWorkshopContext.Other); // Player attribute builder.Append(";").AppendLine(); break; case RuleType.Subroutine: Subroutine.ToWorkshop(builder, ToWorkshopContext.Other); // Attribute name builder.Append(";").AppendLine(); break; } builder.Outdent() .AppendLine("}"); if (Conditions?.Length > 0) { builder.AppendLine() .AppendKeywordLine("conditions") .AppendLine("{") .Indent(); foreach (var condition in Conditions) { condition.ToWorkshop(builder); } builder.Outdent().AppendLine("}"); } // Add actions. if (Actions?.Length > 0) { builder.AppendLine() .AppendLine("// Action count: " + Actions.Length) // Action count comment. .AppendKeywordLine("actions") .AppendLine("{") .Indent(); foreach (var action in Actions) { action.ToWorkshop(builder, ToWorkshopContext.Action); } builder.Outdent().AppendLine("}"); } builder.Outdent().AppendLine("}"); }