public bool check_is_recipe_valid(CraftRecipe r, Actor a, World w) { for (int x = 0; x < r.input.Count; x++) { item_descriptor t = Acc.get_item_by_name(r.input[x].Key); if (t.item_type == ItemType.Empty || t.item_id == -1 || !a.items.has_item(t.item_type, t.item_id, r.input[x].Value)) { return(false); } } for (int x = 0; x < r.furniture_require.Length; x++) { bool contained = false; for (int i = 0; i < id_nearby_furniture.Count; i++) { if (Exilania.furniture_manager.furniture[w.furniture[id_nearby_furniture[i]].furniture_id].name.ToLower() == r.furniture_require[x].ToLower()) { contained = true; } } if (!contained) { return(false); } } return(true); }
public void take_item_requirements(CraftRecipe r, Actor a, World w) { for (int x = 0; x < r.input.Count; x++) { item_descriptor t = Acc.get_item_by_name(r.input[x].Key); if (t.item_type != ItemType.Empty && t.item_id != -1) { a.items.use_item(a, t.item_type, t.item_id, r.input[x].Value); } } }
public CraftPieceInterface() { cur_available_crafts = new List <CraftRecipe>(); first_show = 0; last_time_updated = System.DateTime.Now.Ticks / 10000; last_time_bought = last_time_updated = last_scroll_frame; id_nearby_furniture = new List <int>(); infos = new List <KeyValuePair <string, Vector2> >(); draw_size = new Point(); infos_item_type = new item_descriptor(); infos_item_type.item_type = ItemType.Empty; }
/// <summary> /// returns an item by name in the matching sets of /// item_pieces /// furniture /// materials /// blocks /// </summary> /// <param name="name"></param> /// <returns></returns> public static item_descriptor get_item_by_name(string name) { name = name.Trim().ToLower(); item_descriptor t = new item_descriptor(); for (int x = 0; x < Exilania.block_types.blocks.Count; x++) { if (Exilania.block_types.blocks[x].name.Trim().ToLower() == name) { t.item_type = ItemType.Block; t.item_id = x; return(t); } } for (int x = 0; x < Exilania.furniture_manager.furniture.Count; x++) { if (Exilania.furniture_manager.furniture[x].name.Trim().ToLower() == name) { t.item_id = x; t.item_type = ItemType.Furniture; return(t); } } for (int x = 0; x < Exilania.item_manager.item_pieces.Count; x++) { if (Exilania.item_manager.item_pieces[x].name.Trim().ToLower() == name) { t.item_type = ItemType.ItemPiece; t.item_id = x; return(t); } } for (int x = 0; x < Exilania.material_manager.materials.Count; x++) { if (Exilania.material_manager.materials[x].name.Trim().ToLower() == name) { t.item_id = x; t.item_type = ItemType.Material; return(t); } } t.item_type = ItemType.Empty; t.item_id = -1; return(t); }
public string modify_settings(string new_setting, World w) { string returner = "@07"; string[] items = new_setting.Split(':'); if (items.Length > 2) { for (int i = 2; i < items.Length; i++) { items[1] += ":" + items[i]; } } if (items.Length > 1 && items[1].Length > 0) { switch (items[0]) { case "mastervolume": if (items[1].Contains('.')) { Exilania.sounds.master_volume = float.Parse(items[1]); } else { Exilania.sounds.master_volume = ((float)int.Parse(items[1])) / 100f; } if (Exilania.sounds.master_volume < 0f) { Exilania.sounds.master_volume = 0f; } if (Exilania.sounds.master_volume > 1f) { Exilania.sounds.master_volume = 1f; } returner += "@07Master Volume set to " + (Exilania.sounds.master_volume * 100) + "."; break; case "give": if (w != null && Exilania.game_my_user_id < w.players.Count && w.players.Count > 0) { string[] info = items[1].Split(':'); ushort quantity = 10; item_descriptor cur_item = Acc.get_item_by_name(info[0]); if (info.Length >= 2) { try { quantity = ushort.Parse(info[1]); } catch { quantity = 10; } } if (cur_item.item_id > -1) { switch (cur_item.item_type) { case ItemType.Block: w.players[Exilania.game_my_user_id].avatar.items.pickup_block((sbyte)cur_item.item_id, quantity); returner += info[0] + " qauntity " + quantity + " given."; break; case ItemType.Material: w.players[Exilania.game_my_user_id].avatar.items.pickup_material((sbyte)cur_item.item_id, quantity); returner += info[0] + " qauntity " + quantity + " given."; break; case ItemType.Furniture: w.players[Exilania.game_my_user_id].avatar.items.pickup_furniture((sbyte)cur_item.item_id, quantity); returner += info[0] + " qauntity " + quantity + " given."; break; default: returner += "@08Feature not added, yet."; break; } } else { returner += "@08What is a '" + info[0] + "'?"; } } else { returner += "@08Start a game first."; } break; case "eval": int val_get = Acc.resolve_die_roll(items[1], 0, 0); returner += items[1] + "= " + val_get; break; case "time": if (w != null) { try { if (Exilania.game_server) { items = items[1].Split(':'); int minutes = 0; int hours = 0; if (items.Length > 1) { minutes = int.Parse(items[1]); if (minutes < 10) { minutes *= 10; } minutes %= 60; } hours = int.Parse(items[0]) % 24; int cur_day = (int)(w.world_time / w.day_length); cur_day++; w.world_time = (float)cur_day * w.day_length; w.world_time += ((float)hours - 6) / 24f * w.day_length; Exilania.display.add_message("@00Hour Debug: " + ((float)hours) / 24f); w.world_time += ((float)minutes) / 1440f * w.day_length; returner += "Time set to " + hours.ToString().PadLeft(2, '0') + ":" + minutes.ToString().PadLeft(2, '0') + "."; } else { returner += "@06Admin access only."; } } catch { returner += "@06Unsupported time format please use HH:MM (24H Clock)"; } } else { returner += "@06FOR USE ONLY IN-GAME."; } break; case "liquiddebugging": try { liquid_debugging = bool.Parse(items[1]); returner += "Liquid Debugging set to " + liquid_debugging.ToString() + "."; } catch { liquid_debugging = false; returner += "@06Improper Formatting. Liquid Debugging set to false.@07"; } break; case "highdefwindowheight": try { highdef_window_size.Y = int.Parse(items[1]); returner += "HighDef Window Height set to " + highdef_window_size.Y.ToString() + "."; } catch { highdef_window_size.Y = 1000; returner += "@06Improper Formatting. HighDef Window Height set to 1000.@07"; } break; case "highdefwindowwidth": try { highdef_window_size.X = int.Parse(items[1]); returner += "HighDef Window Width set to " + highdef_window_size.X.ToString() + "."; } catch { highdef_window_size.X = 2600; returner += "@06Improper Formatting. HighDef Window Width set to 2600.@07"; } break; case "msecshowchat": try { msec_show_chat = int.Parse(items[1]); returner += "Msec show chat now set to " + msec_show_chat.ToString() + "ms."; Display.show_received_chat_time = (float)msec_show_chat / 1000f; } catch { msec_show_chat = 5000; Display.show_received_chat_time = (float)msec_show_chat / 1000f; returner += "@06Improper Formatting. Msec show chat set to 5000.@07"; } break; case "showchatbackground": try { show_chat_background = bool.Parse(items[1]); returner += "Show Chat Background now set to " + show_chat_background.ToString() + "."; } catch { show_chat_background = true; returner += "@06Improper Formatting. Show Chat Background set to true.@07"; } break; case "max_users": try { int temp = int.Parse(items[1]); if (temp > 255) { temp = 255; } max_users = (byte)temp; returner += "Max Users now set to " + max_users.ToString() + "."; } catch { max_users = 32; returner += "@06Improper Formatting. Max Users now set to 32.@07"; } break; case "forcenewcharacter": try { force_new_character = Boolean.Parse(items[1]); returner += "Force New Character now set to " + force_new_character.ToString() + "."; } catch { force_new_character = false; returner += "@06Improper Formatting. Force New Character now set to False.@07"; } break; case "allowstrobe": try { allow_strobe = Boolean.Parse(items[1]); returner += "Strobing Text now set to " + allow_strobe.ToString() + "."; } catch { allow_strobe = false; returner += "@06Improper Formatting. Strobing Text now set to False.@07"; } break; case "use_seed": use_seed = Boolean.Parse(items[1]); returner += "use seed now set to " + use_seed.ToString() + ". Rand reset."; if (use_seed) { Exilania.rand = new Lidgren.Network.NetRandom(seed_id); } else { Exilania.rand = new Lidgren.Network.NetRandom((int)System.DateTime.Now.Ticks); } break; case "seed_id": try { seed_id = Int32.Parse(items[1]); } catch { seed_id = 10; returner += "@06Improper Formatting. @07"; } returner += "random seed now set to " + seed_id.ToString() + ","; if (use_seed) { Exilania.rand = new Lidgren.Network.NetRandom(seed_id); returner += " Rand reset."; } break; case "debugging": try { debugging = Boolean.Parse(items[1]); } catch { returner += "@06Improper Formatting. @07"; debugging = false; } Exilania.draw_debug = debugging; returner += "Debug changed to " + debugging.ToString() + "."; break; case "levelupheal": levelupheal = Int32.Parse(items[1]); returner += "Levelupheal changed to " + levelupheal.ToString() + "."; break; case "serveripaddress": server_ip = items[1]; returner += "serveripaddress changed to " + server_ip + "."; break; case "serverport": try { server_port = UInt16.Parse(items[1]); } catch { server_port = 50231; } returner += "serverport changed to " + server_port.ToString() + "."; break; case "clientport": try { client_port = UInt16.Parse(items[1]); } catch { client_port = 50232; } returner += "clientport changed to " + client_port.ToString() + "."; break; case "help": returner += "@05Use commands found in the Exilania.ini text file to commit changes."; break; case "usecustomdimensions": try { use_custom_dimensions = Boolean.Parse(items[1]); returner += " usecustomdimensions changed to " + use_custom_dimensions.ToString() + "."; } catch { returner += "@06Improper Formatting! @07"; use_custom_dimensions = false; } break; case "customwidth": try { custom_width = Int32.Parse(items[1]); returner += "customwidth set to " + custom_width.ToString() + "."; } catch { custom_width = 1920; returner += "@06Improper Formatting! @07"; } break; case "customheight": try { custom_height = Int32.Parse(items[1]); returner += "customheight set to " + custom_height.ToString() + "."; } catch { custom_height = 1080; returner += "@06Improper Formatting! @07"; } break; case "usehardwarelighting": try { use_hardware_lighting = Boolean.Parse(items[1]); returner += "Use Hardware lighting set to " + use_hardware_lighting.ToString() + "."; } catch { use_hardware_lighting = false; returner += "@06Improper Formatting; Use Hardware Lighting set to false."; } break; case "worldloadname": try { world_load_name = items[1]; returner += "World to load changed to " + world_load_name + "."; } catch { world_load_name = "Default World 1"; returner += "@06Improper Formatting; World to Load now 'Default World 1'."; } break; case "showping": try { show_ping = bool.Parse(items[1]); returner += "Show Ping changed to " + show_ping + "."; } catch { show_ping = true; returner = "@06Improper Formatting; Show Ping set to true."; } break; default: returner += "@05unrecognized command. @06'/" + new_setting + "'@05."; break; } } else { returner += "@05Missing command parameters for command @06'" + items[0] + "'@05."; } return(returner); }
public CraftManager() { recipes = new List <CraftRecipe>(); if (System.IO.File.Exists(@"craft_recipes.txt")) { System.IO.StreamReader r = new System.IO.StreamReader(@"craft_recipes.txt"); string line = ""; CraftRecipe p = new CraftRecipe(); bool cont = true; while (cont) { line = r.ReadLine().Trim(); if (line.Length == 0 || line[0] == '#') { //skip this line } else { string[] items = line.Split(':'); switch (items[0].ToLower()) { case "name": if (p.name == "") { p.name = items[1].Trim(); } else { p.crafting_id = (ushort)recipes.Count; recipes.Add(p); Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded."); p = new CraftRecipe(); p.name = items[1].Trim(); } break; case "output": items = items[1].Split(','); for (int i = 0; i < items.Length; i++) { item_descriptor t = Acc.get_item_by_name(Acc.script_remove_content_of_outer_parenthesis(items[i])); Output_Type pr = new Output_Type(t.item_type, t.item_id, int.Parse(Acc.script_remove_outer_parentheses(items[i]))); p.output.Add(pr); } break; case "input": items = items[1].Split(','); for (int x = 0; x < items.Length; x++) { p.input.Add(new KeyValuePair <string, int>(Acc.script_remove_content_of_outer_parenthesis(items[x]), int.Parse(Acc.script_remove_outer_parentheses(items[x])))); } break; case "complexity": p.complexity = int.Parse(items[1]); break; case "furniture-require": items = items[1].Split(','); p.furniture_require = new string[items.Length]; for (int x = 0; x < items.Length; x++) { p.furniture_require[x] = items[x]; } break; default: Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]); break; } } if (r.EndOfStream) { p.crafting_id = (ushort)recipes.Count; recipes.Add(p); Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded."); cont = false; } } r.Close(); for (int x = 0; x < Exilania.item_manager.item_pieces.Count; x++) { p = new CraftRecipe(); p.name = Exilania.item_manager.item_pieces[x].name; p.output.Add(new Output_Type(ItemType.ItemPiece, x, 1)); if (Exilania.item_manager.item_pieces[x].craft_require != "") { p.furniture_require = Exilania.item_manager.item_pieces[x].craft_require.Split(','); } else { p.furniture_require = new string[0]; } if (Exilania.item_manager.item_pieces[x].materials.Count > 0) { foreach (var mats in Exilania.item_manager.item_pieces[x].materials) { p.input.Add(new KeyValuePair <string, int>(mats.Key, mats.Value)); } } p.complexity = Exilania.item_manager.item_pieces[x].complexity; p.crafting_id = (ushort)recipes.Count; recipes.Add(p); Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded."); } for (int x = 0; x < Exilania.furniture_manager.furniture.Count; x++) { p = new CraftRecipe(); p.name = Exilania.furniture_manager.furniture[x].name; p.output.Add(new Output_Type(ItemType.Furniture, x, 1)); if (Exilania.furniture_manager.furniture[x].craft_require.Length > 0) { p.furniture_require = Exilania.furniture_manager.furniture[x].craft_require; } if (Exilania.furniture_manager.furniture[x].materials.Count > 0) { foreach (var mats in Exilania.furniture_manager.furniture[x].materials) { p.input.Add(new KeyValuePair <string, int>(mats.Key, mats.Value)); } } p.complexity = Exilania.furniture_manager.furniture[x].complexity; p.crafting_id = (ushort)recipes.Count; recipes.Add(p); Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded."); } } else { Exilania.text_stream.Write("ERROR! No craft_recipes.txt file."); } }
public void give_items(Actor a, int replicate) { bool match_found = false; for (int x = 0; x < replicate; x++) { foreach (var pair in Exilania.plant_manager.plants[plant_index].drops) { if (Exilania.rand.Next(0, 101) <= pair.Value) { item_descriptor t = Acc.get_item_by_name(pair.Key); switch (t.item_type) { case ItemType.Block: a.items.pickup_block((sbyte)t.item_id); match_found = false; for (int i = 0; i < gives.Count; i++) { if (gives[i].type == ItemType.Block && gives[i].id == t.item_id) { match_found = true; gives[i].count++; i = gives.Count; } } if (!match_found) { gives.Add(new DisplayGive(1, ItemType.Block, t.item_id)); } break; case ItemType.Empty: break; case ItemType.Furniture: a.items.pickup_furniture(t.item_id, 1); match_found = false; for (int i = 0; i < gives.Count; i++) { if (gives[i].type == ItemType.Furniture && gives[i].id == t.item_id) { match_found = true; gives[i].count++; i = gives.Count; } } if (!match_found) { gives.Add(new DisplayGive(1, ItemType.Furniture, t.item_id)); } break; case ItemType.ItemPiece: Item temp = new Item(); temp.add_piece(Exilania.item_manager.item_pieces[t.item_id], t.item_id, -1, 0, 0, 0); temp.construct_item(Exilania.item_manager.item_pieces[t.item_id].name); a.items.pickup_item(temp); match_found = false; for (int i = 0; i < gives.Count; i++) { if (gives[i].type == ItemType.ItemPiece && gives[i].id == t.item_id) { match_found = true; gives[i].count++; i = gives.Count; } } if (!match_found) { gives.Add(new DisplayGive(1, ItemType.ItemPiece, t.item_id)); } break; case ItemType.Material: a.items.pickup_material(t.item_id, 1); match_found = false; for (int i = 0; i < gives.Count; i++) { if (gives[i].type == ItemType.Material && gives[i].id == t.item_id) { match_found = true; gives[i].count++; i = gives.Count; } } if (!match_found) { gives.Add(new DisplayGive(1, ItemType.Material, t.item_id)); } break; } //give item to player! } } } }