本文整理汇总了C#中TEditXNA.Terraria.World.ResetTime方法的典型用法代码示例。如果您正苦于以下问题:C# World.ResetTime方法的具体用法?C# World.ResetTime怎么用?C# World.ResetTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TEditXNA.Terraria.World
的用法示例。
在下文中一共展示了World.ResetTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public static void Save(World world, string filename, bool resetTime = false)
{
try
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
world.Validate();
}
catch (ArgumentOutOfRangeException err)
{
string msg = string.Format("There is a problem in your world.\r\n" +
"{0}\r\nThis world will not open in Terraria\r\n" +
"Would you like to save anyways??\r\n"
, err.ParamName);
if (MessageBox.Show(msg, "World Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
MessageBoxResult.Yes)
return;
}
lock (_fileLock)
{
if (resetTime)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
world.ResetTime();
}
if (filename == null)
return;
string temp = filename + ".tmp";
using (var fs = new FileStream(temp, FileMode.Create))
{
using (var bw = new BinaryWriter(fs))
{
if (world.Version > 87)
SaveV2(world, bw);
else
SaveV1(world, bw);
bw.Close();
fs.Close();
// make a backup of current file if it exists
if (File.Exists(filename))
{
string backup = filename + ".TEdit";
File.Copy(filename, backup, true);
}
// replace actual file with temp save file
File.Copy(temp, filename, true);
// delete temp save file
File.Delete(temp);
OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
}
}
world._lastSave = File.GetLastWriteTimeUtc(filename);
}
}
示例2: NewWorldView
public NewWorldView()
{
InitializeComponent();
_newWorld = new World(1200, 4300, "TEdit World");
_newWorld.Version = World.CompatibleVersion;
_newWorld.GroundLevel = 350;
_newWorld.RockLevel = 480;
_newWorld.ResetTime();
AddCharNames();
this.DataContext = NewWorld;
}
示例3: Save
public static void Save(World world, string filename, bool resetTime = false)
{
lock (_fileLock)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
world.Validate();
if (resetTime)
{
OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
world.ResetTime();
}
if (filename == null)
return;
string temp = filename + ".tmp";
using (var fs = new FileStream(temp, FileMode.Create))
{
using (var bw = new BinaryWriter(fs))
{
if (CompatibleVersion > 87)
SaveV2(world, bw);
else
SaveV1(world, bw);
bw.Close();
fs.Close();
// make a backup of current file if it exists
if (File.Exists(filename))
{
string backup = filename + ".TEdit";
File.Copy(filename, backup, true);
}
// replace actual file with temp save file
File.Copy(temp, filename, true);
// delete temp save file
File.Delete(temp);
OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
}
}
world._lastSave = File.GetLastWriteTimeUtc(filename);
}
}