本文整理汇总了C#中fCraft.SchedulerTask类的典型用法代码示例。如果您正苦于以下问题:C# SchedulerTask类的具体用法?C# SchedulerTask怎么用?C# SchedulerTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchedulerTask类属于fCraft命名空间,在下文中一共展示了SchedulerTask类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Beat
static void Beat( SchedulerTask scheduledTask ) {
if( Server.IsShuttingDown ) return;
if( ConfigKey.HeartbeatEnabled.Enabled() ) {
SendMinecraftNetBeat();
if( ConfigKey.IsPublic.Enabled() && ConfigKey.HeartbeatToWoMDirect.Enabled() ) {
SendWoMDirectBeat();
}
} else {
// If heartbeats are disabled, the server data is written
// to a text file instead (heartbeatdata.txt)
string[] data = new[] {
Salt,
Server.InternalIP.ToString(),
Server.Port.ToStringInvariant(),
Server.CountPlayers( false ).ToStringInvariant(),
ConfigKey.MaxPlayers.GetString(),
ConfigKey.ServerName.GetString(),
ConfigKey.IsPublic.GetString(),
ConfigKey.WoMDirectDescription.GetString(),
ConfigKey.WoMDirectFlags.GetString(),
ConfigKey.HeartbeatToWoMDirect.Enabled().ToString()
};
const string tempFile = Paths.HeartbeatDataFileName + ".tmp";
File.WriteAllLines( tempFile, data, Encoding.ASCII );
Paths.MoveOrReplaceFile( tempFile, Paths.HeartbeatDataFileName );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:29,代码来源:Heartbeat.cs
示例2: ZombieGame
public ZombieGame( World world )
{
_world = world;
startTime = DateTime.Now;
_humanCount = _world.Players.Length;
_task = new SchedulerTask( Interval, false ).RunForever( TimeSpan.FromSeconds( 1 ) );
_world.gameMode = GameMode.ZombieSurvival;
Player.Moved += OnPlayerMoved;
Player.JoinedWorld += OnChangedWorld;
}
开发者ID:727021,项目名称:800craft,代码行数:10,代码来源:ZombieGame.cs
示例3: GetInstance
public static TeamDeathMatch GetInstance(World world)
{
if (instance == null)
{
TDMworld_ = world;
instance = new TeamDeathMatch();
startTime = DateTime.UtcNow;
task_ = new SchedulerTask(Interval, true).RunForever(TimeSpan.FromSeconds(1));
}
return instance;
}
开发者ID:venofox,项目名称:AtomicCraft,代码行数:11,代码来源:TeamDeathMatch.cs
示例4: Interval
public void Interval( SchedulerTask task )
{
//check to stop Interval
if ( _world.gameMode != GameMode.ZombieSurvival || _world == null ) {
_world = null;
task.Stop();
return;
}
if ( !_started ) {
if ( startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 1 ) {
/*if (_world.Players.Length < 3){
_world.Players.Message("&WThe game failed to start: 2 or more players need to be in the world");
Stop(null);
return;
}*/
ShufflePlayerPositions();
_started = true;
RandomPick();
lastChecked = DateTime.Now;
return;
}
}
//calculate humans
_humanCount = _world.Players.Where( p => p.iName != _zomb ).Count();
//check if zombies have won already
if ( _started ) {
if ( _humanCount == 1 && _world.Players.Count() == 1 ) {
_world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
Stop( null );
return;
}
if ( _humanCount == 0 ) {
_world.Players.Message( "&WThe Humans have failed to survive... &9ZOMBIES WIN!" );
Stop( null );
return;
}
}
//check if 5mins is up and all zombies have failed
if ( _started && startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 6 ) {
_world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
Stop( null );
return;
}
//if no one has won, notify players of their status every 31s
if ( lastChecked != null && ( DateTime.Now - lastChecked ).TotalSeconds > 30 ) {
_world.Players.Message( "&WThere are {0} humans", _humanCount.ToString() );
foreach ( Player p in _world.Players ) {
if ( p.iName == _zomb ) p.Message( "&8You are " + _zomb );
else p.Message( "&8You are a Human" );
}
lastChecked = DateTime.Now;
}
}
开发者ID:727021,项目名称:800craft,代码行数:53,代码来源:ZombieGame.cs
示例5: GetInstance
public static ZombieGame GetInstance(World world)
{
if (instance == null)
{
_world = world;
instance = new ZombieGame();
startTime = DateTime.Now;
_humanCount = _world.Players.Length;
_world.Players.Message(_humanCount.ToString());
Player.Moved += OnPlayerMoved;
_task = new SchedulerTask(Interval, true).RunForever(TimeSpan.FromSeconds(1));
//_world.positions = new Player[_world.Map.Width,
// _world.Map.Length, _world.Map.Height];
_world.gameMode = GameMode.ZombieSurvival;
}
return instance;
}
开发者ID:zINaPalm,项目名称:LegendCraftSource,代码行数:17,代码来源:ZombieGame.cs
示例6: UpdateTask
void UpdateTask( SchedulerTask task ) {
Map tempMap = Map;
if( tempMap != null ) {
tempMap.ProcessUpdates();
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:6,代码来源:World.cs
示例7: FireEvent
static void FireEvent( EventHandler<SchedulerTaskEventArgs> eventToFire, SchedulerTask task ) {
var h = eventToFire;
if( h != null ) h( null, new SchedulerTaskEventArgs( task ) );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:4,代码来源:Scheduler.cs
示例8: MonitorProcessorUsage
static void MonitorProcessorUsage( SchedulerTask task ) {
TimeSpan newCPUTime = Process.GetCurrentProcess().TotalProcessorTime - cpuUsageStartingOffset;
CPUUsageLastMinute = ( newCPUTime - oldCPUTime ).TotalSeconds /
( Environment.ProcessorCount * DateTime.UtcNow.Subtract( lastMonitorTime ).TotalSeconds );
lastMonitorTime = DateTime.UtcNow;
CPUUsageTotal = newCPUTime.TotalSeconds /
( Environment.ProcessorCount * DateTime.UtcNow.Subtract( StartTime ).TotalSeconds );
oldCPUTime = newCPUTime;
IsMonitoringCPUUsage = true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:10,代码来源:Server.cs
示例9: TimeCheck
static void TimeCheck(SchedulerTask task)
{
foreach (World world in WorldManager.Worlds)
{
if (world.RealisticEnv)
{
int sky;
int clouds;
int fog;
DateTime now = DateTime.Now;
var SunriseStart = new TimeSpan(6, 30, 0);
var SunriseEnd = new TimeSpan(7, 29, 59);
var MorningStart = new TimeSpan(7, 30, 0);
var MorningEnd = new TimeSpan(11, 59, 59);
var NormalStart = new TimeSpan(12, 0, 0);
var NormalEnd = new TimeSpan(16, 59, 59);
var EveningStart = new TimeSpan(17, 0, 0);
var EveningEnd = new TimeSpan(18, 59, 59);
var SunsetStart = new TimeSpan(19, 0, 0);
var SunsetEnd = new TimeSpan(19, 29, 59);
var NightaStart = new TimeSpan(19, 30, 0);
var NightaEnd = new TimeSpan(1, 0, 1);
var NightbStart = new TimeSpan(1, 0, 2);
var NightbEnd = new TimeSpan(6, 29, 59);
if (now.TimeOfDay > SunriseStart && now.TimeOfDay < SunriseEnd) //sunrise
{
sky = ParseHexColor("ffff33");
clouds = ParseHexColor("ff0033");
fog = ParseHexColor("ff3333");
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Water;
WorldManager.SaveWorldList();
return;
}
if (now.TimeOfDay > MorningStart && now.TimeOfDay < MorningEnd) //end of sunrise
{
sky = -1;
clouds = ParseHexColor("ff0033");
fog = ParseHexColor("fffff0");
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Water;
WorldManager.SaveWorldList();
return;
}
if (now.TimeOfDay > NormalStart && now.TimeOfDay < NormalEnd)//env normal
{
sky = -1;
clouds = -1;
fog = -1;
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Water;
WorldManager.SaveWorldList();
return;
}
if (now.TimeOfDay > EveningStart && now.TimeOfDay < EveningEnd) //evening
{
sky = ParseHexColor("99cccc");
clouds = -1;
fog = ParseHexColor("99ccff");
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Water;
WorldManager.SaveWorldList();
return;
}
if (now.TimeOfDay > SunsetStart && now.TimeOfDay < SunsetEnd) //sunset
{
sky = ParseHexColor("9999cc");
clouds = ParseHexColor("000033");
fog = ParseHexColor("cc9966");
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Water;
WorldManager.SaveWorldList();
return;
}
if (now.TimeOfDay > NightaStart && now.TimeOfDay < NightaEnd) //end of sunset
{
sky = ParseHexColor("003366");
clouds = ParseHexColor("000033");
fog = ParseHexColor("000033");
world.SkyColor = sky;
world.CloudColor = clouds;
world.FogColor = fog;
world.EdgeBlock = Block.Black;
WorldManager.SaveWorldList();
//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:WorldCommands.cs
示例10: DoGC
static void DoGC( SchedulerTask task ) {
if( !gcRequested ) return;
gcRequested = false;
Process proc = Process.GetCurrentProcess();
proc.Refresh();
long usageBefore = proc.PrivateMemorySize64 / ( 1024 * 1024 );
GC.Collect( GC.MaxGeneration, GCCollectionMode.Forced );
proc.Refresh();
long usageAfter = proc.PrivateMemorySize64 / ( 1024 * 1024 );
Logger.Log( LogType.Debug,
"Server.DoGC: Collected on schedule ({0}->{1} MB).",
usageBefore, usageAfter );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:17,代码来源:Server.cs
示例11: ShowRandomAnnouncement
// shows announcements
static void ShowRandomAnnouncement( SchedulerTask task ) {
if( !File.Exists( Paths.AnnouncementsFileName ) ) return;
string[] lines = File.ReadAllLines( Paths.AnnouncementsFileName );
if( lines.Length == 0 ) return;
string line = lines[new Random().Next( 0, lines.Length )].Trim();
if( line.Length == 0 ) return;
foreach( Player player in Players.Where( player => player.World != null ) ) {
string announcementLine = Chat.ReplaceTextKeywords( player, line );
announcementLine = Chat.ReplaceEmoteKeywords( announcementLine );
announcementLine = Chat.ReplaceUnicodeWithEmotes( announcementLine );
player.Message( "&R" + announcementLine );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:14,代码来源:Server.cs
示例12: CheckIdles
static void CheckIdles( SchedulerTask task ) {
Player[] tempPlayerList = Players;
for( int i = 0; i < tempPlayerList.Length; i++ ) {
Player player = tempPlayerList[i];
if( player.Info.Rank.IdleKickTimer <= 0 ) continue;
if( player.IdleTime.TotalMinutes >= player.Info.Rank.IdleKickTimer ) {
Message( "{0}&S was kicked for being idle for {1} min",
player.ClassyName,
player.Info.Rank.IdleKickTimer );
string kickReason = "Idle for " + player.Info.Rank.IdleKickTimer + " minutes";
player.Kick( Player.Console, kickReason, LeaveReason.IdleKick, false, true, false );
player.ResetIdleTimer(); // to prevent kick from firing more than once
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:Server.cs
示例13: PruneDBTask
static void PruneDBTask( SchedulerTask task )
{
int removedCount = PlayerDB.RemoveInactivePlayers();
Player player = (Player)task.UserState;
player.Message( "PruneDB: Removed {0} inactive players!", removedCount );
}
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:6,代码来源:MaintenanceCommands.cs
示例14: SaveTask
void SaveTask( SchedulerTask task ) {
if( !IsLoaded ) return;
lock( SyncRoot ) {
if( Map == null ) return;
lock( BackupLock ) {
if( BackupsEnabled &&
DateTime.UtcNow.Subtract( lastBackup ) > BackupInterval &&
( HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled() ) ) {
string backupFileName = String.Format( TimedBackupFormat, Name, DateTime.Now ); // localized
SaveBackup( Path.Combine( Paths.BackupPath, backupFileName ) );
lastBackup = DateTime.UtcNow;
}
}
if( Map.HasChangedSinceSave ) {
SaveMap();
}
if( BlockDB.IsEnabledGlobally && BlockDB.IsEnabled ) {
BlockDB.Flush( true );
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:25,代码来源:World.cs
示例15: doorTimer_Elapsed
static void doorTimer_Elapsed(SchedulerTask task)
{
DoorInfo info = (DoorInfo)task.UserState;
int counter = 0;
for (int x = info.Zone.Bounds.XMin; x <= info.Zone.Bounds.XMax; x++) {
for (int y = info.Zone.Bounds.YMin; y <= info.Zone.Bounds.YMax; y++) {
for (int z = info.Zone.Bounds.ZMin; z <= info.Zone.Bounds.ZMax; z++) {
info.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), info.Buffer[counter]));
counter++;
}
}
}
lock (openDoorsLock) { openDoors.Remove(info.Zone); }
}
开发者ID:Desertive,项目名称:800craft,代码行数:15,代码来源:ZoneCommands.cs
示例16: FlushAll
static void FlushAll( SchedulerTask task )
{
lock( WorldManager.SyncRoot ) {
foreach( World w in WorldManager.Worlds.Where( w => w.BlockDB.IsEnabled ) ) {
w.BlockDB.Flush();
}
}
}
开发者ID:Desertive,项目名称:800craft,代码行数:8,代码来源:BlockDB.cs
示例17: UndoPlayerLookup
// Looks up the changes in BlockDB and prints a confirmation prompt. Runs on a background thread.
static void UndoPlayerLookup( SchedulerTask task ) {
BlockDBUndoArgs args = (BlockDBUndoArgs)task.UserState;
bool allPlayers = ( args.Targets.Length == 0 );
string cmdName = ( args.Not ? "UndoPlayerNot" : "UndoPlayer" );
// prepare to look up
string targetList;
if( allPlayers ) {
targetList = "EVERYONE";
} else if( args.Not ) {
targetList = "EVERYONE except " + args.Targets.JoinToClassyString();
} else {
targetList = args.Targets.JoinToClassyString();
}
BlockDBEntry[] changes;
if( args.CountLimit > 0 ) {
// count-limited lookup
if( args.Targets.Length == 0 ) {
changes = args.World.BlockDB.Lookup( args.CountLimit );
} else {
changes = args.World.BlockDB.Lookup( args.CountLimit, args.Targets, args.Not );
}
if( changes.Length > 0 ) {
Logger.Log( LogType.UserActivity,
"{0}: Asked {1} to confirm undo on world {2}",
cmdName, args.Player.Name, args.World.Name );
args.Player.Confirm( BlockDBUndoConfirmCallback, args,
"Undo last {0} changes made by {1}&S?",
changes.Length, targetList );
}
} else {
// time-limited lookup
if( args.Targets.Length == 0 ) {
changes = args.World.BlockDB.Lookup( Int32.MaxValue, args.AgeLimit );
} else {
changes = args.World.BlockDB.Lookup( Int32.MaxValue, args.Targets, args.Not, args.AgeLimit );
}
if( changes.Length > 0 ) {
Logger.Log( LogType.UserActivity,
"{0}: Asked {1} to confirm undo on world {2}",
cmdName, args.Player.Name, args.World.Name );
args.Player.Confirm( BlockDBUndoConfirmCallback, args,
"Undo changes ({0}) made by {1}&S in the last {2}?",
changes.Length, targetList, args.AgeLimit.ToMiniString() );
}
}
// stop if there's nothing to undo
if( changes.Length == 0 ) {
args.Player.Message( "{0}: Found nothing to undo.", cmdName );
} else {
args.Entries = changes;
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:57,代码来源:BuildingCommands.cs
示例18: Interval
public static void Interval(SchedulerTask task)
{
//check to stop Interval
if (_world.gameMode != GameMode.ZombieSurvival || _world == null)
{
_world = null;
task.Stop();
return;
}
if (!_started)
{
if (startTime != null && (DateTime.Now - startTime).TotalMinutes > 1)
{
/*if (_world.Players.Length < 3){
_world.Players.Message("&WThe game failed to start: 2 or more players need to be in the world");
Stop(null);
return;
}*/
foreach (Player p in _world.Players)
{
int x = rand.Next(2, _world.Map.Width);
int y = rand.Next(2, _world.Map.Length);
int z1 = 0;
for (int z = _world.Map.Height - 1; z > 0; z--)
{
if (_world.Map.GetBlock(x, y, z) != Block.Air)
{
z1 = z + 3;
break;
}
}
p.TeleportTo(new Position(x, y, z1 + 2).ToVector3I().ToPlayerCoords());
}
_started = true;
RandomPick();
lastChecked = DateTime.Now;
return;
}
}
//calculate humans
_humanCount = _world.Players.Where(p => p.iName != _zomb).Count();
//check if zombies have won already
if (_humanCount == 0)
{
_world.Players.Message("&WThe Humans have failed to survive... &9ZOMBIES WIN!");
Stop(null);
return;
}
//check if 5mins is up and all zombies have failed
if (_started && startTime != null && (DateTime.Now - startTime).TotalMinutes > 6)
{
_world.Players.Message("&WThe Zombies have failed to infect everyone... &9HUMANS WIN!");
Stop(null);
return;
}
//if no one has won, notify players of their status every 31s
if (lastChecked != null && (DateTime.Now - lastChecked).TotalSeconds > 30)
{
_world.Players.Message("&WThere are {0} humans", _humanCount.ToString());
foreach (Player p in _world.Players)
{
if (p.iName == _zomb) p.Message("&8You are " + _zomb);
else p.Message("&8You are a Human");
}
lastChecked = DateTime.Now;
}
}
开发者ID:zINaPalm,项目名称:LegendCraftSource,代码行数:67,代码来源:ZombieGame.cs
示例19: SchedulerTaskEventArgs
public SchedulerTaskEventArgs( SchedulerTask task )
{
Task = task;
}
开发者ID:Bedrok,项目名称:800craft,代码行数:4,代码来源:SchedulerTask.cs
示例20: CheckConnections
static void CheckConnections( SchedulerTask param ) {
TcpListener listenerCache = listener;
if( listenerCache != null && listenerCache.Pending() ) {
try {
Player.StartSession( listenerCache.AcceptTcpClient() );
} catch( Exception ex ) {
Logger.Log( LogType.Error,
"Server.CheckConnections: Could not accept incoming connection: {0}", ex );
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:11,代码来源:Server.cs
注:本文中的fCraft.SchedulerTask类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论