Пример #1
0
        private void CreateTree(UUID uuid, Copse copse, Vector3 position, bool randomScale)
        {
            position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
            if (position.Z < copse.m_treeline_low || position.Z > copse.m_treeline_high)
            {
                return;
            }

            Vector3 scale = copse.m_initial_scale;

            if (randomScale)
            {
                try
                {
                    float t;
                    float r = (float)Util.RandomClass.NextDouble();
                    r *= (float)Util.RandomClass.NextDouble();
                    r *= (float)Util.RandomClass.NextDouble();

                    t = copse.m_maximum_scale.X / copse.m_initial_scale.X;
                    if (t < 1.0)
                    {
                        t = 1 / t;
                    }
                    t        = t * r + 1.0f;
                    scale.X *= t;

                    t = copse.m_maximum_scale.Y / copse.m_initial_scale.Y;
                    if (t < 1.0)
                    {
                        t = 1 / t;
                    }
                    t        = t * r + 1.0f;
                    scale.Y *= t;

                    t = copse.m_maximum_scale.Z / copse.m_initial_scale.Z;
                    if (t < 1.0)
                    {
                        t = 1 / t;
                    }
                    t        = t * r + 1.0f;
                    scale.Z *= t;
                }
                catch
                {
                    scale = copse.m_initial_scale;
                }
            }

            SceneObjectGroup tree = AddTree(uuid, UUID.Zero, scale, Quaternion.Identity, position, copse.m_tree_type, false);

            tree.Name = copse.ToString();
            copse.m_trees.Add(tree.UUID);
            tree.RootPart.ScheduleFullUpdate();
        }
        private void CreateTree(UUID uuid, Copse copse, Vector3 position)
        {
            position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
            if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high)
            {
                SceneObjectGroup tree = AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false);

                tree.Name = copse.ToString();
                copse.m_trees.Add(tree.UUID);
                tree.SendGroupFullUpdate();
            }
        }
Пример #3
0
        private void CreateTree(UUID uuid, Copse copse, Vector3 position)
        {
            position.Z = m_scene.RequestModuleInterface <ITerrainChannel>()[(int)position.X, (int)position.Y];
            if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high)
            {
                SceneObjectGroup tree = (SceneObjectGroup)AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false);

                tree.Name = copse.ToString();
                copse.m_trees.Add(tree.UUID);
                tree.ScheduleGroupUpdate(PrimUpdateFlags.FindBest);
            }
        }
Пример #4
0
        private void ReloadCopse()
        {
            m_copses = new List <Copse>();

            List <SceneObjectGroup> grps = m_scene.GetSceneObjectGroups();

            foreach (SceneObjectGroup grp in grps)
            {
                if (grp.RootPart.Shape.PCode != (byte)PCode.NewTree && grp.RootPart.Shape.PCode != (byte)PCode.Tree)
                {
                    continue;
                }

                string grpname = grp.Name;
                if (grpname.Length > 5 && (grpname.Substring(0, 5) == "ATPM:" || grpname.Substring(0, 5) == "FTPM:"))
                {
                    // Create a new copse definition or add uuid to an existing definition
                    try
                    {
                        Boolean copsefound = false;
                        Copse   grpcopse   = new Copse(grpname);

                        lock (mylock)
                        {
                            foreach (Copse cp in m_copses)
                            {
                                if (cp.m_name == grpcopse.m_name)
                                {
                                    copsefound = true;
                                    cp.m_trees.Add(grp.UUID);
                                    //m_log.DebugFormat("[TREES]: Found tree {0}", grp.UUID);
                                }
                            }

                            if (!copsefound)
                            {
                                m_log.InfoFormat("[TREES]: adding copse {0}", grpcopse.m_name);
                                grpcopse.m_trees.Add(grp.UUID);
                                m_copses.Add(grpcopse);
                            }
                        }
                    }
                    catch
                    {
                        m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
                    }
                }
            }
        }
