public async Task ThrowIfMoreThanOneRoot()
        {
            var provider = new TestTreeDbContextProvider(nameof(ThrowIfMoreThanOneRoot));

            using (var context = provider.CreateContext())
            {
                await context.Nodes.AddRangeAsync(
                    new Node
                {
                    Id   = 1,
                    Name = "Root 1"
                },
                    new Node
                {
                    Id   = 2,
                    Name = "Root 2"
                }
                    );

                await context.SaveChangesAsync();
            }

            var         manager = new TreeManager(provider);
            Func <Task> action  = async() => await manager.GetRootWithRecursiveChildrenAsync();

            await action.Should().ThrowAsync <InvalidOperationException>("Sequence contains more than one matching element");
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var intent      = new ImageGalleryIntent(Intent);
            var imageIdList = intent.ImageIds;
            var title       = intent.Title;
            var tree        = TreeManager <Slug> .GetTree();

            var imageList = new List <Image>();

            foreach (var id in imageIdList)
            {
                var image = tree.Images.Find(i => i.XmlId == id);
                imageList.Add(image);
            }

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_imagegallery);

            var mToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(mToolbar);
            mToolbar.SetNavigationIcon(Resource.Drawable.ic_arrow_back_white_24dp);
            SupportActionBar.SetHomeButtonEnabled(true);

            SupportActionBar.Title = title;
            var          viewPager = FindViewById <ViewPager>(Resource.Id.viewPager);
            ImageAdapter adapter   = new ImageAdapter(this, imageList);

            viewPager.Adapter = adapter;
        }
コード例 #3
0
		private static void UpdateData(TreeManager tm, SimulationManager.UpdateMode mode)
		{
			Singleton<LoadingManager>.instance.m_loadingProfilerSimulation.BeginLoading("TreeManager.UpdateData");
            if (TreeUnlimiter.Mod.DEBUG_LOG_ON == true) { Debug.Log("[TreeUnlimiter::LimitTreeManager::UpdateData()] calling Ensure Init"); }
            LimitTreeManager.Helper.EnsureInit(3);
			for (int i = 1; i < LimitTreeManager.Helper.TreeLimit; i++)
			{
				if (tm.m_trees.m_buffer[i].m_flags != 0 && tm.m_trees.m_buffer[i].Info == null)
				{
					tm.ReleaseTree((uint)i);
				}
			}
			int num = PrefabCollection<TreeInfo>.PrefabCount();
			int num1 = 1;
			while (num1 * num1 < num)
			{
				num1++;
			}
			for (int j = 0; j < num; j++)
			{
				TreeInfo prefab = PrefabCollection<TreeInfo>.GetPrefab((uint)j);
				if (prefab != null)
				{
					prefab.SetRenderParameters(j, num1);
				}
			}
			ColossalFramework.Threading.ThreadHelper.dispatcher.Dispatch(() => {
				tm.GetType().GetField("m_lastShadowRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(tm, new Quaternion());
				tm.GetType().GetField("m_lastCameraRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(tm, new Quaternion());
			});
			tm.m_infoCount = num;
			Singleton<LoadingManager>.instance.m_loadingProfilerSimulation.EndLoading();
		}
コード例 #4
0
ファイル: GameTests.cs プロジェクト: cyecp/DeltaEngine.OpenTK
        public void SendGhostsFromOneTreeToAnother()
        {
            var trees = new TreeManager(Team.HumanYellow);

            trees.AddTree(new Vector2D(0.75f, 0.4f), Team.HumanYellow);
            trees.AddTree(new Vector2D(0.25f, 0.55f), Team.None);
        }
コード例 #5
0
        /// <summary>
        /// Processes the delete command.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="Id">The id.</param>
        void ProcessDeleteCommand(string[] items, int Id)
        {
            for (int i = 0; i < items.Length; i++)
            {
                string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]);
                if (keys != null)
                {
                    int    id            = Int32.Parse(keys[0]);
                    string type          = keys[1];
                    string outlineNumber = keys[2];

                    if (type.Equals("Node"))
                    {
                        FolderElement.Delete(id);
                    }
                    else if (type.Equals("Folder"))
                    {
                        Mediachase.Ibn.Data.Services.TreeNode node = TreeManager.GetNodeByOulineNumber(Folder.GetAssignedMetaClass(), outlineNumber);
                        if (node != null)
                        {
                            DeleteEntryRecursive(node);
                            TreeManager.DeleteNode(node);
                        }
                    }
                }
            }
        }
コード例 #6
0
 void Start()
 {
     audioSource             = GetComponent <AudioSource>();
     audioSource.loop        = false;
     audioSource.playOnAwake = false;
     treeManager             = FindObjectOfType <TreeManager>();
 }
コード例 #7
0
		private static void ReleaseTreeImplementation(TreeManager tm, uint tree, ref TreeInstance data)
		{
            if (data.m_flags != 0)
            {
                InstanceID instanceID = new InstanceID()
                {
                    Tree = tree
                };
                Singleton<InstanceManager>.instance.ReleaseInstance(instanceID);
                data.m_flags = (ushort)(data.m_flags | 2);
                data.UpdateTree(tree);
                data.m_flags = 0;
                try
                {
                    LimitTreeManager.FinalizeTree(tm, tree, ref data);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    object[] objArray = new object[] { tree, tm.m_trees.m_size, LimitTreeManager.Helper.TreeLimit, LimitTreeManager.Helper.UseModifiedTreeCap };
                    Debug.LogFormat("[TreeUnlimiter::ReleaseTreeImplementation] Treexception: Releasing {0} {1} {2} {3}", objArray);
                    Debug.LogException(exception);
                }
                tm.m_trees.ReleaseItem(tree);
                tm.m_treeCount = (int)(tm.m_trees.ItemCount() - 1);
            }
        }
