本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}