Пример #5
0
        private void ReloadCopse()
        {
            m_copse = new List <Copse>();

            List <EntityBase> objs = m_scene.GetEntities();

            foreach (EntityBase obj in objs)
            {
                if (obj is SceneObjectGroup)
                {
                    SceneObjectGroup grp = (SceneObjectGroup)obj;

                    if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:"))
                    {
                        // Create a new copse definition or add uuid to an existing definition
                        try
                        {
                            Boolean copsefound = false;
                            Copse   copse      = new Copse(grp.Name);

                            foreach (Copse cp in m_copse)
                            {
                                if (cp.m_name == copse.m_name)
                                {
                                    copsefound = true;
                                    cp.m_trees.Add(grp.UUID);
                                    //m_log.DebugFormat("[TREES]: Found tree {0}", grp.UUID);
                                }
                            }

                            if (!copsefound)
                            {
                                m_log.InfoFormat("[TREES]: Found copse {0}", grp.Name);
                                m_copse.Add(copse);
                                copse.m_trees.Add(grp.UUID);
                            }
                        }
                        catch
                        {
                            m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
                        }
                    }
                }
            }
        }
Пример #6
0
        private void HandleTreeRemove(string module, string[] cmd)
        {
            if (MainConsole.Instance.ConsoleScene != m_scene)
            {
                return;
            }
            string copsename     = (cmd[2]).Trim();
            Copse  copseIdentity = null;

            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copsename)
                {
                    copseIdentity = cp;
                }
            }

            if (copseIdentity != null)
            {
                List <SceneObjectGroup> groups = new List <SceneObjectGroup>();
                foreach (UUID tree in copseIdentity.m_trees)
                {
                    IEntity entity;
                    if (m_scene.Entities.TryGetValue(tree, out entity))
                    {
                        if (entity is SceneObjectGroup)
                        {
                            groups.Add((SceneObjectGroup)entity);
                        }
                    }
                }
                IBackupModule backup = m_scene.RequestModuleInterface <IBackupModule>();
                if (backup != null)
                {
                    backup.DeleteSceneObjects(groups.ToArray(), true);
                }
                copseIdentity.m_trees = new List <UUID>();
                m_copse.Remove(copseIdentity);
                m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
            }
            else
            {
                m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
            }
        }
            public Copse(string fileName, Boolean planted)
            {
                Copse cp = (Copse)DeserializeObject(fileName);

                this.m_name          = cp.m_name;
                this.m_frozen        = cp.m_frozen;
                this.m_tree_quantity = cp.m_tree_quantity;
                this.m_treeline_high = cp.m_treeline_high;
                this.m_treeline_low  = cp.m_treeline_low;
                this.m_range         = cp.m_range;
                this.m_tree_type     = cp.m_tree_type;
                this.m_seed_point    = cp.m_seed_point;
                this.m_initial_scale = cp.m_initial_scale;
                this.m_maximum_scale = cp.m_maximum_scale;
                this.m_initial_scale = cp.m_initial_scale;
                this.m_rate          = cp.m_rate;
                this.m_planted       = planted;
                this.m_trees         = new List <UUID>();
            }
Пример #8
0
        private void HandleTreeRemove(Object[] args)
        {
            string copsename     = ((string)args[0]).Trim();
            Copse  copseIdentity = null;

            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copsename)
                {
                    copseIdentity = cp;
                }
            }

            if (copseIdentity != null)
            {
                foreach (UUID tree in copseIdentity.m_trees)
                {
                    if (m_scene.Entities.ContainsKey(tree))
                    {
                        SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;


                        m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
                        m_scene.ForEachClient(delegate(IClientAPI controller)
                        {
                            controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
                                                      selectedTree.LocalId);
                        });
                    }
                    else
                    {
                        m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree);
                    }
                }
                copseIdentity.m_trees = new List <UUID>();
                m_copse.Remove(copseIdentity);
                m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
            }
            else
            {
                m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
            }
        }
        private void HandleTreeLoad(Object[] args)
        {
            Copse copse;

            m_log.InfoFormat("[TREES]: Loading copse definition....");

            copse = new Copse(((string)args[0]), false);
            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copse.m_name)
                {
                    m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name);
                    return;
                }
            }

            m_copse.Add(copse);
            m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString());
        }
        private void SpawnChild(Copse copse, SceneObjectPart s_tree)
        {
            Vector3 position = new Vector3();

            double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
            double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);

            position.X = s_tree.AbsolutePosition.X + (float)randX;
            position.Y = s_tree.AbsolutePosition.Y + (float)randY;

            if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 &&
                position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 &&
                Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
            {
                UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;

                CreateTree(uuid, copse, position);
            }
        }
