Example #1
0
        public static void StoreChanges(ShowStage stage, Logger log)
        {
            try
            {
                if ((stage.mSimThatSetupStage == null) && (stage.mPerformingSim == null))
                {
                    List <Slot> remove = new List <Slot>();

                    foreach (KeyValuePair <Slot, ObjectWithOrientation> pair in stage.mVenueStageLayout)
                    {
                        if (pair.Value == null)
                        {
                            continue;
                        }

                        if (pair.Value.mGameObject == null)
                        {
                            remove.Add(pair.Key);
                        }
                        else if (pair.Value.mGameObject.Proxy == null)
                        {
                            remove.Add(pair.Key);
                        }
                    }

                    foreach (Slot slot in remove)
                    {
                        stage.mVenueStageLayout.Remove(slot);
                    }

                    stage.LoadStage();
                    stage.mVenueStageLayout.Clear();
                    stage.SaveStage(stage.mVenueStageLayout);

                    if (log != null)
                    {
                        log(" Stored Stage Changes");
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(stage, e);
            }
        }
Example #2
0
        public static Sim CreateServicePerformer(ShowStage ths)
        {
            List <Service> services = new List <Service> {
                Magician.Instance, Singer.Instance, PerformanceArtist.Instance
            };
            int attempts  = 0;
            Sim performer = null;

            while (performer == null && attempts <= 5)
            {
                Service service = RandomUtil.GetRandomObjectFromList(services);
                if (service != null)
                {
                    foreach (SimDescription description in service.mPool)
                    {
                        if (!service.IsSimAssignedTask(description) && description.CreatedSim == null)
                        {
                            int lotAttempts = 0;
                            Lot lot         = null;
                            while (lot == null && lotAttempts <= 5)
                            {
                                lot = LotManager.SelectRandomLot(null);
                                lotAttempts++;
                            }

                            if (lot != null)
                            {
                                Sim createdSim = service.CreateSim(lot, description);
                                if (createdSim != null)
                                {
                                    createdSim.FadeIn();
                                    performer = createdSim;
                                    break;
                                }
                            }
                        }
                    }
                }
                attempts++;
            }

            return(performer);
        }
Example #3
0
        public static void StoreChanges(ShowStage stage, Logger log)
        {
            try
            {
                if ((stage.mSimThatSetupStage == null) && (stage.mPerformingSim == null))
                {
                    List<Slot> remove = new List<Slot>();

                    foreach (KeyValuePair<Slot, ObjectWithOrientation> pair in stage.mVenueStageLayout)
                    {
                        if (pair.Value == null) continue;

                        if (pair.Value.mGameObject == null)
                        {
                            remove.Add(pair.Key);
                        }
                        else if (pair.Value.mGameObject.Proxy == null)
                        {
                            remove.Add(pair.Key);
                        }
                    }

                    foreach (Slot slot in remove)
                    {
                        stage.mVenueStageLayout.Remove(slot);
                    }

                    stage.LoadStage();
                    stage.mVenueStageLayout.Clear();
                    stage.SaveStage(stage.mVenueStageLayout);

                    if (log != null)
                    {
                        log(" Stored Stage Changes");
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(stage, e);
            }
        }
Example #4
0
        public static void Cleanup(ShowStage stage, Logger log)
        {
            if (stage.mSlaveList == null)
            {
                stage.mSlaveList = new List<IShowSlave>();
            }

            for (int i = stage.mSlaveList.Count - 1; i >= 0; i--)
            {
                IShowSlave slave = stage.mSlaveList[i];

                if (slave == null)
                {
                    stage.mSlaveList.RemoveAt(i);

                    if (log != null)
                    {
                        log(" Null Slave Removed");
                    }
                }
                else
                {
                    ShowStage.WatchTheShow watch = slave as ShowStage.WatchTheShow;
                    if (watch != null)
                    {
                        if (watch.Actor == null)
                        {
                            stage.mSlaveList.RemoveAt(i);

                            if (log != null)
                            {
                                log(" Broken WatchTheShow Removed");
                            }
                        }
                    }
                }
            }

            StoreChanges(stage, log);
        }
Example #5
0
        public static void Cleanup(ShowStage stage, Logger log)
        {
            if (stage.mSlaveList == null)
            {
                stage.mSlaveList = new List <IShowSlave>();
            }

            for (int i = stage.mSlaveList.Count - 1; i >= 0; i--)
            {
                IShowSlave slave = stage.mSlaveList[i];

                if (slave == null)
                {
                    stage.mSlaveList.RemoveAt(i);

                    if (log != null)
                    {
                        log(" Null Slave Removed");
                    }
                }
                else
                {
                    ShowStage.WatchTheShow watch = slave as ShowStage.WatchTheShow;
                    if (watch != null)
                    {
                        if (watch.Actor == null)
                        {
                            stage.mSlaveList.RemoveAt(i);

                            if (log != null)
                            {
                                log(" Broken WatchTheShow Removed");
                            }
                        }
                    }
                }
            }

            StoreChanges(stage, log);
        }
Example #6
0
        public static Sim CreateAnNPCPerformer(ShowStage ths)
        {
            Sim createdSim = null;
            Lot lotCurrent = null;

            OccupationNames[]           randomList           = new OccupationNames[] { OccupationNames.SingerCareer, OccupationNames.MagicianCareer, OccupationNames.PerformanceArtistCareer };
            AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(RandomUtil.GetRandomObjectFromList(randomList), false, true);
            bool flag = RandomUtil.CoinFlip();

            // Custom
            List <SimDescription> list = Household.AllTownieSimDescriptions(ValidPerformer);

            if (list.Count != 0)
            {
                SimDescription randomObjectFromList = RandomUtil.GetRandomObjectFromList(list);
                if (randomObjectFromList.CreatedSim == null)
                {
                    lotCurrent = ths.LotCurrent;
                    createdSim = randomObjectFromList.Instantiate(lotCurrent);
                }
                else
                {
                    createdSim = randomObjectFromList.CreatedSim;
                }
            }
            else
            {
                Sim servicePerformer = CreateServicePerformer(ths);
                if (servicePerformer != null)
                {
                    createdSim = servicePerformer;
                }
            }

            if (createdSim == null)
            {
                return(null);
            }

            GoToLot interaction = GoToLot.Singleton.CreateInstanceWithCallbacks(ths.LotCurrent, createdSim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, true, null, new Callback(GoToLotSuccess), new Callback(GoToLotFailure)) as GoToLot;

            if (createdSim.InteractionQueue != null)
            {
                Common.DebugNotify("Pushing GoToLot on " + createdSim.FullName);
                createdSim.InteractionQueue.Add(interaction);
            }

            if (createdSim.CareerManager == null)
            {
                return(null);
            }

            if (createdSim.CareerManager.OccupationAsPerformanceCareer == null)
            {
                try
                {
                    if (createdSim.WasCreatedByAService)
                    {
                        switch (createdSim.Service.ServiceType)
                        {
                        case ServiceType.Magician:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.MagicianCareer, false, true);
                            break;

                        case ServiceType.Singer:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.SingerCareer, false, true);
                            break;

                        case ServiceType.PerformanceArtist:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.PerformanceArtistCareer, false, true);
                            break;

                        default:
                            break;
                        }
                    }

                    createdSim.AcquireOccupation(occupationParameters);

                    int num = flag ? RandomUtil.GetInt(0x0, 0x5) : RandomUtil.GetInt(0x5, createdSim.Occupation.HighestLevel);
                    for (int i = 0x1; i < num; i++)
                    {
                        createdSim.CareerManager.Occupation.PromoteSim();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(createdSim, e);
                    return(null);
                }
            }
            return(createdSim);
        }
Example #7
0
        public static void SetupSimFest(ShowStage ths)
        {
            Common.StringBuilder msg = new Common.StringBuilder("SetupSimFest");

            try
            {
                if ((ths.OwnerProprietor == null) || (ths.OwnerProprietor.HasBeenDestroyed))
                {
                    if (ths.CurrentRole == null)
                    {
                        return;
                    }

                    ths.OwnerProprietor = ths.CurrentRole.SimInRole;
                    if ((ths.OwnerProprietor == null) || (ths.OwnerProprietor.HasBeenDestroyed))
                    {
                        return;
                    }
                }

                CommonSpace.Helpers.ShowStageEx.Cleanup(ths, null);

                msg += "C";

                List <Sim> list = new List <Sim>();
                foreach (Sim sim in LotManager.Actors)
                {
                    if (ths.BasicNPCPerformerTest(sim))
                    {
                        list.Add(sim);
                    }
                }

                ths.LoadStage();
                PerformanceCareer.PerformanceAudiencePosture standing = PerformanceCareer.PerformanceAudiencePosture.Standing;
                ths.PreShowSetup();
                foreach (IShowFloor floor in ths.LotCurrent.GetObjects <IShowFloor>())
                {
                    floor.ResetShowFloor();
                    switch (standing)
                    {
                    case PerformanceCareer.PerformanceAudiencePosture.Standing:
                        floor.SetupShowFloorWithStandingLocations();
                        break;

                    case PerformanceCareer.PerformanceAudiencePosture.Sitting:
                        floor.SetupShowFloorWithSittingLocations();
                        break;
                    }
                }

                msg += "A";

                foreach (ICrowdMonster monster in ths.LotCurrent.GetObjects <ICrowdMonster>())
                {
                    switch (standing)
                    {
                    case PerformanceCareer.PerformanceAudiencePosture.Standing:
                        monster.CreateStandingCrowdMonster();
                        break;

                    case PerformanceCareer.PerformanceAudiencePosture.Sitting:
                        monster.CreateSittingCrowdMonster();
                        break;
                    }
                }

                msg += "B";

                ths.mDoesPerformanceAllowDancing = false;
                ths.Controller.PostEvent(ShowEventType.kShowSetup);
                string titleText = ShowStage.LocalizeString(ths.OwnerProprietor.IsFemale, "AnnounceSimFestStart", new object[] { ths.LotCurrent.Name });
                StyledNotification.Format format = new StyledNotification.Format(titleText, ths.OwnerProprietor.ObjectId, StyledNotification.NotificationStyle.kSystemMessage);
                StyledNotification.Show(format);
                ths.AddSimFestMapTags();

                msg += "D";

                bool addedAlarm = false;
                for (int i = 0x0; i < 0x3; i++)
                {
                    // Custom
                    Sim item = CreateAnNPCPerformer(ths);
                    if (item != null)
                    {
                        list.Add(item);
                        if (item.WasCreatedByAService && !addedAlarm)
                        {
                            addedAlarm = true;
                            new Common.AlarmTask(9, TimeUnit.Hours, HibernateServiceSims);
                        }
                    }
                }

                msg += "E";

                foreach (Sim sim3 in list)
                {
                    if (sim3 != null)
                    {
                        ths.PushWatchTheShowOntoSim(sim3);
                    }
                }

                msg += "F";

                int audienceSize = ths.GetSimFestDesiredAudienceSize() - list.Count;
                if (audienceSize > 0x0)
                {
                    ths.PullAudienceToLot(audienceSize);
                }

                msg += "G";

                ths.mSimFestStartAlarm = ths.AddAlarmRepeating(10f, TimeUnit.Minutes, ths.SimFestWaitForPerformers, "SimFestWaitForPerformers", AlarmType.AlwaysPersisted);
                ShowStage.SimFestWait entry = ShowStage.SimFestWait.Singleton.CreateInstance(ths, ths.OwnerProprietor, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), ths.OwnerProprietor.IsNPC, false) as ShowStage.SimFestWait;

                msg += "H";

                entry.mAction = ShowStage.SimFestWait.SimFestWaitAction.WaitForPerformers;
                ths.OwnerProprietor.InteractionQueue.AddNext(entry);

                Common.DebugWriteLog(msg);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }
        }
Example #8
0
        public static Sim CreateAnNPCPerformer(ShowStage ths)
        {            
            Sim createdSim = null;
            Lot lotCurrent = null;
            OccupationNames[] randomList = new OccupationNames[] { OccupationNames.SingerCareer, OccupationNames.MagicianCareer, OccupationNames.PerformanceArtistCareer };
            AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(RandomUtil.GetRandomObjectFromList(randomList), false, true);
            bool flag = RandomUtil.CoinFlip();

            // Custom
            List<SimDescription> list = Household.AllTownieSimDescriptions(ValidPerformer);            
            if (list.Count != 0)
            {
                SimDescription randomObjectFromList = RandomUtil.GetRandomObjectFromList(list);
                if (randomObjectFromList.CreatedSim == null)
                {
                    lotCurrent = ths.LotCurrent;
                    createdSim = randomObjectFromList.Instantiate(lotCurrent);
                }
                else
                {
                    createdSim = randomObjectFromList.CreatedSim;
                }
            }
            else
            {
                Sim servicePerformer = CreateServicePerformer(ths);
                if (servicePerformer != null)
                {
                    createdSim = servicePerformer;                    
                }
            }

            if (createdSim == null)
            {
                return null;
            }

            GoToLot interaction = GoToLot.Singleton.CreateInstanceWithCallbacks(ths.LotCurrent, createdSim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, true, null, new Callback(GoToLotSuccess), new Callback(GoToLotFailure)) as GoToLot;
            if(createdSim.InteractionQueue != null)
            {
                Common.DebugNotify("Pushing GoToLot on " + createdSim.FullName);
                createdSim.InteractionQueue.Add(interaction);
            }

            if (createdSim.CareerManager == null)
            {                
                return null;
            }

            if (createdSim.CareerManager.OccupationAsPerformanceCareer == null)
            {
                try
                {
                    if (createdSim.WasCreatedByAService)
                    {                        
                        switch(createdSim.Service.ServiceType)
                        {
                            case ServiceType.Magician:
                                occupationParameters = new AcquireOccupationParameters(OccupationNames.MagicianCareer, false, true);
                                break;
                            case ServiceType.Singer:
                                occupationParameters = new AcquireOccupationParameters(OccupationNames.SingerCareer, false, true);
                                break;
                            case ServiceType.PerformanceArtist:
                                occupationParameters = new AcquireOccupationParameters(OccupationNames.PerformanceArtistCareer, false, true);
                                break;
                            default:
                                break;
                        }
                    }

                    createdSim.AcquireOccupation(occupationParameters);

                    int num = flag ? RandomUtil.GetInt(0x0, 0x5) : RandomUtil.GetInt(0x5, createdSim.Occupation.HighestLevel);
                    for (int i = 0x1; i < num; i++)
                    {
                        createdSim.CareerManager.Occupation.PromoteSim();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(createdSim, e);
                    return null;
                }
            }
            return createdSim;
        }
Example #9
0
        public static void SetupSimFest(ShowStage ths)
        {
            Common.StringBuilder msg = new Common.StringBuilder("SetupSimFest");

            try
            {
                if ((ths.OwnerProprietor == null) || (ths.OwnerProprietor.HasBeenDestroyed))
                {
                    if (ths.CurrentRole == null) return;

                    ths.OwnerProprietor = ths.CurrentRole.SimInRole;
                    if ((ths.OwnerProprietor == null) || (ths.OwnerProprietor.HasBeenDestroyed))
                    {
                        return;
                    }
                }               

                CommonSpace.Helpers.ShowStageEx.Cleanup(ths, null);

                msg += "C";

                List<Sim> list = new List<Sim>();
                foreach (Sim sim in LotManager.Actors)
                {
                    if (ths.BasicNPCPerformerTest(sim))
                    {
                        list.Add(sim);
                    }
                }

                ths.LoadStage();
                PerformanceCareer.PerformanceAudiencePosture standing = PerformanceCareer.PerformanceAudiencePosture.Standing;
                ths.PreShowSetup();
                foreach (IShowFloor floor in ths.LotCurrent.GetObjects<IShowFloor>())
                {
                    floor.ResetShowFloor();
                    switch (standing)
                    {
                        case PerformanceCareer.PerformanceAudiencePosture.Standing:
                            floor.SetupShowFloorWithStandingLocations();
                            break;

                        case PerformanceCareer.PerformanceAudiencePosture.Sitting:
                            floor.SetupShowFloorWithSittingLocations();
                            break;
                    }
                }

                msg += "A";

                foreach (ICrowdMonster monster in ths.LotCurrent.GetObjects<ICrowdMonster>())
                {
                    switch (standing)
                    {
                        case PerformanceCareer.PerformanceAudiencePosture.Standing:
                            monster.CreateStandingCrowdMonster();
                            break;

                        case PerformanceCareer.PerformanceAudiencePosture.Sitting:
                            monster.CreateSittingCrowdMonster();
                            break;
                    }
                }

                msg += "B";

                ths.mDoesPerformanceAllowDancing = false;
                ths.Controller.PostEvent(ShowEventType.kShowSetup);
                string titleText = ShowStage.LocalizeString(ths.OwnerProprietor.IsFemale, "AnnounceSimFestStart", new object[] { ths.LotCurrent.Name });
                StyledNotification.Format format = new StyledNotification.Format(titleText, ths.OwnerProprietor.ObjectId, StyledNotification.NotificationStyle.kSystemMessage);
                StyledNotification.Show(format);
                ths.AddSimFestMapTags();

                msg += "D";

                bool addedAlarm = false;
                for (int i = 0x0; i < 0x3; i++)
                {
                    // Custom
                    Sim item = CreateAnNPCPerformer(ths);
                    if (item != null)
                    {
                        list.Add(item);
                        if (item.WasCreatedByAService && !addedAlarm)
                        {                            
                            addedAlarm = true;
                            new Common.AlarmTask(9, TimeUnit.Hours, HibernateServiceSims);
                        }
                    }                    
                }

                msg += "E";

                foreach (Sim sim3 in list)
                {
                    if (sim3 != null)
                    {                        
                        ths.PushWatchTheShowOntoSim(sim3);
                    }
                }

                msg += "F";

                int audienceSize = ths.GetSimFestDesiredAudienceSize() - list.Count;
                if (audienceSize > 0x0)
                {                    
                    ths.PullAudienceToLot(audienceSize);
                }

                msg += "G";

                ths.mSimFestStartAlarm = ths.AddAlarmRepeating(10f, TimeUnit.Minutes, ths.SimFestWaitForPerformers, "SimFestWaitForPerformers", AlarmType.AlwaysPersisted);
                ShowStage.SimFestWait entry = ShowStage.SimFestWait.Singleton.CreateInstance(ths, ths.OwnerProprietor, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), ths.OwnerProprietor.IsNPC, false) as ShowStage.SimFestWait;

                msg += "H";                

                entry.mAction = ShowStage.SimFestWait.SimFestWaitAction.WaitForPerformers;
                ths.OwnerProprietor.InteractionQueue.AddNext(entry);

                Common.DebugWriteLog(msg);                
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }
        }
Example #10
0
        public static Sim CreateServicePerformer(ShowStage ths)
        {            
            List<Service> services = new List<Service>{Magician.Instance, Singer.Instance, PerformanceArtist.Instance};
            int attempts = 0;
            Sim performer = null;
            while (performer == null && attempts <= 5)
            {
                Service service = RandomUtil.GetRandomObjectFromList(services);                
                if (service != null)
                {                    
                    foreach (SimDescription description in service.mPool)
                    {
                        if (!service.IsSimAssignedTask(description) && description.CreatedSim == null)
                        {                            
                            int lotAttempts = 0;
                            Lot lot = null;
                            while(lot == null && lotAttempts <= 5)
                            {
                                lot = LotManager.SelectRandomLot(null);
                                lotAttempts++;
                            }

                            if (lot != null)
                            {                                
                                Sim createdSim = service.CreateSim(lot, description);
                                if (createdSim != null)
                                {                                    
                                    createdSim.FadeIn();
                                    performer = createdSim;
                                    break;
                                }
                            }
                        }
                    }
                }
                attempts++;
            }            

            return performer;            
        }