コード例 #8
0
        private static void InitializeTree(TreeManager tm, uint tree, ref TreeInstance data, bool assetEditor)
		{
			unsafe
			{
				int num;
				int num1;
				if (!assetEditor)
				{
					num = Mathf.Clamp((data.m_posX + 32768) * 540 / 65536, 0, 539);
					num1 = Mathf.Clamp((data.m_posZ + 32768) * 540 / 65536, 0, 539);
				}
				else
				{
					num = Mathf.Clamp((data.m_posX / 16 + 32768) * 540 / 65536, 0, 539);
					num1 = Mathf.Clamp((data.m_posZ / 16 + 32768) * 540 / 65536, 0, 539);
				}
				int num2 = num1 * 540 + num;
				while (!Monitor.TryEnter(tm.m_treeGrid, SimulationManager.SYNCHRONIZE_TIMEOUT))
				{
				}
				try
				{
					tm.m_trees.m_buffer[tree].m_nextGridTree = tm.m_treeGrid[num2];
					tm.m_treeGrid[num2] = tree;
				}
				finally
				{
					Monitor.Exit(tm.m_treeGrid);
				}
			}
		}
コード例 #9
0
		private static void PopulateGroupData(TreeManager tm, int groupX, int groupZ, int layer, ref int vertexIndex, ref int triangleIndex, Vector3 groupPosition, RenderGroup.MeshData data, ref Vector3 min, ref Vector3 max, ref float maxRenderDistance, ref float maxInstanceDistance, ref bool requireSurfaceMaps)
		{
			unsafe
			{
				if (layer != tm.m_treeLayer)
				{
					return;
				}
				int num = groupX * 540 / 45;
				int num1 = groupZ * 540 / 45;
				int num2 = (groupX + 1) * 540 / 45 - 1;
				int num3 = (groupZ + 1) * 540 / 45 - 1;
				for (int i = num1; i <= num3; i++)
				{
					for (int j = num; j <= num2; j++)
					{
						uint mTreeGrid = tm.m_treeGrid[i * 540 + j];
						int num4 = 0;
						while (mTreeGrid != 0)
						{
							tm.m_trees.m_buffer[mTreeGrid].PopulateGroupData(mTreeGrid, layer, ref vertexIndex, ref triangleIndex, groupPosition, data, ref min, ref max, ref maxRenderDistance, ref maxInstanceDistance);
							mTreeGrid = tm.m_trees.m_buffer[mTreeGrid].m_nextGridTree;
							int num5 = num4 + 1;
							num4 = num5;
							if (num5 < LimitTreeManager.Helper.TreeLimit)
							{
								continue;
							}
							CODebugBase<LogChannel>.Error(LogChannel.Core, string.Concat("Invalid list detected!\n", Environment.StackTrace));
							break;
						}
					}
				}
			}
		}
