当前位置: 首页>>代码示例>>C#>>正文


C# Main.ClearEntities方法代码示例

本文整理汇总了C#中Main.ClearEntities方法的典型用法代码示例。如果您正苦于以下问题:C# Main.ClearEntities方法的具体用法?C# Main.ClearEntities怎么用?C# Main.ClearEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Main的用法示例。


在下文中一共展示了Main.ClearEntities方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Reload

        public static void Reload(Main main, bool deleteEditor = true)
        {
            main.LoadingMap.Execute(main.MapFile);
            using (Stream stream = new MemoryStream())
            {
                XmlSerializer serializer = new XmlSerializer(typeof(List<Entity>));
                serializer.Serialize(stream, main.Entities.Where(x => x.Serialize).ToList());

                main.ClearEntities(deleteEditor);

                stream.Seek(0, SeekOrigin.Begin);

                List<Entity> entities = (List<Entity>)serializer.Deserialize(stream);

                foreach (Entity entity in entities)
                {
                    Factory factory = Factory.Get(entity.Type);
                    factory.Bind(entity, main);
                    main.Add(entity);
                }
            }
            main.MapLoaded.Execute();
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:23,代码来源:MapLoader.cs

示例2: Load

		private static void Load(Main main, Stream stream, bool deleteEditor = true)
		{
			main.Camera.Position.Value = new Vector3(0, -10000, 0);
			main.IsLoadingMap = true;
			main.ClearEntities(deleteEditor);

			List<Entity> entities = null;
			try
			{
				entities = (List<Entity>)MapLoader.Serializer.Deserialize(stream);
			}
			catch (InvalidOperationException e)
			{
				throw new Exception("Failed to deserialize file stream.", e);
			}

			foreach (Entity entity in entities)
			{
				Factory<Main> factory = Factory<Main>.Get(entity.Type);
				factory.Bind(entity, main);
				main.Add(entity);
			}

			main.IsLoadingMap = false;
			main.MapLoaded.Execute();
		}
开发者ID:sparker,项目名称:Lemma,代码行数:26,代码来源:MapLoader.cs

示例3: load

		private static void load(Main main, Stream stream, bool deleteEditor, Entity playerData)
		{
			main.Camera.Position.Value = new Vector3(0, -1000, 0);
			main.IsLoadingMap = true;
			main.ClearEntities(deleteEditor);

			if (stream == null)
				main.DefaultLighting(); // There's no World entity to set the correct lighting, so set the defaults
			else
			{
				List<Entity> entities = null;
				try
				{
					entities = (List<Entity>)MapLoader.Serializer.Deserialize(stream);
				}
				catch (InvalidOperationException e)
				{
					throw new Exception("Failed to deserialize file stream.", e);
				}

				if (playerData != null)
					entities.Add(playerData);

				foreach (Entity entity in entities)
				{
					Factory<Main> factory = Factory<Main>.Get(entity.Type);
					if (factory != null)
					{
						factory.Bind(entity, main);
						main.Add(entity);
					}
				}
			}

			main.IsLoadingMap = false;
			main.MapLoaded.Execute();
		}
开发者ID:dsmo7206,项目名称:Lemma,代码行数:37,代码来源:MapLoader.cs

示例4: New

		public static void New(Main main, string filename, string templateMap)
		{
			main.LoadingMap.Execute(filename);

			main.MapFile.Value = filename;

			if (!filename.EndsWith(MapLoader.MapExtension))
				filename += MapLoader.MapExtension;

			main.ClearEntities(false);

			if (!templateMap.EndsWith(MapLoader.MapExtension))
				templateMap += MapLoader.MapExtension;

			using (Stream fs = File.OpenRead(templateMap))
			{
				using (Stream stream = new GZipInputStream(fs))
					MapLoader.load(main, stream, false, null);
			}
			WorldFactory.Instance.Get<World>().NewUUID();
		}
开发者ID:dsmo7206,项目名称:Lemma,代码行数:21,代码来源:MapLoader.cs


注:本文中的Main.ClearEntities方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。