public void Init() { if (Initialized) { return; } InvalidateRegions(); RegisterSubCommands(); EventSink.Shutdown += ServerShutdownHandler; EventSink.Logout += LogoutHandler; EventSink.Login += LoginHandler; _CoreTimer = PollTimer.FromSeconds(1.0, OnCoreTick, () => Initialized && !_StateTransition); Schedule.OnGlobalTick += OnScheduleTick; Teams.Where(team => team != null && !team.Deleted).ForEach(team => team.Init()); OnInit(); Initialized = true; if (!Validate()) { State = PvPBattleState.Internal; } }
static WebSockets() { CMOptions = new WebSocketsOptions(); EventSink.ServerStarted += () => _Started = true; Clients = new List <WebSocketsClient>(); OnConnected += HandleConnection; _ActivityTimer = PollTimer.FromSeconds( 60.0, () => { if (!_Listening || Listener == null || Listener.Server == null || !Listener.Server.IsBound) { _Listening = false; ListenAsync(); } Clients.RemoveAll(c => !c.Connected); }, () => CMOptions.ModuleEnabled && Clients.Count > 0); NetState.CreatedCallback += ns => { if (ns is WebSocketsClient) { var client = (WebSocketsClient)ns; client.CompressionEnabled = false; } }; }
public void Init() { if (Initialized) { return; } InvalidateRegions(); RegisterSubCommands(); if (_CoreTimer != null) { _CoreTimer.Callback = OnCoreTick; _CoreTimer.Condition = () => Initialized && !_StateTransition; } else { _CoreTimer = PollTimer.FromSeconds(1.0, OnCoreTick, () => Initialized && !_StateTransition); } Schedule.OnGlobalTick += OnScheduleTick; ForEachTeam(t => t.Init()); OnInit(); Initialized = true; if (!Validate()) { State = PvPBattleState.Internal; } }
public static void Configure() { if (_Timer == null) { _Timer = PollTimer.FromSeconds(1.0, DefragmentStates, States.Any, false); } }
static WebAPI() { CSOptions = new WebAPIOptions(); Clients = new List <WebAPIClient>(); Handlers = new Dictionary <string, WebAPIHandler>(); _ActivityTimer = PollTimer.FromSeconds( 60.0, () => { if (!_Listening || Listener == null || Listener.Server == null || !Listener.Server.IsBound) { _Listening = false; ListenerUtility.ListenAsync(); } Clients.RemoveAll(c => !c.Connected); }, () => Clients.Count > 0, false); ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xFF0; // Ssl3, Tls, Tls11, Tls12 }
public static void Init() { if (Initialized) { return; } ReqOplParent = PacketHandlers.GetExtendedHandler(0x10); PacketHandlers.RegisterExtended(ReqOplParent.PacketID, ReqOplParent.Ingame, OnQueryProperties); ReqBatchOplParent = PacketHandlers.GetHandler(0xD6); bool is6017 = (PacketHandlers.Get6017Handler(0xD6) != null); PacketHandlers.Register( ReqBatchOplParent.PacketID, ReqBatchOplParent.Length, ReqBatchOplParent.Ingame, OnBatchQueryProperties); if (is6017) { PacketHandlers.Register6017( ReqBatchOplParent.PacketID, ReqBatchOplParent.Length, ReqBatchOplParent.Ingame, OnBatchQueryProperties); } OutParent0xD6 = OutgoingPacketOverrides.GetHandler(0xD6); OutgoingPacketOverrides.Register(0xD6, true, OnEncode0xD6); Initialized = true; PollTimer.FromSeconds(10.0, FreeCache); }
static WebStats() { CMOptions = new WebStatsOptions(); EventSink.ServerStarted += () => _Started = true; Clients = new List <WebStatsClient>(); Snapshot = new Dictionary <IPAddress, List <NetState> >(); Stats = new BinaryDataStore <string, WebStatsEntry>(VitaNexCore.SavesDirectory + "/WebStats", "Stats") { OnSerialize = SerializeStats, OnDeserialize = DeserializeStats }; TimeSpan uptime = DateTime.UtcNow - Clock.ServerStart; Stats.Add("uptime", new WebStatsEntry(uptime, false)); Stats.Add("uptime_peak", new WebStatsEntry(uptime, true)); Stats.Add("online", new WebStatsEntry(0, false)); Stats.Add("online_max", new WebStatsEntry(0, false)); Stats.Add("online_peak", new WebStatsEntry(0, true)); Stats.Add("unique", new WebStatsEntry(0, false)); Stats.Add("unique_max", new WebStatsEntry(0, false)); Stats.Add("unique_peak", new WebStatsEntry(0, true)); Stats.Add("items", new WebStatsEntry(0, false)); Stats.Add("items_max", new WebStatsEntry(0, false)); Stats.Add("items_peak", new WebStatsEntry(0, true)); Stats.Add("mobiles", new WebStatsEntry(0, false)); Stats.Add("mobiles_max", new WebStatsEntry(0, false)); Stats.Add("mobiles_peak", new WebStatsEntry(0, true)); Stats.Add("guilds", new WebStatsEntry(0, false)); Stats.Add("guilds_max", new WebStatsEntry(0, false)); Stats.Add("guilds_peak", new WebStatsEntry(0, true)); OnConnected += HandleConnection; _ActivityTimer = PollTimer.FromSeconds( 60.0, () => { if (!_Listening || Listener == null || Listener.Server == null || !Listener.Server.IsBound) { _Listening = false; ListenAsync(); } Clients.RemoveRange(c => !c.Connected); }, () => CMOptions.ModuleEnabled && Clients.Count > 0); }
public static void Initialize() { if (_RespawnTimers.All(t => t == null)) { _RespawnTimers.SetAll(i => PollTimer.FromSeconds(15.0, () => ProcessRespawn(i), () => _Instances.Count > i * 1000)); } else { _RespawnTimers.For(i => _RespawnTimers[i].Running = true); } }
public void init() { bool success = SpawnPortal(); if (!success) { Console.WriteLine("Could not find a valid portal location, aborting."); return; } GenerateAnims(); _CoreTimer = PollTimer.FromSeconds(1.0, OnTick, () => Status == PortalStatus.Running); }
public void Init() { if (Initialized || Initializing) { return; } Initialized = true; if (Deleted) { return; } Initializing = true; EventSink.Shutdown += InternalServerShutdown; EventSink.Logout += InternalLogout; EventSink.Login += InternalLogin; CoreTimer = PollTimer.FromSeconds(1.0, Slice, () => !Deleted && !Initializing && Initialized); if (Map == null || Map.Deleted) { Map = Instances.ResolveMap(this, true); } if (Map == null || Map.Deleted) { Initializing = false; Delete(); return; } _NextDefragment = Core.TickCount + 60000; RegisterSubCommands(); Generate(); OnInit(); foreach (var z in Zones.Where(z => z != null && !z.Deleted && z.Dungeon != this)) { z.Dungeon = this; } Defragment(); Initializing = false; }
public void init() { if (TownGates != null) { DeleteGates(); } if (SpawnTownGates) { TownGates = SpawnGates(); } _CoreTimer = PollTimer.FromSeconds(1.0, OnTick, () => Status == InvasionStatus.Running); }
static ThrowableStinkBomb() { Stinky = new Dictionary <Mobile, DateTime>(); _InternalTimer = PollTimer.FromSeconds(5.0, InternalCallback, () => Stinky.Count > 0); }
static StrobeLantern() { Instances = new List <StrobeLantern>(); _Timer = PollTimer.FromSeconds(1.0, CheckStrobe, Instances.Any); }
protected override void OnThrownAt(Mobile m, IEntity target) { if (m == null || m.Deleted || target == null) { return; } if (ImpactSound >= 0) { Effects.PlaySound(target.Location, target.Map, ImpactSound); } ThrownLast = DateTime.UtcNow; LastUsed = DateTime.UtcNow + ThrowRecovery; int range = 1; int zOffset = 10; Point3D src = target.Location.Clone3D(0, 0, zOffset); Point3D[] points = src.GetAllPointsInRange(target.Map, 0, 1); Effects.PlaySound(target.Location, target.Map, 0x19C); var mobile = target as Mobile; if (mobile != null) { mobile.SendMessage(343, "{0} has thrown a pile of human feces at you!", m.RawName); } Timer.DelayCall( TimeSpan.FromMilliseconds(100), () => { foreach (Point3D trg in points) { int bloodID = Utility.RandomMinMax(4650, 4655); new MovingEffectInfo(src, trg.Clone3D(0, 0, 2), target.Map, bloodID, 342).MovingImpact( info => { var blood = new Blood { Name = "poo", ItemID = bloodID, Hue = 343 }; blood.MoveToWorld(info.Target.Location, info.Map); Effects.PlaySound(info.Target, info.Map, 0x028); }); } }); if (ThrowRecovery > TimeSpan.Zero) { if (UpdateTimer == null) { UpdateTimer = PollTimer.FromSeconds( 1.0, () => { ClearProperties(); Delta(ItemDelta.Properties); DateTime readyWhen = ThrownLast + ThrowRecovery; if (DateTime.UtcNow < readyWhen) { return; } m.EndAction(GetType()); if (UpdateTimer == null) { return; } UpdateTimer.Running = false; UpdateTimer = null; }); } else { UpdateTimer.Running = true; } } else { if (UpdateTimer != null) { UpdateTimer.Running = false; UpdateTimer = null; } ClearProperties(); Delta(ItemDelta.Properties); m.EndAction(GetType()); } }
public override void OnRegister() { base.OnRegister(); Expire = DateTime.UtcNow.AddSeconds(300.0); if (Effects == null) { var effects = new EffectInfo[Area.Length][, ]; effects.SetAll(i => new EffectInfo[Area[i].Width, Area[i].Height]); for (int index = 0; index < Area.Length; index++) { var b = Area[index]; int xSpacing = Math.Max(1, Math.Min(16, b.Width / 8)); int ySpacing = Math.Max(1, Math.Min(16, b.Height / 8)); int minX = Math.Min(b.Start.X, b.End.X); int maxX = Math.Max(b.Start.X, b.End.X); int minY = Math.Min(b.Start.Y, b.End.Y); int maxY = Math.Max(b.Start.Y, b.End.Y); Parallel.For( minX, maxX, x => Parallel.For( minY, maxY, y => { if (x != b.Start.X && x != b.End.X - 1 && x % xSpacing != 0 && // y != b.Start.Y && y != b.End.Y - 1 && y % ySpacing != 0) { return; } int idxX = x - minX; int idxY = y - minY; effects[index][idxX, idxY] = new EffectInfo( new Point3D(x, y, 0), Map, EffectID, EffectHue, 1, 25, EffectRender); })); } Effects = effects.AsParallel().SelectMany(list => list.OfType <EffectInfo>()).ToArray(); foreach (var e in Effects) { e.SetSource(e.Source.GetWorldTop(e.Map)); } } if (Timer == null) { Timer = PollTimer.FromSeconds( 1.0, () => { if (DateTime.UtcNow > Expire) { Unregister(); return; } foreach (var e in Effects) { e.Send(); } }, () => Registered); } else { Timer.Running = true; } _Previews.AddOrReplace(Serial, this); }
public void init() { _CoreTimer = PollTimer.FromSeconds(1.0, OnTick, () => Status == ZombieEventStatus.Running); }
protected override void OnThrownAt(Mobile m, IEntity target) { if (m == null || m.Deleted || target == null) { return; } if (ImpactSound >= 0) { Effects.PlaySound(target.Location, target.Map, ImpactSound); } ThrownLast = DateTime.UtcNow; LastUsed = DateTime.UtcNow + ThrowRecovery; if (target is BaseCreature) { var creature = target as BaseCreature; if (creature.Alive) { m.DoHarmful(creature); creature.Damage(Utility.RandomMinMax(5, 20), m); } int range = 1; int zOffset = 10; Point3D src = target.Location.Clone3D(0, 0, zOffset); var points = src.GetAllPointsInRange(target.Map, range, range); Effects.PlaySound(target.Location, target.Map, 0x19C); Timer.DelayCall( TimeSpan.FromMilliseconds(100), () => { foreach (Point3D trg in points) { int bloodID = Utility.RandomMinMax(4650, 4655); new MovingEffectInfo(src, trg.Clone3D(0, 0, 2), target.Map, bloodID).MovingImpact( info => { var blood = new Blood { ItemID = bloodID }; blood.MoveToWorld(info.Target.Location, info.Map); Effects.PlaySound(info.Target, info.Map, 0x028); }); } }); } if (ThrowRecovery > TimeSpan.Zero) { if (UpdateTimer == null) { UpdateTimer = PollTimer.FromSeconds( 1.0, () => { ClearProperties(); Delta(ItemDelta.Properties); DateTime readyWhen = ThrownLast + ThrowRecovery; if (DateTime.UtcNow < readyWhen) { return; } m.EndAction(GetType()); if (UpdateTimer == null) { return; } UpdateTimer.Running = false; UpdateTimer = null; }); Consume(); } else { UpdateTimer.Running = true; } } else { if (UpdateTimer != null) { UpdateTimer.Running = false; UpdateTimer = null; } ClearProperties(); Delta(ItemDelta.Properties); m.EndAction(GetType()); } }
protected virtual void OnThrownAt(Mobile m, TEntity target) { if (m == null || m.Deleted || target == null) { return; } if (ImpactSound >= 0) { Effects.PlaySound(target.Location, target.Map, ImpactSound); } ThrownLast = DateTime.UtcNow; if (Consumable) { Consume(); } if (ThrowRecovery > TimeSpan.Zero) { if (UpdateTimer == null) { UpdateTimer = PollTimer.FromSeconds( 1.0, () => { ClearProperties(); Delta(ItemDelta.Properties); var readyWhen = ThrownLast + ThrowRecovery; if (DateTime.UtcNow < readyWhen) { return; } m.EndAction(GetType()); if (UpdateTimer == null) { return; } UpdateTimer.Running = false; UpdateTimer = null; }); } else { UpdateTimer.Running = true; } } else { if (UpdateTimer != null) { UpdateTimer.Running = false; UpdateTimer = null; } ClearProperties(); Delta(ItemDelta.Properties); m.EndAction(GetType()); } }