Example #1
0
        /// <summary>
        /// pass in something like this: 2,2|(990,991,1022,1023)|24,24|ROTATEFAST
        /// </summary>
        /// <param name="info"></param>
        public FrameFacet(string info)
        {
            string[] pieces   = info.Split('|');
            string[] subpiece = pieces[0].Split(',');
            width    = byte.Parse(subpiece[0]);
            height   = byte.Parse(subpiece[1]);
            subpiece = Acc.script_remove_outer_parentheses(pieces[1]).Split(',');
            images   = new int[subpiece.Length];
            for (int i = 0; i < images.Length; i++)
            {
                images[i] = int.Parse(subpiece[i]);
            }
            subpiece     = pieces[2].Split(',');
            attach_point = new Point(int.Parse(subpiece[0]), int.Parse(subpiece[1]));
            if (pieces.Length == 4)
            {
                center_of_rotation = new Point(0, 0);
                rotation_type      = (FACETTRACKERS)Enum.Parse(typeof(FACETTRACKERS), pieces[3]);
            }
            else
            {
                subpiece             = pieces[3].Split(',');
                center_of_rotation   = new Point(int.Parse(subpiece[0]), int.Parse(subpiece[1]));
                center_of_rotation.X = width * 12 - center_of_rotation.X;
                center_of_rotation.Y = height * 12 - center_of_rotation.Y;

                rotation_type = (FACETTRACKERS)Enum.Parse(typeof(FACETTRACKERS), pieces[4]);
            }
        }
Example #2
0
        public bool apply_use_action(World w, Point world_loc)
        {
            if (use_action == "")
            {
                return(false);
            }

            string command = Acc.script_remove_content_of_outer_parenthesis(use_action);
            string passed  = Acc.script_remove_outer_parentheses(use_action).ToLower();

            switch (command.Trim().ToLower())
            {
            case "plant":
                if (Exilania.plant_manager.spawn_plant_in_world(w, world_loc, passed))
                {
                    if (!Exilania.game_server)
                    {
                        Exilania.network_client.send_place_plant(w, w.plants.Count - 1);
                    }
                    return(true);
                }
                break;
            }


            return(false);
        }
Example #3
0
 public PlantPiece(string vals)
 {
     string[] halves = vals.Split('|');
     halves[0] = halves[0].Trim();
     halves[1] = halves[1].Trim();
     string[] pair = halves[0].Split('=');
     name = pair[0];
     pair = pair[1].Split(',');
     if (pair[0].Contains('-'))
     { //variable width
         string[] temp = pair[0].Split('-');
         width_min = int.Parse(temp[0]);
         width_max = int.Parse(temp[1]);
         if (width_max < width_min)
         {
             int t2 = width_min;
             width_min = width_max;
             width_max = t2;
         }
     }
     else
     { //non variable width
         width_max = int.Parse(pair[0]);
         width_min = width_max;
     }
     if (pair[1].Contains('-'))
     { //variable height
         string[] temp = pair[1].Split('-');
         height_min = int.Parse(temp[0]);
         height_max = int.Parse(temp[1]);
         if (height_max < height_min)
         {
             int t2 = height_min;
             height_min = height_max;
             height_max = t2;
         }
     }
     else
     { //non variable height
         height_max = int.Parse(pair[1]);
         height_min = height_max;
     }
     //interpret half 1 now!, the images.
     if (Acc.script_remove_content_of_outer_parenthesis(halves[1]).ToLower() == "rand")
     {
         random_images = true;
     }
     halves[1] = Acc.script_remove_outer_parentheses(halves[1]);
     halves    = halves[1].Split(',');
     images    = new int[halves.Length];
     for (int x = 0; x < halves.Length; x++)
     {
         images[x] = int.Parse(halves[x]);
     }
 }
Example #4
0
        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;
                }
            }
        }