コード例 #10
0
		private static bool CheckLimits(TreeManager tm)
		{
			ItemClass.Availability mMode = Singleton<ToolManager>.instance.m_properties.m_mode;
			if ((mMode & ItemClass.Availability.MapEditor) != ItemClass.Availability.None)
			{
				// changed to enable >250k in mapeditor.
                //if (tm.m_treeCount >= 250000)
                if (tm.m_treeCount >= LimitTreeManager.Helper.TreeLimit - 5)
                {
					return false;
				}
			}
			else if ((mMode & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None)
			{
				if (tm.m_treeCount + Singleton<PropManager>.instance.m_propCount >= 64)
				{
					return false;
				}
			}
			else if (tm.m_treeCount >= LimitTreeManager.Helper.TreeLimit - 5)
			{
				return false;
			}
			return true;
		}
コード例 #11
0
 private static void FinalizeTree(TreeManager tm, uint tree, ref TreeInstance data)
 {
     unsafe
     {
         int num;
         int num1;
         if (Singleton<ToolManager>.instance.m_properties.m_mode == ItemClass.Availability.AssetEditor)
         {
             num = Mathf.Clamp((data.m_posX / 16 + 32768) * 540 / 65536, 0, 539);
             num1 = Mathf.Clamp((data.m_posZ / 16 + 32768) * 540 / 65536, 0, 539);
         }
         else
         {
             num = Mathf.Clamp((data.m_posX + 32768) * 540 / 65536, 0, 539);
             num1 = Mathf.Clamp((data.m_posZ + 32768) * 540 / 65536, 0, 539);
         }
         int num2 = num1 * 540 + num;
         while (!Monitor.TryEnter(tm.m_treeGrid, SimulationManager.SYNCHRONIZE_TIMEOUT))
         {
         }
         try
         {
             uint num3 = 0;
             uint mTreeGrid = tm.m_treeGrid[num2];
             int num4 = 0;
             while (mTreeGrid != 0)
             {
                 if (mTreeGrid != tree)
                 {
                     num3 = mTreeGrid;
                     mTreeGrid = tm.m_trees.m_buffer[mTreeGrid].m_nextGridTree;
                     int num5 = num4 + 1;
                     num4 = num5;
                     if (num5 <= LimitTreeManager.Helper.TreeLimit)
                     {
                         continue;
                     }
                     CODebugBase<LogChannel>.Error(LogChannel.Core, string.Concat("Invalid list detected!\n", Environment.StackTrace));
                     break;
                 }
                 else if (num3 == 0)
                 {
                     tm.m_treeGrid[num2] = data.m_nextGridTree;
                     break;
                 }
                 else
                 {
                     tm.m_trees.m_buffer[num3].m_nextGridTree = data.m_nextGridTree;
                     break;
                 }
             }
             data.m_nextGridTree = 0;
         }
         finally
         {
             Monitor.Exit(tm.m_treeGrid);
         }
         Singleton<RenderManager>.instance.UpdateGroup(num * 45 / 540, num1 * 45 / 540, tm.m_treeLayer);
     }
 }
コード例 #12
0
        public static void AddPoint(IDEInterop ide, TreeManager treeManager, AspectManager Manager, TreeViewAdapter Adapter, TreeNode NewParent, Action Callback)
        {
            if (ide.GetCurrentDocumentFileName() == "")
            {
                return;
            }

            string Text = ide.GetCurrentLine().Trim();

            if (Text == "")
            {
                return;
            }

            List <PointOfInterest> points = FindPointUnderCursor(ide, treeManager);

            if (points != null)
            {
                foreach (PointOfInterest pt in points)
                {
                    pt.FileName = Manager.GetRelativePath(pt.FileName);
                    pt.Text     = Text;
                }
            }
            ShowPointDialog(Adapter, points, NewParent, true, Callback);
        }
コード例 #13
0
ファイル: Packer.cs プロジェクト: gilanghamidy/TreeUnlimiter
        /// <summary>
        /// Returns a list of indexes where trees actually exist and hence need to be saved\processed.
        /// Used by serialization process; Also I used this in Treeinfo validate upon load to save duplicating code.
        /// </summary>
        /// <returns>list object of int's</returns>
        public static List <int> GetPackedList()
        {
            List <int>  treeidx;
            TreeManager TM = Singleton <TreeManager> .instance;

            try
            {
                if (TM != null && TM.m_treeCount > 0)
                {
                    treeidx = new List <int>(TM.m_treeCount);
                    //Sadly we have to jackup entry [0] to account for buffer[0] and 1 based entries in serialize\deserialize
                    treeidx.Add(0); //add dummy entry at list index[0]
                    for (int i = 0; i < TM.m_trees.m_size; i++)
                    {
                        if (TM.m_trees.m_buffer[i].m_flags != 0)
                        {
                            treeidx.Add(i);
                        }
                    }
                    return(treeidx);
                }
            }
            catch (Exception ex)
            { Logger.dbgLog("", ex, true); }
            return(new List <int>());
        }
コード例 #14
0
        /// <summary>
        /// Поиск точки в текущем документе в позиции курсора
        /// Документ должен быть открыт.
        /// </summary>
        /// <param name="dte"></param>
        /// <param name="Wrapper"></param>
        /// <param name="Manager"></param>
        /// <returns></returns>
        public static List <PointOfInterest> FindPointUnderCursor(IDEInterop ide, TreeManager treeManager)
        {
            string                 SourceText = ide.GetCurrentTextDocument();
            PointOfInterest        root       = treeManager.GetTree(ide.GetCurrentDocumentFileName(), SourceText);
            LexLocation            loc        = ide.GetCursorPosition();
            string                 Text       = ide.GetLine(loc.StartLine);
            List <PointOfInterest> Points     = TreeSearchEngine.FindPointByLocation(root, loc.StartLine, loc.StartColumn);

            if (Points == null || Points.Count == 0)
            {
                return(null);
            }

            List <PointOfInterest> Result = new List <PointOfInterest>();

            foreach (PointOfInterest pt in Points)
            {
                PointOfInterest p2 = pt.ClonePointAssignItems();
                p2.ApplyInnerContext();
                p2.Items = new List <PointOfInterest>();
                Result.Add(p2);
                TreeSearchEngine.SetNearLG(root, pt, SourceText, out p2.NearL, out p2.NearG);
            }

            int len = loc.StartLine == loc.EndLine ? loc.EndColumn - loc.StartColumn : Text.Length - loc.StartColumn;

            Result[0].Title = GetCurrentWord(Text, loc.StartColumn, len);
            return(Result);
        }
コード例 #15
0
        public static void EditPointAnchor(IDEInterop ide, TreeManager treeManager, AspectManager Manager, TreeViewAdapter Adapter, TreeNode Node, Action Callback)
        {
            if (ide.GetCurrentDocumentFileName() == "")
            {
                return;
            }

            string Text = ide.GetCurrentLine().Trim();

            if (Text == "")
            {
                return;
            }

            List <PointOfInterest> points        = FindPointUnderCursor(ide, treeManager);
            PointOfInterest        OriginalPoint = Adapter.GetPointByNode(Node);

            if (points != null)
            {
                foreach (PointOfInterest pt in points)
                {
                    pt.FileName = Manager.GetRelativePath(pt.FileName);
                    pt.Title    = OriginalPoint.Title;
                    pt.Note     = OriginalPoint.Note;
                    pt.Text     = Text;
                }
            }

            ShowPointDialog(Adapter, points, Node, false, Callback);
        }
コード例 #16
0
        /// <summary>
        /// Loads a KML tree from data file to the tree view
        /// </summary>
        /// <param name="filename">The full path and filename of the data file to read</param>
        public void Load(string filename)
        {
            WarningsManager.BeforeTreeLoad();
            TreeManager.Load(filename);
            VesselsManager.Load(TreeManager);
            KerbalsManager.Load(TreeManager);
            WarningsManager.AfterTreeLoad();

            // Show warnings tab if there are any
            if (Syntax.Messages.Count > 0)
            {
                WarningsTab.Visibility = System.Windows.Visibility.Visible;
                Tabs.SelectedItem      = WarningsTab;
                WarningsManager.Focus();
            }
            else
            {
                if (Tabs.SelectedItem == WarningsTab)
                {
                    Tabs.SelectedItem = TreeTab;
                    TreeManager.Focus();
                }
                else
                {
                    IGuiManager mgr = GetActiveGuiManager();
                    if (mgr != null)
                    {
                        mgr.Focus();
                    }
                }
                WarningsTab.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
コード例 #17
0
		private static void CalculateAreaHeight(TreeManager tm, float minX, float minZ, float maxX, float maxZ, out int num, out float min, out float avg, out float max)
		{
			unsafe
			{
				int num1 = Mathf.Max((int)(((double)minX - 8) / 32 + 270), 0);
				int num2 = Mathf.Max((int)(((double)minZ - 8) / 32 + 270), 0);
				int num3 = Mathf.Min((int)(((double)maxX + 8) / 32 + 270), 539);
				int num4 = Mathf.Min((int)(((double)maxZ + 8) / 32 + 270), 539);
				num = 0;
				min = 1024f;
				avg = 0f;
				max = 0f;
				for (int i = num2; i <= num4; i++)
				{
					for (int j = num1; j <= num3; j++)
					{
						uint mTreeGrid = tm.m_treeGrid[i * 540 + j];
						int num5 = 0;
						while (mTreeGrid != 0)
						{
							Vector3 position = tm.m_trees.m_buffer[mTreeGrid].Position;
							if ((double)Mathf.Max(Mathf.Max(minX - 8f - position.x, minZ - 8f - position.z), Mathf.Max((float)((double)position.x - (double)maxX - 8), (float)((double)position.z - (double)maxZ - 8))) < 0)
							{
								TreeInfo info = tm.m_trees.m_buffer[mTreeGrid].Info;
								if (info != null)
								{
									Randomizer randomizer = new Randomizer(mTreeGrid);
									float mMinScale = info.m_minScale + (float)((double)randomizer.Int32(10000) * ((double)info.m_maxScale - (double)info.m_minScale) * 9.99999974737875E-05);
									float mSize = position.y + (float)((double)info.m_generatedInfo.m_size.y * (double)mMinScale * 2);
									if ((double)mSize < (double)min)
									{
										min = mSize;
									}
									avg = avg + mSize;
									if ((double)mSize > (double)max)
									{
										max = mSize;
									}
									num = num + 1;
								}
							}
							mTreeGrid = tm.m_trees.m_buffer[mTreeGrid].m_nextGridTree;
							int num6 = num5 + 1;
							num5 = num6;
							if (num6 < LimitTreeManager.Helper.TreeLimit)
							{
								continue;
							}
							CODebugBase<LogChannel>.Error(LogChannel.Core, string.Concat("Invalid list detected!\n", Environment.StackTrace));
							break;
						}
					}
				}
				if ((double)avg == 0)
				{
					return;
				}
				avg = avg / (float)num;
			}
		}
コード例 #18
0
                    public TreeClient(int apiVersion = RichHudMaster.apiVID)
                    {
                        this.apiVersion = apiVersion;

                        updateAccessors = new List <HudUpdateAccessors>();
                        Registered      = TreeManager.RegisterClient(this);
                    }
コード例 #19
0
 public override void Close()
 {
     InputMode    = HudInputMode.NoInput;
     EnableCursor = false;
     instance     = null;
     treeManager  = null;
 }
コード例 #20
0
        public IList <string> RemoveSubfolders1(string[] folder)
        {
            /*
             * 问题:在给定的文件夹列表中,去掉子文件夹
             * 思路:
             *  1. 借用Trie树的构建思路,另外做特殊处理
             *  2. 将文件夹路径,按照"\"分隔,得到多个组成部分,把他们构造到Trie树当中
             *  3. 对于树中的每个节点,需要记录的是:
             *       3.1 节点存储的字符串
             *       3.2 当前节点,是否是文件夹的终点
             *       3.3 如果不是文件夹的终点,有多少子文件夹
             *  4. 先构建Trie树,然后使用回溯法遍历得到的结果,就是解
             *
             * 关键点:
             *
             * 时间复杂度:O(n)
             * 空间复杂度:O(n)
             */

            var treeTemp = new TreeManager();

            foreach (var folderItem in folder)
            {
                treeTemp.AddNode(folderItem);
            }

            return(treeTemp.ForReturn());
        }
コード例 #21
0
ファイル: FormMain.cs プロジェクト: NTDLS/LeafSQL
        public FormMain()
        {
            InitializeComponent();

            tabManager  = new TabManager(tabControlPages);
            treeManager = new TreeManager(treeViewDatabase);
        }
コード例 #22
0
        public void DeleteAllTrees()
        {
            int         r  = TreeManager.TREEGRID_RESOLUTION;    // 540
            TreeManager tm = TreeManager.instance;

            if (tm.m_treeCount == 0)
            {
                return;
            }

            uint tot = 0;

            for (int i = 0; i < r * r; i++)
            {
                uint id = tm.m_treeGrid[i];
                if (id != 0)
                {
                    while (id != 0 && tot++ < TreeManager.MAX_MAP_TREES)
                    {
                        uint next = tm.m_trees.m_buffer[id].m_nextGridTree;
                        SimulationManager.instance.AddAction(DelTree(id));
                        id = next;
                    }
                    ;
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Deletes the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        public static void DeleteFolder(CalendarFolder folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                TreeService treeService = folder.GetTreeService();

                //Erase all child folders
                foreach (TreeNode node in TreeManager.GetAllChildNodes(treeService.CurrentNode))
                {
                    CalendarFolder childFolder = (CalendarFolder)node.InnerObject;
                    EraseFolder(childFolder);
                    treeService.RemoveChild(node.ObjectId);
                    childFolder.Delete();
                }

                //Erase current folder
                EraseFolder(folder);
                folder.Delete();

                tran.Commit();
            }
        }
コード例 #24
0
        /// <summary>
        /// The original C/O code to loop though the tree array and update m_infoIndex
        /// on all treeinstances with non-null .Info's with updated m_prefabDataIndex values.
        /// </summary>
        public static void DoOriginal()
        {
            TreeManager instance = Singleton <TreeManager> .instance;

            TreeInstance[] buffer = instance.m_trees.m_buffer;
            int            num    = buffer.Length;

            for (int i = 1; i < num; i++)
            {
                if (buffer[i].m_flags != 0)
                {
                    TreeInfo info = buffer[i].Info;
                    if (info != null)
                    {
                        buffer[i].m_infoIndex = (ushort)info.m_prefabDataIndex;
                    }
                    if (buffer[i].GrowState != 0)
                    {
                        DistrictManager instance2 = Singleton <DistrictManager> .instance;
                        byte            park      = instance2.GetPark(buffer[i].Position);
                        ++instance2.m_parks.m_buffer[(int)park].m_treeCount;
                    }
                }
            }
        }
コード例 #25
0
        /// <summary>
        /// A method to remove *ALL* tress from a map.
        /// This is provided only as an emergency option for people with really broken maps as a last resort.
        /// </summary>
        /// <param name="confirmed">If not set to true function does nothing</param>
        internal static void RemoveAllTrees(bool confirmed)
        {
            int c = 0;

            try
            {
                if (confirmed == true & OptionsWrapper <Configuration> .Options.EmergencyOnly_RemoveAllTrees == true & OptionsWrapper <Configuration> .Options.IsLoggingEnabled() == true & OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1 & OptionsWrapper <Configuration> .Options.NullTreeOptionsIndex == (int)NullTreeOptions.RemoveTree)
                {
                    TreeManager    treeManager = Singleton <TreeManager> .instance;
                    TreeInstance[] tBuffer     = treeManager.m_trees.m_buffer;
                    Logger.dbgLog("Now deleating all active trees as requested!");
                    for (uint i = 1; i < tBuffer.Length; i++)
                    {
                        if (tBuffer[i].m_flags != 0)
                        {
                            treeManager.ReleaseTree(i);
                            c++;
                        }
                    }
                    Logger.dbgLog("Removed all " + c.ToString() + " active trees as instructed!");
                }
                else
                {
                    Logger.dbgLog("*** You tried a danagerous EmergencyOnly_RemoveAllTrees option but did not enable debug level 2 and-or RemoveTree settings, for your safety we did not do anything.  ***");
                }
            }
            catch (Exception ex)
            {
                Logger.dbgLog("Could not remove all trees as instructed due to errors " + c.ToString() + " were removed.", ex, true);
            }
        }
コード例 #26
0
        public static void ResetAllBurningTrees(bool ClearBurningBufferToo)
        {
            try
            {
                //List<int> theList = DumpBurningTreesToList(true);
                TreeManager        tm = Singleton <TreeManager> .instance;
                TreeInstance.Flags tflags;
                ushort             sourceFlags = 0;
                int counter = 0; int counter2 = 0;
                for (int i = 1; i < tm.m_trees.m_buffer.Length; i++)
                {
                    sourceFlags = tm.m_trees.m_buffer[i].m_flags;
                    tflags      = (TreeInstance.Flags)sourceFlags;
                    if (HasTreeFlags(tflags, TreeInstance.Flags.Created) && (HasTreeFlags(tflags, TreeInstance.Flags.Burning) | HasTreeFlags(tflags, TreeInstance.Flags.FireDamage)))
                    {
                        tflags &= ~(TreeInstance.Flags.Burning | TreeInstance.Flags.FireDamage);
                        tm.m_trees.m_buffer[i].m_flags = (ushort)tflags;
                        counter++;
                    }
                }

                if (ClearBurningBufferToo)
                {
                    counter2 = tm.m_burningTrees.m_size;
                    tm.m_burningTrees.Clear();
                    tm.m_burningTrees.Trim();
                }
                Logger.dbgLog(string.Format("debug user reset all {0} burning trees, and {1} in the burningfastlist.", counter.ToString(), counter2.ToString()));
            }
            catch (Exception ex)
            {
                Logger.dbgLog("Error: ", ex);
            }
        }
コード例 #27
0
        /// <summary>
        /// Replaces a map tree.
        /// </summary>
        /// <param name="target">Tree to replace</param>
        /// <param name="replacement">Replacement tree</param>
        private void ReplaceTrees(TreeInfo target, TreeInfo replacement)
        {
            // Check for valid parameters.
            if (target != null && replacement != null)
            {
                // Local references.
                TreeManager    treeManager = Singleton <TreeManager> .instance;
                TreeInstance[] trees       = treeManager.m_trees.m_buffer;

                Logging.Message("replacing tree ", target.name, " with ", replacement.name);

                // Iterate through each tree in map.
                for (uint treeIndex = 0; treeIndex < trees.Length; ++treeIndex)
                {
                    // Local reference.
                    TreeInstance tree = trees[treeIndex];

                    // Skip non-existent trees (those with no flags).
                    if (tree.m_flags == (ushort)TreeInstance.Flags.None)
                    {
                        continue;
                    }

                    // If tree matches, replace!
                    if (tree.Info == target)
                    {
                        trees[treeIndex].Info = replacement;

                        // Refresh tree render (to update LOD).
                        treeManager.UpdateTreeRenderer(treeIndex, true);
                    }
                }
            }
        }
コード例 #28
0
ファイル: GameTests.cs プロジェクト: cyecp/DeltaEngine.OpenTK
        public void ShortTreeDistance()
        {
            var trees = new TreeManager(Team.HumanYellow);

            trees.AddTree(new Vector2D(0.35f, 0.4f), Team.HumanYellow);
            trees.AddTree(new Vector2D(0.65f, 0.5f), Team.None);
        }
コード例 #29
0
        public static void Run()
        {
            var i = 0;
            var j = 7;

            var rootBranch = new Branch(TBranch.Sequence);

            for (int k = 0; k < 10; k++)
            {
                rootBranch.AddNode(new Branch(TBranch.Selector).AddNode(new Leaf(() => {
                    var result = i > j ? TOperation.Success : TOperation.Failure;
                    Console.WriteLine($"i is {i}, check completed, result: {result}");
                    return(result);
                })).AddNode(new Leaf(() => {
                    i++;
                    Console.WriteLine($"Now i is {i}");
                    return(TOperation.Success);
                }))).AddNode(new Leaf(() => {
                    var result = i < j ? TOperation.Success : TOperation.Failure;
                    Console.WriteLine($"i less then {j}, result: {result}");
                    return(result);
                }));
            }

            var btManager = new TreeManager(rootBranch);

            btManager.Execute();
        }
コード例 #30
0
/*
 *      public static List<int> DumpBurningTreesToList(bool IncludeFireDamaged = false)
 *      {
 *          List<int> theList = new List<int>(32);
 *          try
 *          {
 *
 *              TreeManager tm = Singleton<TreeManager>.instance;
 *              ushort sourceFlags = 0;
 *              int burningcounter = 0;
 *              TreeInstance.Flags flags;
 *              for (int i = 1; i < tm.m_trees.m_buffer.Length; i++)
 *              {
 *                  sourceFlags = tm.m_trees.m_buffer[i].m_flags;
 *                  flags = (TreeInstance.Flags)sourceFlags;
 *                  if(IncludeFireDamaged)
 *                  {
 *                      if (HasTreeFlags(flags, TreeInstance.Flags.Created) && (HasTreeFlags(flags, TreeInstance.Flags.Burning) | HasTreeFlags(flags, TreeInstance.Flags.FireDamage)))
 *                      {
 *                          theList.Add(i);
 *                          burningcounter++;
 *                      }
 *                  }
 *                  else
 *                  {
 *                      if (HasTreeFlags(flags, TreeInstance.Flags.Created) && HasTreeFlags(flags, TreeInstance.Flags.Burning))
 *                      {
 *                          theList.Add(i);
 *                          burningcounter++;
 *                      }
 *                  }
 *              }
 *              Logger.dbgLog("--done, processed " + burningcounter.ToString() + " created and burning trees");
 *          }
 *          catch (Exception ex)
 *          { Logger.dbgLog("error: ", ex); }
 *
 *          return theList;
 *      }
 */

        public static void DumpBurningTrees(bool IncludeFireDamaged = false)
        {
            try
            {
                TreeManager tm          = Singleton <TreeManager> .instance;
                ushort      sourceFlags = 0;
                Logger.dbgLog("----- burning trees dump -----");
                byte               logcounter     = 0;
                int                burningcounter = 0;
                string             tmpstr         = "";
                TreeInstance.Flags flags;
                for (int i = 1; i < tm.m_trees.m_buffer.Length; i++)
                {
                    sourceFlags = tm.m_trees.m_buffer[i].m_flags;
                    flags       = (TreeInstance.Flags)sourceFlags;
                    if (HasTreeFlags(flags, TreeInstance.Flags.Created) && HasTreeFlags(flags, TreeInstance.Flags.Burning))
                    {
                        burningcounter++;
                        tmpstr = tmpstr + string.Format("Treeidx:{0} flags:{1}  ", i.ToString(), sourceFlags.ToString());
                        logcounter++;
                    }
                    if (logcounter > 3)
                    {
                        Logger.dbgLog(tmpstr, null, false, true); //dump 4 per line.
                        tmpstr     = "";
                        logcounter = 0;
                    }
                }
                Logger.dbgLog("--done, processed " + burningcounter.ToString() + " created and burning trees");
            }
            catch (Exception ex)
            { Logger.dbgLog("error: ", ex); }
        }
コード例 #31
0
ファイル: GenerationManager.cs プロジェクト: Mcfli/Moai
    void Start () {
        player = GameObject.FindGameObjectWithTag("Player");
        tree_manager = gameObject.GetComponent<TreeManager>();
        chunkGen = gameObject.GetComponent<ChunkGenerator>();
        weather_manager = gameObject.GetComponent<WeatherManager>();
        shrine_manager = gameObject.GetComponent<ShrineManager>();
        chunkGen.chunk_size = chunk_size;
        chunkGen.chunk_resolution = chunk_resolution;
        cur_chunk = new Vector2(-1, -1);
        loaded_chunks = new List<Vector2>();
        loaded_tree_chunks = new List<Vector2>();
		loaded_shrine_chunks = new List<Vector2>();
    }
コード例 #32
0
ファイル: GameTests.cs プロジェクト: whztt07/DeltaEngine
		public void SendGhostsFromOneTreeToAnother()
		{
			var trees = new TreeManager(Team.HumanYellow);
			trees.AddTree(new Vector2D(0.75f, 0.4f), Team.HumanYellow);
			trees.AddTree(new Vector2D(0.25f, 0.55f), Team.None);
		}
コード例 #33
0
ファイル: GameTests.cs プロジェクト: whztt07/DeltaEngine
		public void ShortTreeDistance()
		{
			var trees = new TreeManager(Team.HumanYellow);
			trees.AddTree(new Vector2D(0.35f, 0.4f), Team.HumanYellow);
			trees.AddTree(new Vector2D(0.65f, 0.5f), Team.None);
		}
コード例 #34
0
 public FmSelectPoint(IDEInterop ide, TreeManager treeManager)
 {
     _ide = ide;
     _treeManager = treeManager;
     InitializeComponent();
 }
コード例 #35
0
 public void TestCleanup()
 {
     database = null;
     userManager = null;
 }
コード例 #36
0
        public void TestInit()
        {
            database = new PwDatabase();
            database.RootGroup = new PwGroup();
            userManager = new TreeManager();
            userManager.Initialize( database );

            rootGroup = database.RootGroup;

            normalEntry1 = new PwEntry( true, false );
            normalEntry2 = new PwEntry( true, false );
            normalEntry3 = new PwEntry( true, false );
            pwdProxyTo1 = new PwEntry( true, false );
            pwdProxyTo3 = new PwEntry( true, false );
            pwdProxyTo3_1 = new PwEntry( true, false );
            proxyToRoot1 = new PwEntry( true, false );
            brokenProxy1 = new PwEntry( true, false );
            brokenProxy2 = new PwEntry( true, false );

            //initial data
            root1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, root1.Uuid.ToHexString() ) );
            root2.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, root2.Uuid.ToHexString() ) );

            //pwdProxies
            pwdProxyTo1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, normalEntry1.Uuid.ToHexString() ) );
            pwdProxyTo3.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, normalEntry3.Uuid.ToHexString() ) );
            pwdProxyTo3_1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, normalEntry3.Uuid.ToHexString() ) );
            //proxyNode => references rootNode1
            proxyToRoot1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, root1.Uuid.ToHexString() ) );

            //entry with empty stringfield
            brokenProxy1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, "" ) );
            //entry with junk stringfield
            brokenProxy2.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString( false, "falseLinkToNonhere" ) );

            rootGroup.AddEntry( root1, true );
            rootGroup.AddEntry( root2, true );
            rootGroup.AddEntry( normalEntry1, true );
            rootGroup.AddEntry( normalEntry2, true );
            rootGroup.AddEntry( normalEntry3, true );
            rootGroup.AddEntry( pwdProxyTo1, true );
            rootGroup.AddEntry( pwdProxyTo3, true );
            rootGroup.AddEntry( pwdProxyTo3_1, true );
            rootGroup.AddEntry( brokenProxy1, true );
            rootGroup.AddEntry( proxyToRoot1, true );
            rootGroup.AddEntry( brokenProxy2, true );
        }