Пример #11
0
        private void HandleTreeRemove(Object[] args)
        {
            string copsename     = ((string)args[0]).Trim();
            Copse  copseIdentity = null;

            lock (mylock)
            {
                foreach (Copse cp in m_copses)
                {
                    if (cp.m_name == copsename)
                    {
                        copseIdentity = cp;
                    }
                }

                if (copseIdentity != null)
                {
                    foreach (UUID tree in copseIdentity.m_trees)
                    {
                        if (m_scene.Entities.ContainsKey(tree))
                        {
                            SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
                            // Delete tree and alert clients (not silent)
                            m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
                        }
                        else
                        {
                            m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree);
                        }
                    }
                    copseIdentity.m_trees = null;
                    m_copses.Remove(copseIdentity);
                    m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
                }
                else
                {
                    m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
                }
            }
        }
Пример #12
0
        private void ReloadCopse()
        {
            m_copse = new List <Copse>();

            ISceneEntity[] objs = m_scene.Entities.GetEntities();
            foreach (ISceneEntity grp in objs)
            {
                if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:"))
                {
                    // Create a new copse definition or add uuid to an existing definition
                    try
                    {
                        Boolean copsefound = false;
                        Copse   copse      = new Copse(grp.Name);

                        foreach (Copse cp in m_copse)
                        {
                            if (cp.m_name == copse.m_name)
                            {
                                copsefound = true;
                                cp.m_trees.Add(grp.UUID);
                                //MainConsole.Instance.DebugFormat("[TREES]: Found tree {0}", grp.UUID);
                            }
                        }

                        if (!copsefound)
                        {
                            MainConsole.Instance.InfoFormat("[TREES]: Found copse {0}", grp.Name);
                            m_copse.Add(copse);
                            copse.m_trees.Add(grp.UUID);
                        }
                    }
                    catch
                    {
                        MainConsole.Instance.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
                    }
                }
            }
        }
Пример #13
0
        private void HandleTreeLoad(string module, string[] cmd)
        {
            if (MainConsole.Instance.ConsoleScene != m_scene)
            {
                return;
            }
            Copse copse;

            m_log.InfoFormat("[TREES]: Loading copse definition....");

            copse = new Copse(cmd[2], false);
            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copse.m_name)
                {
                    m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name);
                    return;
                }
            }

            m_copse.Add(copse);
            m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString());
        }
Пример #14
0
        private void SpawnChild(Copse copse, SceneObjectPart s_tree, bool low)
        {
            Vector3 position = new Vector3();

            float randX = copse.m_maximum_scale.X * 1.25f;
            float randY = copse.m_maximum_scale.Y * 1.25f;

            float r = (float)Util.RandomClass.NextDouble();

            randX     *= 2.0f * r - 1.0f;
            position.X = s_tree.AbsolutePosition.X + (float)randX;

            r          = (float)Util.RandomClass.NextDouble();
            randY     *= 2.0f * r - 1.0f;
            position.Y = s_tree.AbsolutePosition.Y + (float)randY;

            if (position.X > (m_scene.RegionInfo.RegionSizeX - 1) || position.X <= 0 ||
                position.Y > (m_scene.RegionInfo.RegionSizeY - 1) || position.Y <= 0)
            {
                return;
            }

            randX  = position.X - copse.m_seed_point.X;
            randX *= randX;
            randY  = position.Y - copse.m_seed_point.Y;
            randY *= randY;
            randX += randY;

            if (randX > copse.m_range * copse.m_range)
            {
                return;
            }

            UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;

            CreateTree(uuid, copse, position, low);
        }