Example #5
0
        public PlantManager()
        {
            plants = new List <PlantData>();
            if (System.IO.File.Exists(@"plants.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"plants.txt");
                string    line           = "";
                PlantData p    = new PlantData();
                bool      cont = true;
                while (cont)
                {
                    line = r.ReadLine();
                    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();
                                p.plant_id = 0;
                            }
                            else
                            {
                                p.plant_id = (ushort)plants.Count;
                                p.get_height_range();
                                plants.Add(p);
                                Exilania.text_stream.WriteLine("Plant Item '" + p.name + "' Loaded.");
                                p      = new PlantData();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "drops":
                            string[] pieces = items[1].Trim().Split(',');
                            if (items[1].Trim() != "")
                            {
                                for (int x = 0; x < pieces.Length; x++)
                                {
                                    pieces[x] = pieces[x].Trim();
                                    string key = Acc.script_remove_content_of_outer_parenthesis(pieces[x]);
                                    byte   val = byte.Parse(Acc.script_remove_outer_parentheses(pieces[x]));
                                    p.drops.Add(key, val);
                                }
                            }
                            break;

                        case "piece":
                            p.pieces.Add(new PlantPiece(items[1]));
                            break;

                        case "anatomy":
                            p.anatomy = items[1].Trim().Split(',');
                            break;

                        case "growson":
                            items = items[1].Trim().Split(',');
                            for (int x = 0; x < items.Length; x++)
                            {
                                if (items[x].Length > 0)
                                {
                                    p.grows_on.Add(items[x].Trim().ToLower());
                                }
                            }
                            break;

                        case "behavior-cut":
                            p.behavior_cut = items[1].Trim();
                            break;

                        case "min-distance":
                            p.min_distance = Int32.Parse(items[1]);
                            break;

                        case "density":
                            p.density = Int32.Parse(items[1]);
                            break;

                        case "break-below":
                            p.break_below = bool.Parse(items[1]);
                            break;

                        case "below-block-remove":
                            p.below_block_remove = bool.Parse(items[1]);
                            break;

                        case "material":
                            p.material = items[1].Trim().ToUpper();
                            break;

                        case "auto-spawn":
                            p.auto_spawn = bool.Parse(items[1]);
                            break;

                        case "growth":
                            string[] parts = items[1].Split('|');
                            for (int i = 0; i < parts.Length; i++)
                            {
                                p.growth_possibilities.Add(new Growth(parts[i]));
                            }
                            break;

                        case "extreme-height":
                            p.max_height = int.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        p.plant_id = (ushort)plants.Count;
                        p.get_height_range();
                        plants.Add(p);
                        Exilania.text_stream.WriteLine("Plant Item '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No plants.txt file.");
            }
        }
Example #6
0
        public BlockManager()
        {
            blocks             = new List <BlockData>();
            custom_item_images = new Dictionary <int, Texture2D>();

            if (System.IO.File.Exists(@"blocks.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"blocks.txt");
                string    line           = "";
                BlockData p    = new BlockData();
                bool      cont = true;
                while (cont)
                {
                    line = r.ReadLine();
                    if (line == "" || line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0].ToLower())
                        {
                        case "block":
                            if (p.name == "")
                            {
                                p.name = items[1].Trim();
                            }
                            else
                            {
                                blocks.Add(p);
                                Exilania.text_stream.WriteLine("Block '" + p.name + "' Loaded.");
                                p      = new BlockData();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "block_group":
                            p.block_group = sbyte.Parse(items[1]);
                            break;

                        case "background":
                            p.background = bool.Parse(items[1]);
                            break;

                        case "platform":
                            p.platform = bool.Parse(items[1]);
                            break;

                        case "transparent":
                            p.transparent = bool.Parse(items[1]);
                            break;

                        case "place_wall":
                            p.place_wall = bool.Parse(items[1]);
                            break;

                        case "passable":
                            p.passable = bool.Parse(items[1]);
                            break;

                        case "light_source":
                            if (!items[1].Contains("null"))
                            {
                                items          = items[1].Split(',');
                                p.light_source = new byte[] { byte.Parse(items[0]), byte.Parse(items[1]), byte.Parse(items[2]) };
                            }
                            break;

                        case "liquid_id":
                            p.liquid_id = byte.Parse(items[1]);
                            break;

                        case "block_image_use":
                            p.block_image_use = byte.Parse(items[1]);
                            break;

                        case "image_pointers":
                            items            = items[1].Split(',');
                            p.image_pointers = new int[items.Length];
                            for (int x = 0; x < items.Length; x++)
                            {
                                p.image_pointers[x] = int.Parse(items[x]);
                            }
                            break;

                        case "random_tiles":
                            p.random_tiles = Boolean.Parse(items[1]);
                            break;

                        case "background_transparent":
                            p.bkd_transparent = Boolean.Parse(items[1]);
                            break;

                        case "lighter_background":
                            p.lighter_background = Boolean.Parse(items[1]);
                            break;

                        case "map_color":
                            items           = Acc.script_remove_outer_parentheses(items[1]).Split(',');
                            p.map_represent = new Color(byte.Parse(items[0]), byte.Parse(items[1]), byte.Parse(items[2]));
                            break;

                        case "is_hangar": p.is_hangar = Boolean.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        blocks.Add(p);
                        Exilania.text_stream.WriteLine("Block '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No blocks.txt file.");
            }
        }
Example #7
0
        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.");
            }
        }
Example #8
0
        public ParticleManager()
        {
            particles = new List <ParticleTemplate>();
            if (System.IO.File.Exists(@"particles.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"particles.txt");
                string           line    = "";
                ParticleTemplate p       = new ParticleTemplate();
                bool             cont    = true;
                while (cont)
                {
                    line = r.ReadLine();
                    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
                            {
                                particles.Add(p);
                                Exilania.text_stream.WriteLine("Particle Template '" + p.name + "' Loaded.");
                                p      = new ParticleTemplate();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "pic":
                            string[] vals = Acc.script_remove_outer_parentheses(items[1]).Split(',');
                            p.image = new Rectangle(int.Parse(vals[0]), int.Parse(vals[1]), int.Parse(vals[2]), int.Parse(vals[3]));
                            break;

                        case "travel":
                            switch (items[1].ToLower())
                            {
                            case "straight":
                                p.travel_path = TravelType.Straight;
                                break;

                            case "boomerang":
                                p.travel_path = TravelType.Boomerang;
                                break;

                            case "piercing":
                                p.travel_path = TravelType.Piercing;
                                break;

                            case "bouncing":
                                p.travel_path = TravelType.Bouncy;
                                break;

                            case "graceful":
                                p.travel_path = TravelType.Graceful;
                                break;

                            case "haphazard":
                                p.travel_path = TravelType.Haphazard;
                                break;
                            }
                            break;

                        case "gravity":
                            p.gravity_affected = bool.Parse(items[1]);
                            break;

                        case "speed":
                            p.speed = float.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        particles.Add(p);
                        Exilania.text_stream.WriteLine("Particle Template '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No furniture.txt file.");
            }
        }