public static void Initialize() { UpdateTimer = PollTimer.CreateInstance(Config.Options.CharUpdateInterval, Begin, () => Config.Options.Enabled); CommandSystem.Register("UpdateMyRunUO", AccessLevel.Administrator, UpdateMyRunUO_OnCommand); CommandSystem.Register("PublicChar", AccessLevel.Player, PublicChar_OnCommand); CommandSystem.Register("PrivateChar", AccessLevel.Player, PrivateChar_OnCommand); }
public virtual void CheckTraining(Mobile from, Mobile target) { if (from == null || from.Deleted || target == null || target.Deleted) { if (TrainingTimer != null) { TrainingTimer.Stop(); TrainingTimer = null; } return; } if (TrainingTimer == null) { TrainingLocation = from.Location; TrainingTimer = PollTimer.CreateInstance( TimeSpan.FromSeconds(1.0), () => { if (from.Location != TrainingLocation) { TrainingTimer.Stop(); TrainingTimer = null; return; } BeginThrow(from, target); }); } else if (from.Location != TrainingLocation) { TrainingTimer.Stop(); TrainingTimer = null; } }
public override void OnLocationChange(Point3D oldLocation) { base.OnLocationChange(oldLocation); if (!ProducesWaste || RootParent != null) { if (UpdateTimer != null) { UpdateTimer.Running = false; UpdateTimer = null; } return; } if (UpdateTimer != null) { UpdateTimer.Running = true; } else { UpdateTimer = PollTimer.CreateInstance(TimeSpan.FromSeconds(1), OnProductionTimerTick); } }
public static void Init() { if (Initialized) { return; } ReqOplParent = PacketHandlers.GetExtendedHandler(0x10); PacketHandlers.RegisterExtended(ReqOplParent.PacketID, ReqOplParent.Ingame, OnQueryProperties); ReqBatchOplParent = PacketHandlers.GetHandler(0xD6); var 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, OnEncode0xD6); Initialized = true; PollTimer.FromSeconds(10.0, FreeCache); }
public void Start() { if (Deleted || !Active || Map == null || Map == Map.Internal || Parent != null) { Stop(); return; } if (_Effects == null || _Center != GetWorldLocation()) { ClearEffects(); _Effects = new List<EffectInfo>(GetEffects()); } if (_Timer == null) { _Timer = PollTimer.CreateInstance( Interval, () => { if (!Active) { Stop(); return; } SendEffects(); }, () => !Deleted && Active && Map != null && Map != Map.Internal && Parent == null); } else { _Timer.Running = true; } if (!PlayerRangeSensitive) { if (_ActivityTimer != null) { _ActivityTimer.Running = false; _ActivityTimer = null; } return; } if (_ActivityTimer != null) { _ActivityTimer.Running = true; return; } _ActivityTimer = PollTimer.CreateInstance( ActivityInterval, () => { if (DateTime.UtcNow - _LastActivity < ActivityInterval) { return; } IPooledEnumerable clients = GetClientsInRange(GetMaxUpdateRange()); if (clients.OfType<NetState>().Any()) { clients.Free(); return; } clients.Free(); Stop(); }, () => !Deleted && Map != null && Map != Map.Internal && Parent == null); }
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 static void Configure() { if (_StatLossDecayTimer == null || !_StatLossDecayTimer.Running) { _StatLossDecayTimer = PollTimer.FromMinutes( 30.0, // Every 30 minutes (this used to be on FoodDecay timer...) () => { Mobile[] mobs = NetState.Instances.Where(ns => ns != null && ns.Mobile != null).Select(ns => ns.Mobile).ToArray(); foreach (Mobile m in mobs) { StatLossDecay(m); } }, () => NetState.Instances.Count > 0); } }
static StrobeLantern() { Instances = new List <StrobeLantern>(); _Timer = PollTimer.FromSeconds(1.0, CheckStrobe, Instances.Any); }
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()); } }
public void Delete() { if (Deleted) { return; } Reset(); if (_CoreTimer != null) { _CoreTimer.Dispose(); _CoreTimer = null; } _CoreTicks = 0; if (Gate != null) { Gate.Delete(); Gate = null; } ForEachTeam(t => t.Delete()); if (Schedule != null) { Schedule.Stop(); Schedule.Enabled = false; Schedule.OnGlobalTick -= OnScheduleTick; Schedule = null; } if (_BattleRegion != null) { _BattleRegion.ClearPreview(); _BattleRegion.Unregister(); _BattleRegion = null; } if (_SpectateRegion != null) { _SpectateRegion.ClearPreview(); _SpectateRegion.Unregister(); _SpectateRegion = null; } if (Options != null) { Options.Clear(); } OnDeleted(); if (AutoPvP.RemoveBattle(this)) { OnRemoved(); } Deleted = true; }
static SepticTank() { Instances = new List <SepticTank>(); UpdateTimer = PollTimer.CreateInstance(TimeSpan.FromMinutes(1), CheckProduction, () => Instances.Count > 0); }
public void init() { _CoreTimer = PollTimer.FromSeconds(1.0, OnTick, () => Status == ZombieEventStatus.Running); }
public void Delete() { if (Deleted) { return; } Reset(); EventSink.Shutdown -= ServerShutdownHandler; EventSink.Logout -= LogoutHandler; EventSink.Login -= LoginHandler; if (_CoreTimer != null) { _CoreTimer.Dispose(); _CoreTimer = null; } _CoreTicks = 0; if (Gate != null) { Gate.Delete(); Gate = null; } Teams.Where(t => t != null && !t.Deleted).ForEach(t => t.Delete()); if (Schedule != null) { Schedule.Stop(); Schedule.Enabled = false; Schedule.OnGlobalTick -= OnScheduleTick; Schedule = null; } if (_BattleRegion != null) { _BattleRegion.ClearPreview(); _BattleRegion.Unregister(); _BattleRegion = null; } if (_SpectateRegion != null) { _SpectateRegion.ClearPreview(); _SpectateRegion.Unregister(); _SpectateRegion = null; } if (_Options != null) { _Options.Clear(); } OnDeleted(); if (AutoPvP.RemoveBattle(this)) { OnRemoved(); } Deleted = true; }
private static void CMConfig() { _InternalTimer = PollTimer.CreateInstance( TimeSpan.FromMilliseconds(10.0), PollCastBarQueue, () => CMOptions.ModuleEnabled); }
public void init() { if (TownGates != null) { DeleteGates(); } if (SpawnTownGates) { TownGates = SpawnGates(); } _CoreTimer = PollTimer.FromSeconds(1.0, OnTick, () => Status == InvasionStatus.Running); }
public void Stop() { if (_ActivityTimer != null) { _ActivityTimer.Running = false; _ActivityTimer = null; } ClearEffects(); if (_Timer == null) { return; } _Timer.Running = false; _Timer = null; }
public static void Initialize() { UpdateTimer = PollTimer.CreateInstance(Config.Options.StatusUpdateInterval, Begin, () => Config.Options.Enabled); CommandSystem.Register("UpdateWebStatus", AccessLevel.Administrator, UpdateWebStatus_OnCommand); }
public void EntryPoint() { CommandSystem.Register( "DigitalTest1", AccessLevel.GameMaster, e => Sandbox.SafeInvoke( () => { var split = e.ArgString.Trim().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); var numbers = new int[split.Length]; if (numbers.Length == 0) { numbers = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; } else { for (int i = 0; i < split.Length; i++) { numbers[i] = Math.Max(0, Math.Min(9, Int32.Parse(split[i]))); } } SuperGump.Send(new DigitalNumericDisplayGump(e.Mobile as PlayerMobile, numbers: numbers)); }, this)); CommandSystem.Register( "DigitalTest2", AccessLevel.GameMaster, e => Sandbox.SafeInvoke( () => { var pm = e.Mobile as PlayerMobile; if (pm == null) { return; } if (Tests.ContainsKey(pm)) { if (Tests[pm] != null) { Tests[pm].Stop(); } } else { Tests.Add(pm, null); } int i = 0; const int iMax = 100; Tests[pm] = PollTimer.CreateInstance( TimeSpan.FromMilliseconds(100.0), () => { string numStr = i.ToString(CultureInfo.InvariantCulture); var numbers = new int[numStr.Length]; for (int j = 0; j < numbers.Length; j++) { numbers[j] = Math.Max(0, Math.Min(9, Int32.Parse(numStr[j].ToString(CultureInfo.InvariantCulture)))); } var instances = SuperGump.GetInstances <DigitalNumericDisplayGump>(pm); if (instances.Length != 0) { DigitalNumericDisplayGump g = instances[0]; g.NumericWidth += 1; g.NumericHeight += 2; g.Numerics = numbers; g.Refresh(); } else { var g = new DigitalNumericDisplayGump(e.Mobile as PlayerMobile, numbers: numbers); g.Send(); } i++; if (i < iMax || !Tests.ContainsKey(pm)) { return; } Tests[pm].Stop(); Tests.Remove(pm); }, () => i <= iMax); }, this)); CommandSystem.Register( "DigitalTest3", AccessLevel.GameMaster, e => Sandbox.SafeInvoke( () => { var pm = e.Mobile as PlayerMobile; if (pm == null) { return; } if (Tests.ContainsKey(pm)) { if (Tests[pm] != null) { Tests[pm].Stop(); } } else { Tests.Add(pm, null); } int i = 60; const int iMin = 0; Tests[pm] = PollTimer.CreateInstance( TimeSpan.FromSeconds(1.0), () => { string numStr = i.ToString(CultureInfo.InvariantCulture); var numbers = new int[numStr.Length]; for (int j = 0; j < numbers.Length; j++) { numbers[j] = Math.Max(0, Math.Min(9, Int32.Parse(numStr[j].ToString(CultureInfo.InvariantCulture)))); } var instances = SuperGump.GetInstances <DigitalNumericDisplayGump>(pm); if (instances.Length != 0) { DigitalNumericDisplayGump g = instances[0]; g.NumericWidth -= 1; g.NumericHeight -= 2; g.Numerics = numbers; g.Refresh(); } else { var g = new DigitalNumericDisplayGump( e.Mobile as PlayerMobile, numericWidth: 60, numericHeight: 120, numbers: numbers); g.Send(); } i--; if (i > 0 || !Tests.ContainsKey(pm)) { return; } Tests[pm].Stop(); Tests.Remove(pm); }, () => i >= iMin); }, this)); }
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); }
protected override void OnInit() { _FlagEffectTimer = PollTimer.FromMilliseconds( 100.0, () => Teams.OfType<CTFTeam>().Where(t => t != null && t.Flag != null).ForEach(t => t.Flag.InvalidateCarryEffect()), () => !Deleted && !Hidden && State == PvPBattleState.Running && Teams.Count > 0); base.OnInit(); }
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()); } }
protected override void OnDeleted() { if (_FlagEffectTimer != null) { _FlagEffectTimer.Stop(); _FlagEffectTimer = null; } base.OnDeleted(); }
public void Start() { if (Deleted || !Active || Map == null || Map == Map.Internal || Parent != null) { Stop(); return; } if (_Effects == null || _Center != GetWorldLocation()) { ClearEffects(); _Effects = new List <EffectInfo>(GetEffects()); } if (_Timer == null) { _Timer = PollTimer.CreateInstance( Interval, () => { if (!Active) { Stop(); return; } SendEffects(); }, () => !Deleted && Active && Map != null && Map != Map.Internal && Parent == null); } else { _Timer.Running = true; } if (!PlayerRangeSensitive) { if (_ActivityTimer != null) { _ActivityTimer.Running = false; _ActivityTimer = null; } return; } if (_ActivityTimer != null) { _ActivityTimer.Running = true; return; } _ActivityTimer = PollTimer.CreateInstance( ActivityInterval, () => { if (DateTime.UtcNow - _LastActivity < ActivityInterval) { return; } IPooledEnumerable clients = GetClientsInRange(GetMaxUpdateRange()); if (clients.OfType <NetState>().Any()) { clients.Free(); return; } clients.Free(); Stop(); }, () => !Deleted && Map != null && Map != Map.Internal && Parent == null); }
private void PollView_FormClosing(object sender, FormClosingEventArgs e) { PollTimer.Stop(); tsbStart.Enabled = true; tsbStop.Enabled = false; }
static ThrowableStinkBomb() { Stinky = new Dictionary <Mobile, DateTime>(); _InternalTimer = PollTimer.FromSeconds(5.0, InternalCallback, () => Stinky.Count > 0); }
private PollTimer PollTimer; // Timer object which manages the polling of the sensor object protected virtual void Start() { PollTimer = new PollTimer(SensorPollRate); PollTimer.OnTimerPoll += Poll; TogglePolling(PollOnStart, true); }
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()); } }