Exemple #1
0
        public static bool GetRoleHours(SimDescription sim, ref DateAndTime start, ref DateAndTime end)
        {
            if ((sim != null) && (sim.AssignedRole != null))
            {
                IRoleGiverExtended roleGivingObject = sim.AssignedRole.RoleGivingObject as IRoleGiverExtended;
                if (roleGivingObject != null)
                {
                    float startTime;
                    float endTime;
                    roleGivingObject.GetRoleTimes(out startTime, out endTime);

                    start = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    end   = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    if (SimClock.HoursPassedOfDay >= endTime)
                    {
                        start = SimClock.Add(start, TimeUnit.Hours, startTime);
                        end   = SimClock.Add(end, TimeUnit.Hours, endTime + 24f);
                    }
                    else
                    {
                        start = SimClock.Add(start, TimeUnit.Hours, startTime);
                        end   = SimClock.Add(end, TimeUnit.Hours, endTime);
                    }

                    return(true);
                }
            }

            return(false);
        }