コード例 #37
0
        public void IsParentTest()
        {
            PwDatabase db = new PwDatabase();
            db.RootGroup = new PwGroup();
            TreeManager um = new TreeManager();
            userManager.Initialize( db );
            rootGroup = db.RootGroup;

            //groups are named like g<# of group>_<level in tree> level 0 is the copyRootGroup
            PwGroup g1_1 = new PwGroup( true, true, "g1_1", PwIcon.Apple );
            PwGroup g2_1 = new PwGroup( true, true, "g2_1", PwIcon.Apple );
            PwGroup g3_2 = new PwGroup( true, true, "g3_2", PwIcon.Apple );
            PwGroup g4_3 = new PwGroup( true, true, "g4_3", PwIcon.Apple );

            rootGroup.AddGroup( g1_1, true );
            rootGroup.AddGroup( g2_1, true );
            g2_1.AddGroup( g3_2, true );
            g3_2.AddGroup( g4_3, true );

            PwEntry pe1_0 = new PwEntry( true, true );
            PwEntry pe2_1 = new PwEntry( true, true );
            PwEntry pe3_2 = new PwEntry( true, true );
            PwEntry pe4_3 = new PwEntry( true, true );

            rootGroup.AddEntry( pe1_0, true );
            g2_1.AddEntry( pe2_1, true );
            g3_2.AddEntry( pe3_2, true );
            g4_3.AddEntry( pe4_3, true );

            Assert.IsTrue( pe1_0.IsInsideParent( rootGroup ) );
            Assert.IsTrue( pe4_3.IsInsideParent( rootGroup ) );
            Assert.IsTrue( pe4_3.IsInsideParent( g2_1 ) );
            Assert.IsTrue( g4_3.IsInsideParent( g2_1 ) );
            Assert.IsTrue( g4_3.IsInsideParent( rootGroup ) );

            Assert.IsFalse( pe1_0.IsInsideParent( g2_1 ) );
            Assert.IsFalse( pe4_3.IsInsideParent( g1_1 ) );
            Assert.IsFalse( pe2_1.IsInsideParent( g3_2 ) );
            Assert.IsFalse( g2_1.IsInsideParent( g4_3 ) );
        }
