public void FromActionRow(Actions.ActionRow actionRow) { if (!actionRow.IsIDNull()) { ID = Convert.ToInt32(actionRow.ID); } if (!actionRow.IsAllyActionNull()) { AllyAction = Convert.ToInt32(actionRow.AllyAction); } if (!actionRow.IsAxisActionNull()) { AxisAction = Convert.ToInt32(actionRow.AxisAction); } if (!actionRow.IsRadiusNull()) { Radius = Convert.ToInt32(actionRow.Radius); } if (!actionRow.IsGoalNull()) { Goal = Convert.ToInt32(actionRow.Goal); } if (!actionRow.IsGroupNull()) { Group = Convert.ToInt32(actionRow.Group); } if (!actionRow.IsClassNull()) { Class = Convert.ToInt32(actionRow.Class); } if (!actionRow.IsCloseNodeNull()) { CloseNode = Convert.ToInt32(actionRow.CloseNode); } if (!actionRow.IsLinksNull()) { Links = actionRow.Links; } if (!actionRow.IsProneNull()) { Prone = Convert.ToInt32(actionRow.Prone); } if (!actionRow.IsActiveNull()) { Active = Convert.ToInt32(actionRow.Active); } if (!actionRow.IsEntityNull()) { Entity = Convert.ToInt32(actionRow.Entity); } }
public static void WriteActions(string fileName, Actions actions) { fileName = GetActionFile(fileName); StringBuilder buff = new StringBuilder(); StringBuilder execBuff = new StringBuilder(); int startNode = 0; int endNode = 99; int count = 0; foreach (DataRow row in actions.Action.Rows) { Actions.ActionRow actionRow = (Actions.ActionRow)row; if (actionRow.ID == null) { continue; } // action_axis if (!actionRow.IsAxisActionNull()) { buff.Append("action_axis " + actionRow.ID + " " + actionRow.AxisAction + ";"); } else { buff.Append("action_axis " + actionRow.ID + " -1;"); } // action_allies if (!actionRow.IsAllyActionNull()) { buff.Append("action_allies " + actionRow.ID + " " + actionRow.AllyAction + ";"); } else { buff.Append("action_allies " + actionRow.ID + " -1;"); } if (!actionRow.IsCloseNodeNull()) { buff.Append("action_closenode " + actionRow.ID + " " + actionRow.CloseNode + ";"); } if (!actionRow.IsEntityNull()) { buff.Append("action_ent " + actionRow.ID + " " + actionRow.Entity + ";"); } if (!actionRow.IsRadiusNull()) { buff.Append("action_radius " + actionRow.ID + " " + actionRow.Radius + ";"); } if (!actionRow.IsGoalNull()) { buff.Append("action_goal " + actionRow.ID + " " + actionRow.Goal + ";"); } if (!actionRow.IsGroupNull()) { buff.Append("action_group " + actionRow.ID + " " + actionRow.Group + ";"); } if (!actionRow.IsActiveNull()) { buff.Append("action_active " + actionRow.ID + " " + actionRow.Active + ";"); } if (!actionRow.IsClassNull()) { buff.Append("action_class " + actionRow.ID + " " + actionRow.Class + ";"); } if (!actionRow.IsLinksNull()) { buff.Append("action_links " + actionRow.ID + " " + actionRow.Links + ";"); } if (!actionRow.IsProneNull()) { buff.Append("action_prone " + actionRow.ID + " " + actionRow.Prone + ";"); } buff.Append("\r\n"); count++; if (count > endNode) { string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + endNode + ".cfg"; WriteConfig(subConfigFileName, buff); buff = new StringBuilder(); startNode = endNode + 1; endNode = startNode + 99; execBuff.Append("exec " + subConfigFileName + "\r\n"); } } if (buff.Length > 0) { string subConfigFileName = fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + startNode + "_" + (count - 1) + ".cfg"; WriteConfig(subConfigFileName, buff); execBuff.Append("exec " + subConfigFileName + "\r\n"); } WriteConfig(fileName, execBuff); }
private bool IsActionValid(Actions.ActionRow actionRow) { bool isValid = true; StringBuilder msg = new StringBuilder(); string id = ""; string allyAction = ""; string axisAction = ""; string ent = ""; string linked = ""; string classNum = ""; if (!actionRow.IsIDNull()) { id = Convert.ToString(actionRow["ID"]); } if (!actionRow.IsAllyActionNull()) { allyAction = Convert.ToString(actionRow["AllyAction"]); } if (!actionRow.IsAxisActionNull()) { axisAction = Convert.ToString(actionRow["AxisAction"]); } if (!actionRow.IsEntityNull()) { ent = Convert.ToString(actionRow["Entity"]); if (ent == "1023") { ent = ""; // default } if (ent == "-1") { ent = ""; // shouldn't be -1 } } if (!actionRow.IsLinksNull()) { linked = Convert.ToString(actionRow["Links"]); } if (!actionRow.IsClassNull()) { classNum = Convert.ToString(actionRow["Class"]); } if ((allyAction == "-1" || allyAction == "") && (axisAction == "-1" || axisAction == "")) { msg.Append("Action " + id + " has no valid ally or axis actions.\r\n"); isValid = false; } if (ent == "") { if (_entityActions.ContainsKey(allyAction)) { msg.Append("Action " + id + " is an " + _entityActions[allyAction] + " action with no entity.\r\n"); isValid = false; } if (_entityActions.ContainsKey(axisAction)) { msg.Append("Action " + id + " is an " + _entityActions[axisAction] + " action with no entity.\r\n"); isValid = false; } } if (_campActions.ContainsKey(allyAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // check to see if the action exists!!! if (ndx > _actions.Action.Count - 1) { msg.Append("Action " + id + " has link to an action that doesn't exist [" + ndx + "]"); isValid = false; } else { Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAllyActionNull() || linkedAction.AllyAction != "3") { msg.Append("Action " + id + " is an ally " + _campActions[allyAction] + " with an invalid link to Action " + links[x] + " (either no ally action or an ally action that is not an Aim action)\r\n"); isValid = false; } } } } } if (_campActions.ContainsKey(axisAction)) { if (linked.Trim() == "") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with no links.\r\n"); isValid = false; } else { // check the links string[] links = linked.Split(new char[] { ' ' }); for (int x = 0; x < links.Length; x++) { int ndx = Convert.ToInt32(links[x]); // the axis action should be 3 Actions.ActionRow linkedAction = _actions.Action[ndx]; // we don't allow sorting, so this is ok if (linkedAction.IsAxisActionNull() || linkedAction.AxisAction != "3") { msg.Append("Action " + id + " is an axis " + _campActions[axisAction] + " with an invalid link to Action " + links[x] + " (either no axis action or an axis action that is not an Aim action)\r\n"); isValid = false; } } } } if (!isValid) { MessageBox.Show(this.ParentForm, msg.ToString(), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(isValid); }