Beispiel #1
0
 private static void CSConfig()
 {
     ConnectionPoller = PollTimer.CreateInstance(
         TimeSpan.FromSeconds(15),
         () => Connections.Where(c => !c.Connected).ForEach(Disconnected),
         () => Connections.Count > 0);
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        static SpellCastBars()
        {
            States.OnSerialize   = Serialize;
            States.OnDeserialize = Deserialize;

            _InternalTimer = PollTimer.CreateInstance(
                TimeSpan.FromMilliseconds(100.0),
                PollCastBarQueue,
                () => CMOptions.ModuleEnabled,
                false);
        }
Beispiel #4
0
        public void InitPollTimer()
        {
            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            if (EnablePolling)
            {
                InstancePoller = PollTimer.CreateInstance(PollInterval, OnInstancePollCheck, CanPollInstance);
            }
        }
Beispiel #5
0
 public static void Initialize()
 {
     PollTimer.CreateInstance(
         TimeSpan.FromSeconds(5),
         () => Cache.ForEach(
             m =>
     {
         if (CheckStinky(m))
         {
             DoStinkEffect(m);
         }
     }),
         () => (Stinky.Count > 0));
 }
Beispiel #6
0
        static SpellCastBars()
        {
            CMOptions = new CastBarsOptions();

            _CastBarQueue = new Queue <PlayerMobile>();

            _InternalTimer = PollTimer.CreateInstance(TimeSpan.FromSeconds(0.1), PollCastBarQueue, _CastBarQueue.Any);

            Instances = new Dictionary <PlayerMobile, SpellCastBar>();

            States = new BinaryDataStore <PlayerMobile, CastBarState>(VitaNexCore.SavesDirectory + "/SpellCastBars", "States")
            {
                Async         = true,
                OnSerialize   = Serialize,
                OnDeserialize = Deserialize
            };
        }
Beispiel #7
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            var version = reader.GetVersion();

            switch (version)
            {
            case 2:
                Token = reader.ReadString();
                goto case 1;

            case 1:
            {
                StinkMode     = reader.ReadBool();
                SwagMode      = reader.ReadBool();
                ProducesWaste = reader.ReadBool();
            }
                goto case 0;

            case 0:
            {
                _ProductionDelay    = reader.ReadTimeSpan();
                ProductionTimeBonus = reader.ReadTimeSpan();
                LastProduction      = reader.ReadDateTime();
                Products            = reader.ReadInt();
                ProductsMax         = reader.ReadInt();
            }
            break;
            }

            if (UpdateTimer != null)
            {
                UpdateTimer.Running = true;
            }
            else
            {
                UpdateTimer = PollTimer.CreateInstance(TimeSpan.FromSeconds(1), OnProductionTimerTick);
            }
        }
Beispiel #8
0
        public override void OnAdded(object parent)
#endif
        {
            base.OnAdded(parent);

            if (parent == null && ProducesWaste)
            {
                if (UpdateTimer != null)
                {
                    UpdateTimer.Running = true;
                }
                else
                {
                    UpdateTimer = PollTimer.CreateInstance(TimeSpan.FromSeconds(1), OnProductionTimerTick);
                }
            }
            else if (UpdateTimer != null)
            {
                UpdateTimer.Running = false;
                UpdateTimer         = null;
            }
        }
Beispiel #9
0
        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;
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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));
        }
Beispiel #14
0
        static SepticTank()
        {
            Instances = new List <SepticTank>();

            UpdateTimer = PollTimer.CreateInstance(TimeSpan.FromMinutes(1), CheckProduction, () => Instances.Count > 0);
        }
Beispiel #15
0
 private static void CMConfig()
 {
     _InternalTimer = PollTimer.CreateInstance(
         TimeSpan.FromMilliseconds(10.0), PollCastBarQueue, () => CMOptions.ModuleEnabled);
 }