Пример #15
0
        private void ReloadCopse()
        {
            m_copse = new List<Copse>();

            EntityBase[] objs = m_scene.GetEntities();
            foreach (EntityBase obj in objs)
            {
                if (obj is SceneObjectGroup)
                {
                    SceneObjectGroup grp = (SceneObjectGroup)obj;

                    if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:"))
                    {
                        // Create a new copse definition or add uuid to an existing definition
                        try
                        {
                            Boolean copsefound = false;
                            Copse copse = new Copse(grp.Name);

                            foreach (Copse cp in m_copse)
                            {
                                if (cp.m_name == copse.m_name)
                                {
                                    copsefound = true;
                                    cp.m_trees.Add(grp.UUID);
                                    //m_log.DebugFormat("[TREES]: Found tree {0}", grp.UUID);
                                }
                            }

                            if (!copsefound)
                            {
                                m_log.InfoFormat("[TREES]: Found copse {0}", grp.Name);
                                m_copse.Add(copse);
                                copse.m_trees.Add(grp.UUID);
                            }
                        }
                        catch
                        {
                            m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creats (plants) a tree
        /// </summary>
        /// <param name="uuid">UUID.</param>
        /// <param name="copse">Copse.</param>
        /// <param name="position">Position.</param>
        void CreateTree( UUID uuid, Copse copse, Vector3 position )
        {
            position.Z = m_scene.RequestModuleInterface<ITerrainChannel>()[(int)position.X, (int)position.Y];
            if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high)
            {
                var tree = (SceneObjectGroup) AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false);

                tree.Name = copse.ToString();
                copse.m_trees.Add(tree.UUID);
                tree.ScheduleGroupUpdate(PrimUpdateFlags.FindBest);
            }
        }
Пример #17
0
        private void SpawnChild(Copse copse, SceneObjectPart s_tree)
        {
            Vector3 position = new Vector3();

            double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
            double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);

            position.X = s_tree.AbsolutePosition.X + (float)randX;
            position.Y = s_tree.AbsolutePosition.Y + (float)randY;

            if (position.X <= 255 && position.X >= 0 &&
                position.Y <= 255 && position.Y >= 0 &&
                Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
            {
                UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
                if (uuid == UUID.Zero)
                    uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID;

                CreateTree(uuid, copse, position);
            }
        }
        /// <summary>
        /// Re-configure a copse definition.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void HandleTreeUpdate(IScene scene, string[] cmd)
        {
            if ( !TreeCheckValidRegion(m_scene) )
                return;

            bool advancedOptions = false;
            if ( cmd.Count() == 3 )
                advancedOptions = Boolean.Parse( cmd[2] );

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\n************* WhiteCore Tree Configuration *************");
            Console.WriteLine (
                "\n   This will update an existing copse definition for this region.\n Type 'quit' to exit");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.ResetColor();

            var updateCopse = new Copse();
            updateCopse.m_name = "?";

            bool nameCheckOk = false;
            do
            {
            updateCopse.m_name = ReadLine ("Which copse would you like to update?", updateCopse.m_name);
            if ( updateCopse.m_name[0] == '?' )
                {
                    ListExistingCopse();
                    continue;
                }

                // provide an "out"
                if (updateCopse.m_name.ToLower () == "quit")
                    return;

                // check for definition
                foreach ( Copse cp in m_copse )
                {
                if ( cp.m_name == updateCopse.m_name )
                    {
                        // found it.. grab details
                        nameCheckOk = true;
                        updateCopse = cp;

                        break;
                    }
                }

                // not found ?
                if ( !nameCheckOk )
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine ("The copse name (" + updateCopse.m_name + ") does not exist. ('?' for list)");
                    Console.ResetColor ();
                }

            } while (!nameCheckOk);

            // disable activity if necessary
            bool oldState = m_active_trees;
            if ( oldState )
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine( "Disabling growth whilst re-configuring");
                Console.ResetColor();

                activeizeTreeze( false );
            }

            GetCopseDefinitions (updateCopse, advancedOptions);

            // update this definition
            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == updateCopse.m_name)
                {

                    // cp.m_name = updateCopse.m_name;
                    // cp.m_frozen = false;
                    cp.m_tree_quantity = updateCopse.m_tree_quantity;
                    cp.m_treeline_high = updateCopse.m_treeline_high;
                    cp.m_treeline_low = updateCopse.m_treeline_low;
                    cp.m_range = updateCopse.m_range;
                    cp.m_tree_type = updateCopse.m_tree_type;
                    cp.m_seed_point = updateCopse.m_seed_point;
                    cp.m_initial_scale = updateCopse.m_initial_scale;
                    cp.m_maximum_scale = updateCopse.m_maximum_scale;
                    cp.m_rate = updateCopse.m_rate;
                    //cp.m_planted = false;
                    //cp.m_trees = new List<UUID>();

                    break;
                }
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Your new copse of trees has been successfully configured");
            Console.ResetColor();

            // need to plant them now?
            if (!updateCopse.m_planted )
            {
                string plantNow;
                plantNow = ReadLine("Do you want to plant this copse now?", "no");

                if(plantNow[0] == 'y')
                PlantTreeCopse (updateCopse.m_name);
            }

            if ( oldState )
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine( "Re-activiating growth");
                Console.ResetColor();

                activeizeTreeze( true );
            }
        }
        /// <summary>
        /// Interactive tree configuration.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void HandleTreeConfigure(IScene scene, string[] cmd)
        {
            if ( !TreeCheckValidRegion(m_scene) )
                return;

            bool advancedOptions = false;
            if ( cmd.Count() == 3 ) {
                advancedOptions |= cmd [2].ToLower () == "true";
            }

            string resp = "no";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\n************* WhiteCore Tree Configuration *************");
            Console.WriteLine (
                "\n   This configurator will interactively generate a new tree copse" +
                "\n     definition for this region.\n");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.ResetColor();
            resp = ReadLine("Do you want to configure a new copse of trees now?", resp).ToLower();

            if ( resp[0] != 'y' )
                return;

            // here we go... set some defaults for ease of use
            var newCopse = new Copse();

            newCopse.m_name = "Mycopse";
            newCopse.m_frozen = false;
            newCopse.m_tree_quantity = 25;
            newCopse.m_treeline_high = 35;
            newCopse.m_treeline_low = 20;
            newCopse.m_range = 50;
            newCopse.m_tree_type = Tree.Pine1;
            newCopse.m_seed_point = new Vector3(128,128,0);
            newCopse.m_initial_scale = new Vector3(4,4,4);
            newCopse.m_maximum_scale = new Vector3(15,15,15);
            newCopse.m_rate = new Vector3((float) 0.01,(float) 0.01,(float)0.01);
            newCopse.m_planted = false;
            newCopse.m_trees = new List<UUID>();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("\n\n");
            Console.WriteLine("====================================================================");
            Console.WriteLine("================== WhiteCore Tree CONFIGURATOR =====================");
            Console.WriteLine("====================================================================");
            Console.WriteLine("\n\n");
            Console.ResetColor();

            bool nameCheckOk;
            do
            {
                newCopse.m_name = ReadLine ("What will you call this copse of trees ('quit' to abort) ?", newCopse.m_name);
                nameCheckOk = true;         // assume name is ok

                foreach ( Copse cp in m_copse )
                {
                    if ( cp.m_name == newCopse.m_name )
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine ("This copse name (" + newCopse.m_name + ") already exists");
             			Console.ResetColor ();
                        nameCheckOk = false;
                    }
                }
            } while (!nameCheckOk);

            if ( newCopse.m_name.ToLower() == "quit" )		// provide an "out"
                return;

            GetCopseDefinitions (newCopse, advancedOptions);
            m_copse.Add(newCopse);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Your new copse of trees has been successfully configured");
            Console.ResetColor();

            // plant them now?
            string plantNow;
            plantNow = ReadLine("Do you want to plant this copse now?", "no");
            if( plantNow[0] == 'y' )
                PlantTreeCopse (newCopse.m_name);

            if ( !m_active_trees )
            {
                resp = "yes";
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.ResetColor();
                resp = ReadLine( "Do you want to activate tree growth now?", resp ).ToLower();

                if ( resp[0] == 'y' )
                {
                    MainConsole.Instance.Info ( "[TREES]: Activating Trees" );
                    activeizeTreeze( true );
                }
            }
        }
        /// <summary>
        /// Load a copse definition from file
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void HandleTreeLoad(IScene scene, string[] cmd)
        {
            if ( !TreeCheckValidRegion( m_scene ) )
                return;

            if ( cmd.Count() < 3 )
            {
                MainConsole.Instance.Info ( "[TREES]: You need to specify the filename to load" );
                return;
            }

            string fileName = cmd [2];
            string extension = Path.GetExtension( fileName );

            if ( extension == string.Empty)
                fileName = fileName+".copse";

            if ( !File.Exists( fileName ) )
            {
                MainConsole.Instance.Info ( "[TREES]: Copse definition file '" + fileName + "' not found." );
                return;
            }

            MainConsole.Instance.Info ( "[TREES]: Loading copse definition...." );
            var newCopse = new Copse( cmd[2], false );

            foreach ( Copse cp in m_copse )
            {
                if ( cp.m_name == newCopse.m_name )
                {
                    MainConsole.Instance.Info ( "[TREES]: Copse: " + newCopse.m_name + " is already defined - load ignored" );
                    return;
                }
            }

            m_copse.Add( newCopse );
            MainConsole.Instance.Info ( "[TREES]: Loaded copse: " + newCopse );
        }
