public FrameFurniture(string read_in) { string[] split = read_in.Split('|'); string[] size_split = split[0].Split(','); split = Acc.get_inner_parenthesis(split[1]).Split(','); width = byte.Parse(size_split[0]); height = byte.Parse(size_split[1]); images = new int[split.Length]; for (int x = 0; x < images.Length; x++) { images[x] = int.Parse(split[x]); } }
public BodyTemplate(System.IO.StreamReader r, int template_num) { body_template_id = template_num; BodypartTemplate temp = new BodypartTemplate(); parts_list = new List <BodypartTemplate>(); skins = new List <Color>(); string line = ""; bool cont = true; while (cont) { line = r.ReadLine(); if (line.Trim() == "" || line[0] == '#') { //skip this line } else { string[] items = line.Split(':'); switch (items[0].ToLower()) { case "color": if (items[1].ToLower() == "none") { temp.no_color = true; } break; case "skins": string[] colors = items[1].Split(';'); for (int i = 0; i < colors.Length; i++) { string[] comps = colors[i].Split(','); skins.Add(Color.FromNonPremultiplied(byte.Parse(comps[0]), byte.Parse(comps[1]), byte.Parse(comps[2]), 255)); } break; case "body": template_name = items[1]; break; case "size": string[] tdim = Acc.script_remove_outer_parentheses(items[1]).Split(','); size_body = new Rectangle(int.Parse(tdim[0]) / -2, int.Parse(tdim[1]) / -2, int.Parse(tdim[0]), int.Parse(tdim[1])); break; case "num-torsos": num_torsos = Int32.Parse(items[1]); break; case "endbody": parts_list.Add(temp); num_parts++; cont = false; break; case "part": if (temp.name == "") { //first time... already default temp.name = items[1]; } else { //not the first time, add to stack, then default the temp and give it it's name. parts_list.Add(temp); num_parts++; temp = new BodypartTemplate(); temp.name = items[1]; } break; case "angle": if (items[1].Contains("CLICKMOUSE")) { temp.click_active_mouse = true; temp.angle_follow_mouse = true; if (items[1].Length > 10) { items[1] = items[1].Remove(items[1].IndexOf("CLICKMOUSE"), 10); temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0); } } else if (items[1].Contains("MOUSE")) { temp.angle_follow_mouse = true; if (items[1].Length > 5) { items[1] = items[1].Remove(items[1].IndexOf("MOUSE"), 5); temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0); } } else if (items[1].Contains("PARENT")) { temp.angle_follow_parent = true; if (items[1].Length > 6) { items[1] = items[1].Remove(items[1].IndexOf("PARENT"), 6); temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0); } } else if (items[1].Contains("WALKING")) { char[] split = { '+', '-' }; string[] codes = items[1].Split(split); temp.angle_walking_id = Int32.Parse(codes[0].Substring(codes[0].IndexOf("WALKING") + 7)); if (codes.Length > 1) { temp.angle_offset = Acc.resolve_die_roll(codes[1], 0, 0); } } else { temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0); } break; case "draw-order": temp.draw_order = Int32.Parse(items[1]); break; case "images": items = items[1].Split(';'); Rectangle temp_rect = new Rectangle(); ChildPinPicture t = new ChildPinPicture(); for (int x = 0; x < items.Length; x++) { if (items[x].Contains('=')) { //this is setup to be a child, it has an attachment point. string[] sub_inner = items[x].Split('='); string[] inner = Acc.get_inner_parenthesis(sub_inner[0]).Split(','); temp_rect = new Rectangle(Int32.Parse(inner[0]), Int32.Parse(inner[1]), Int32.Parse(inner[2]), Int32.Parse(inner[3])); sub_inner = Acc.get_inner_parenthesis(sub_inner[1]).Split(','); t.image = temp_rect; t.child_loc = new Point(Int32.Parse(sub_inner[0]), Int32.Parse(sub_inner[1])); temp.images.Add(t); } else { //this is not a child, no attachment point. string[] inner = Acc.get_inner_parenthesis(items[x]).Split(','); temp_rect = new Rectangle(Int32.Parse(inner[0]), Int32.Parse(inner[1]), Int32.Parse(inner[2]), Int32.Parse(inner[3])); t.image = temp_rect; t.child_loc = new Point(0, 0); temp.images.Add(t); } } break; case "child": items = items[1].Split(';'); //Left Arm;attach(14,5) ParentBrassPin temp_child = new ParentBrassPin(); temp_child.child_name = items[0]; items = Acc.get_inner_parenthesis(items[1]).Split(','); temp_child.parent_loc = new Point(Int32.Parse(items[0]), Int32.Parse(items[1])); temp.children.Add(temp_child); break; } } if (r.EndOfStream) { cont = false; } } }
public ItemManager() { item_pieces = new List <ItemPiece>(); custom_item_images = new Dictionary <int, Texture2D>(); if (System.IO.File.Exists(@"item_pieces.txt")) { System.IO.StreamReader r = new System.IO.StreamReader(@"item_pieces.txt"); string line = ""; ItemPiece p = new ItemPiece(); bool cont = true; while (cont) { line = r.ReadLine(); if (line[0] == '#') { //skip this line } else { string[] items = line.Split(':'); switch (items[0]) { case "PIECE": if (p.name == "") { p.name = items[1]; } else { item_pieces.Add(p); Exilania.text_stream.WriteLine("Item Piece '" + p.name + "' Loaded."); p = new ItemPiece(); p.name = items[1]; } break; case "IMAGE": items = Acc.get_inner_parenthesis(items[1]).Split(','); p.image = new Rectangle(Int32.Parse(items[0]), Int32.Parse(items[1]), Int32.Parse(items[2]), Int32.Parse(items[3])); break; case "HAND-ATTACH": items = items[1].Split(','); p.hand_attach_point = new Point(Int32.Parse(items[0]), Int32.Parse(items[1])); p.has_hand_attach_point = true; break; case "ATTACH-POINT": items = Acc.get_inner_parenthesis(items[1]).Split(','); p.item_attach_points.Add(new Point(Int32.Parse(items[0]), Int32.Parse(items[1]))); break; case "CLICK": p.click_action += items[1]; break; case "DATA": items = items[1].Split('='); p.data.Add(items[0], items[1]); break; case "BREAK-BLOCK": items = items[1].Split(';'); for (int x = 0; x < items.Length; x++) { if (items[x] != "") { string[] mitems = items[x].Split('='); int key = BlockData.block_enum[mitems[0]]; int value = Int32.Parse(mitems[1]); if (p.break_block.ContainsKey(key)) { p.break_block[key] = Math.Min(p.break_block[key], value); } else { p.break_block.Add(key, value); } } } if (items.Length > 0) { p.break_block.Add(BlockData.block_enum["SINGLE"], 0); } break; case "MATERIAL": items = items[1].Split(';'); for (int x = 0; x < items.Length; x++) { if (items[x] != "") { string[] mitems = items[x].Split('='); string key = mitems[0]; int value = Int32.Parse(mitems[1]); if (p.materials.ContainsKey(key)) { p.materials[key] = Math.Min(p.materials[key], value); } else { p.materials.Add(key, value); } } } break; case "CRAFT-REQUIRE": if (items[1].Trim().ToLower() != "none") { p.craft_require = items[1].Trim().ToLower(); } break; case "COMPLEXITY": p.complexity = int.Parse(items[1]); break; case "WORTH": p.worth = int.Parse(items[1]); break; default: Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]); break; } } if (r.EndOfStream) { item_pieces.Add(p); Exilania.text_stream.WriteLine("Item Piece '" + p.name + "' Loaded."); cont = false; } } r.Close(); } else { Exilania.text_stream.Write("ERROR! NO ITEM PIECES DEFINING items...."); } }