コード例 #38
0
ファイル: VillageGen.cs プロジェクト: nathn123/Ai-RTS-Game
	// Use this for initialization
	void Start () {
        TaskExecutives = new List<VillageManager>();
        TreeMgr = new TreeManager();
	
	}
コード例 #39
0
 public void Initialise(Vector2 StartingPos_,int VillageNum_,AI_Bias bias,TreeManager TreeMgr_,ref char[,] AiMap_, VillageGen.Scenario NewScenario = new VillageGen.Scenario())
 {
     if(VillageNum_ == 0)
     {
         MaleVillager = Resources.Load<GameObject>("Characters/Prefabs/Male 1");
         FemaleVillager = Resources.Load<GameObject>("Characters/Prefabs/Female 1");
     }
     else if (VillageNum_ == 1)
     {
         MaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Male 2.prefab");
         FemaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Female 2.prefab");
     }
     else if (VillageNum_ == 2)
     {
         MaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Male 3.prefab");
         FemaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Female 3.prefab");
     }
     else if (VillageNum_ == 3)
     {
         MaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Male 4.prefab");
         FemaleVillager = Resources.Load<GameObject>(Application.dataPath + "Characters/Prefabs/Female 4.prefab");
     }
     VillageNum = VillageNum_;
     TaskPlanner = new TaskPlanning();
     TaskPlanner.Initialise();
     PathPlanner = new PathPlanning();
     PathPlanner.Initialise(ref AiMap_);
     CurrentObj = new List<ObjectiveTasks>();
     CurrentBias = bias;
     AiMap = AiMap_;
     Villagers = new List<Villager>();
     AvailableVillagers = new List<Villager>();
     Buildings = new List<Building>();
     TreeMgr = TreeMgr_;
     if (!NewScenario.Created)
     {
         Villagers.Add((GameObject.Instantiate(MaleVillager, new Vector3(StartingPos_.x, StartingPos_.y), Quaternion.identity) as GameObject).GetComponent<Villager>());
         Villagers.Add((GameObject.Instantiate(FemaleVillager, new Vector3(StartingPos_.x, StartingPos_.y), Quaternion.identity) as GameObject).GetComponent<Villager>());
         StartingPos = StartingPos_;
         foreach (var vill in Villagers)
             vill.Initialise(StartingPos_);
         AvailableVillagers.AddRange(Villagers);
         Initialised = true;
     }
     else
     {
         StartingPos = new Vector2(NewScenario.Xpos, NewScenario.Ypos);
         // gen scenario
         for (int i = 0; i < NewScenario.Barracks; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Barracks));
         for (int i = 0; i < NewScenario.BlackS; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Blacksmith));
         for (int i = 0; i < NewScenario.House; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.House));
         for (int i = 0; i < NewScenario.Market; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Market));
         for (int i = 0; i < NewScenario.Mine; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Mine));
         for (int i = 0; i < NewScenario.Quarry; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Quarry));
         for (int i = 0; i < NewScenario.Saw; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Sawmill));
         for (int i = 0; i < NewScenario.School; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.School));
         for (int i = 0; i < NewScenario.Smelter; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Smelter));
         for (int i = 0; i < NewScenario.Storage; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Storage));
         for (int i = 0; i < NewScenario.Turf; i++)
             Buildings.Add(GenerateBuildingSite(Building.BuildingType.Turf));
         for (int i = 0; i < NewScenario.Villagers; i++)
             Villagers.Add((GameObject.Instantiate(MaleVillager, new Vector3(StartingPos_.x, StartingPos_.y), Quaternion.identity) as GameObject).GetComponent<Villager>());
         
     }
 }