Пример #21
0
        private void CreateTree(UUID uuid, Copse copse, Vector3 position)
        {

            position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
            if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high)
            {
                SceneObjectGroup tree = AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false);

                tree.Name = copse.ToString();
                copse.m_trees.Add(tree.UUID);
                tree.SendGroupFullUpdate(PrimUpdateFlags.FindBest);
            }
        }
        /// <summary>
        /// Gets/updates the copse definitions.
        /// </summary>
        /// <returns>The copse definitions.</returns>
        /// <param name="cp">Cp.</param>
        /// <param name="advancedOptions">If set to <c>true</c> advanced options.</param>
        static Copse GetCopseDefinitions(Copse cp, bool advancedOptions)
        {
            int treeType = GetTreeType ((int) cp.m_tree_type);
            cp.m_tree_type = (Tree)treeType;

            cp.m_tree_quantity = int.Parse(ReadLine("How many trees do you want?", cp.m_tree_quantity.ToString()));
            cp.m_treeline_high = int.Parse(ReadLine("The highest elevation to grow a tree?", cp.m_treeline_high.ToString()));
            cp.m_treeline_low = int.Parse(ReadLine("The lowest elevation to grow a tree (may be below the waterline)?", cp.m_treeline_low.ToString()));
            cp.m_range = double.Parse(ReadLine("The maximum distance away from the initial seed point to grow trees?", cp.m_range.ToString()));

            // allow entry of seed point only if the initial plant has not happened
            if (!cp.m_planted)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine ("Enter the position where to plant the first tree\n" +
                    "e.g. to start in the middle of a 256x256 region enter position x = 128 and position y = 128");
                Console.ResetColor ();
                cp.m_seed_point.X = int.Parse (ReadLine ("Plant the first tree at X location ", cp.m_seed_point.X.ToString ()));
                cp.m_seed_point.Y = int.Parse (ReadLine ("Plant the first tree at Y location ", cp.m_seed_point.Y.ToString ()));
            }

            if ( advancedOptions )
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine ("Enter the initial size of the tree when it is planted <size> &  <height>\n");
                Console.ResetColor();
                cp.m_initial_scale.X = int.Parse(ReadLine("Initial tree size ", cp.m_initial_scale.X.ToString()));
                cp.m_initial_scale.Z = int.Parse(ReadLine("Initial tree height ", cp.m_initial_scale.Z.ToString()));
                cp.m_initial_scale.Y = cp.m_initial_scale.X;

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine ("Enter the maximum size of the tree when it is fully grown <size> &  <height>\n");
                Console.ResetColor();
                cp.m_maximum_scale.X = int.Parse(ReadLine("Maximum tree size ", cp.m_maximum_scale.X.ToString()));
                cp.m_maximum_scale.Z = int.Parse(ReadLine("Maximum tree height ", cp.m_maximum_scale.Z.ToString()));
                cp.m_maximum_scale.Y = cp.m_maximum_scale.X;

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine ("Enter the growth rate of the tree <horizontal> & <vertical>\n");
                Console.ResetColor();
                cp.m_rate.X = float.Parse(ReadLine("Horizontal growth rate of the tree ", cp.m_rate.X.ToString()));
                cp.m_rate.Z = int.Parse(ReadLine("Vertical growth rate ot the tree ", cp.m_rate.Z.ToString()));
                cp.m_rate.Y = cp.m_rate.X;
            }

            return cp;
        }
