示例#1
0
        public void SetCloseHour()
        {
            Bartending.BarData data;
            if (Bartending.sData.TryGetValue(this.MetaAutonomyType, out data))
            {
                data.mHourClose = this.mHourClose;

                List <Bartending.BartendingVenueHelper> dispose = new List <Bartending.BartendingVenueHelper>();
                foreach (Bartending.BartendingVenueHelper helper in Bartending.sHelpers)
                {
                    if (helper.mLotType == this.MetaAutonomyType)
                    {
                        AlarmManager.Global.OnDispose(helper);
                        dispose.Add(helper);
                    }
                }

                foreach (Bartending.BartendingVenueHelper helper2 in dispose)
                {
                    Bartending.sHelpers.Remove(helper2);
                }
                Bartending.sData[this.MetaAutonomyType] = data;
                Bartending.sHelpers.Add(new Bartending.BartendingVenueHelper(this.MetaAutonomyType, data));
            }

            List <MetaAutonomyTuning> tlist;

            if (MetaAutonomyManager.sTunings.TryGetValue(this.MetaAutonomyToVenue(), out tlist))
            {
                MetaAutonomyTuning tuning = tlist[0];
                if (tuning != null)
                {
                    tuning.HourClose = this.mHourClose;
                }
            }

            foreach (IRoleGiverExtended roleObj in Queries.GetObjects(typeof(IRoleGiver)))
            {
                if (roleObj.CurrentRole != null)
                {
                    foreach (AlarmHandle handle in roleObj.CurrentRole.mAlarmHandles)
                    {
                        List <AlarmManager.Timer> alarms;
                        if (AlarmManager.Global.mTimers.TryGetValue(handle, out alarms))
                        {
                            AlarmManager.Timer alarm = alarms[0];
                            if (alarm != null)
                            {
                                if (alarm.CallBack.ToString().Contains("EndRole"))
                                {
                                    AlarmManager.Global.SetNewAlarmTime(handle, this.mHourOpen, TimeUnit.Hours);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public static void Dump(List <Pair <AlarmManager.Timer, int> > timers)
        {
            StringBuilder msg = new StringBuilder();

            foreach (Pair <AlarmManager.Timer, int> pair in timers)
            {
                msg.Append(Common.NewLine);

                msg.Append(Common.NewLine + "Order: " + pair.Second);

                AlarmManager.Timer timer = pair.First;

                msg.Append(Common.NewLine + "Time: " + timer.AlarmDateAndTime);
                msg.Append(Common.NewLine + "Repeating: " + timer.Repeating);

                if (timer.Repeating)
                {
                    msg.Append(Common.NewLine + "Repeat Length: " + timer.RepeatLength);
                    msg.Append(Common.NewLine + "Time Unit: " + timer.UnitOfTime);
                }

                msg.Append(Common.NewLine + "Owner: " + timer.ObjectRef);

                if (timer.ObjectRef is Lot)
                {
                    msg.Append(Common.NewLine + "Owner Name: " + (timer.ObjectRef as Lot).Name);
                    msg.Append(Common.NewLine + "Owner Address: " + (timer.ObjectRef as Lot).Address);
                }
                else if (timer.ObjectRef is SimDescription)
                {
                    msg.Append(Common.NewLine + "Owner Name: " + (timer.ObjectRef as SimDescription).FullName);
                }
                else if (timer.ObjectRef is Sim)
                {
                    msg.Append(Common.NewLine + "Owner Name: " + (timer.ObjectRef as Sim).FullName);
                }

                if (timer.CallBack != null)
                {
                    msg.Append(Common.NewLine + "Function: " + timer.CallBack.Method.ToString() + " - " + timer.CallBack.Method.DeclaringType.GetType().AssemblyQualifiedName);
                    if (timer.CallBack.Target != null)
                    {
                        msg.Append(Common.NewLine + "Target: " + timer.CallBack.Target);
                        msg.Append(Common.NewLine + "Target Type: " + timer.CallBack.Target.GetType() + "," + timer.CallBack.Target.GetType().Assembly.FullName);
                    }
                }
                else
                {
                    msg.Append(Common.NewLine + "<No Callback>");
                }
            }

            Common.WriteLog(msg.ToString());
        }
示例#3
0
        public override bool Run()
        {
            try
            {
                List <AlarmManager> managers = new List <AlarmManager>();

                managers.Add(AlarmManager.Global);

                foreach (Lot lot in LotManager.AllLots)
                {
                    if (lot.mSavedData.mAlarmManager == null)
                    {
                        continue;
                    }

                    managers.Add(lot.AlarmManager);
                }

                Dictionary <ReferenceWrapper, bool> lookup = new Dictionary <ReferenceWrapper, bool>();

                List <Pair <AlarmManager.Timer, int> > timers = new List <Pair <AlarmManager.Timer, int> >();

                foreach (AlarmManager manager in managers)
                {
                    int count = 0;
                    foreach (object item in manager.mTimerQueue)
                    {
                        AlarmManager.Timer timer = item as AlarmManager.Timer;
                        if (timer == null)
                        {
                            continue;
                        }

                        if (lookup.ContainsKey(new ReferenceWrapper(timer)))
                        {
                            continue;
                        }
                        lookup.Add(new ReferenceWrapper(timer), true);

                        timers.Add(new Pair <AlarmManager.Timer, int> (timer, count));

                        count++;
                    }
                }

                DumpAlarms.Dump(timers);
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }
            return(true);
        }
示例#4
0
        protected static void OnYieldAll()
        {
            //if (LoadingScreenController.IsLayoutLoaded()) return;   >>>Originally included in the OnGameSpeedChanged callback which is no longer used. Is this still needed?

            AlarmManager manager = AlarmManager.Global;

            if (manager == null || manager.mTimerQueue == null)
            {
                return;
            }

            try
            {
                foreach (object item in manager.mTimerQueue)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    AlarmManager.Timer timer = item as AlarmManager.Timer;
                    if (timer == null)
                    {
                        continue;
                    }

                    if (timer.Repeating)
                    {
                        continue;
                    }

                    timer.YieldRequired = true;
                }
            }
            catch (Exception e)
            {
                Common.Exception("", e);
            }
        }