Пример #23
0
        private void HandleTreeLoad(string module, string[] cmd)
        {
            if (MainConsole.Instance.ConsoleScene != m_scene)
                return;
            Copse copse;

            m_log.InfoFormat("[TREES]: Loading copse definition....");

            copse = new Copse(cmd[2], false);
            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copse.m_name)
                {
                    m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name);
                    return;
                }
            }

            m_copse.Add(copse);
            m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString());
        }
Пример #24
0
        private void HandleTreeLoad(Object[] args)
        {
            Copse copse;

            m_log.InfoFormat("[TREES]: Loading copse definition....");

            copse = new Copse(((string)args[0]), false);
            foreach (Copse cp in m_copse)
            {
                if (cp.m_name == copse.m_name)
                {
                    m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name);
                    return;
                }
            }

            m_copse.Add(copse);
            m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString());
        }
        private void ReloadCopse()
        {
            m_copse = new List<Copse>();

            ISceneEntity[] objs = m_scene.Entities.GetEntities ();
            foreach(ISceneEntity grp in objs)
            {
                if(grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:"))
                {
                    // Create a new copse definition or add uuid to an existing definition
                    try
                    {
                        Boolean copsefound = false;
                        Copse copse = new Copse(grp.Name);

                        foreach(Copse cp in m_copse)
                        {
                            if(cp.m_name == copse.m_name)
                            {
                                copsefound = true;
                                cp.m_trees.Add(grp.UUID);
                                //MainConsole.Instance.DebugFormat("[TREES]: Found tree {0}", grp.UUID);
                            }
                        }

                        if(!copsefound)
                        {
                            MainConsole.Instance.InfoFormat("[TREES]: Found copse {0}", grp.Name);
                            m_copse.Add(copse);
                            copse.m_trees.Add(grp.UUID);
                        }
                    }
                    catch
                    {
                        MainConsole.Instance.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
                    }
                }
            }
        }
        /// <summary>
        /// Reloads the copse definitions.
        /// </summary>
        void ReloadCopse()
        {
            m_copse = new List<Copse>();

            ISceneEntity[] objs = m_scene.Entities.GetEntities ();
            foreach( ISceneEntity grp in objs )
            {
                if( grp.Name.Length > 5 && ( grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:" ) )
                {
                    // Create a new copse definition or add uuid to an existing definition
                    try
                    {
                        bool copsefound = false;
                        var copse = new Copse( grp.Name );

                        foreach( Copse cp in m_copse )
                        {
                            if( cp.m_name == copse.m_name )
                            {
                                // MainConsole.Instance.Info ("[TREES]: Found tree "+ grp.UUID);
                                copsefound = true;
                                cp.m_trees.Add( grp.UUID );
                            }
                        }

                        if( !copsefound )
                        {
                            m_copse.Add( copse );
                            copse.m_trees.Add(grp.UUID);
                            MainConsole.Instance.Info ( "[TREES]: Found copse "+ copse.m_name + " at "+
                                copse.m_seed_point.X+", "+copse.m_seed_point.Y );
                        }
                    }
                    catch
                    {
                        MainConsole.Instance.Info ( "[TREES]: Ill formed copse definition "+grp.Name+" - ignoring" );
                    }
                }
            }
        }
Пример #27
0
        private void SpawnChild(Copse copse, SceneObjectPart s_tree)
        {
            Vector3 position = new Vector3();

            double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
            double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);

            position.X = s_tree.AbsolutePosition.X + (float)randX;
            position.Y = s_tree.AbsolutePosition.Y + (float)randY;

            if (!m_scene.TestBorderCross(position, Cardinals.W) && position.X >= 0 &&
                !m_scene.TestBorderCross(position, Cardinals.N) && position.Y >= 0 &&
                Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
            {
                UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;

                CreateTree(uuid, copse, position);
            }
        }
        /// <summary>
        /// Spawns a new tree.
        /// </summary>
        /// <param name="copse">Copse.</param>
        /// <param name="s_tree">S_tree.</param>
        void SpawnChild( Copse copse, ISceneChildEntity s_tree )
        {
            var position = new Vector3();

            double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
            double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);

            position.X = s_tree.AbsolutePosition.X + (float)randX;
            position.Y = s_tree.AbsolutePosition.Y + (float)randY;

            if (!(position.X < 0f || position.Y < 0f ||
                position.X > m_scene.RegionInfo.RegionSizeX || position.Y > m_scene.RegionInfo.RegionSizeY) &&
                Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
            {
                UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;

                CreateTree(uuid, copse, position);
            }
        }