コード例 #1
0
ファイル: PlanResortUniformEx.cs プロジェクト: yakoder/NRaas
        public override bool Run()
        {
            try
            {
                if (IntroTutorial.IsRunning && !IntroTutorial.AreYouExitingTutorial())
                {
                    return(false);
                }
                if (GameStates.IsCurrentlySwitchingSubStates)
                {
                    return(false);
                }
                Sim target = Target;
                if (target == null)
                {
                    throw new Exception("EditSimInCAS: Cannot edit a non-sim!");
                }

                if (Responder.Instance.OptionsModel.SaveGameInProgress)
                {
                    return(false);
                }

                mTookSemaphore = GameStates.WaitForInteractionStateChangeSemaphore(Target, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                if (!mTookSemaphore)
                {
                    return(false);
                }

                ResortExpenseDialog.SwitchToCAS();

                try
                {
                    new Sims.Stylist(Sims.CASBase.EditType.Uniform).Perform(new GameHitParameters <GameObject>(target, target, GameObjectHit.NoHit));

                    while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode)
                    {
                        SpeedTrap.Sleep(0);
                    }

                    if (!CASChangeReporter.Instance.CasCancelled)
                    {
                        ResortWorker service = target.Service as ResortWorker;
                        if (service != null)
                        {
                            service.SetIsUsingCustomUniform(target.SimDescription.SimDescriptionId);
                        }
                        else
                        {
                            ResortMaintenance maintenance = target.Service as ResortMaintenance;
                            if (maintenance != null)
                            {
                                ServiceSituation situationOfType = target.GetSituationOfType <ServiceSituation>();
                                if (situationOfType != null)
                                {
                                    maintenance.SetWorkerOutfit(target.SimDescription, situationOfType.Lot.LotId, target.SimDescription.GetOutfit(OutfitCategories.Career, 0));
                                }
                            }
                        }
                    }
                    CASChangeReporter.Instance.ClearChanges();
                }
                finally
                {
                    ResortExpenseDialog.SwitchFromCAS();
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }

            return(false);
        }
コード例 #2
0
        public override bool Run()
        {
            try
            {
                if (IntroTutorial.IsRunning && !IntroTutorial.AreYouExitingTutorial())
                {
                    return(false);
                }

                if (GameStates.IsCurrentlySwitchingSubStates)
                {
                    return(false);
                }

                if (Responder.Instance.OptionsModel.SaveGameInProgress)
                {
                    return(false);
                }

                ResortStaffedObjectComponent resortStaffedObjectComponent = Target.ResortStaffedObjectComponent;
                if (Target.ResortStaffedObjectComponent == null)
                {
                    return(false);
                }

                ResortWorker   service        = resortStaffedObjectComponent.GetService();
                SimDescription assignedWorker = service.GetAssignedWorker(Target);
                if (assignedWorker == null)
                {
                    Sim worker = service.GetWorker(Target);
                    if (worker != null)
                    {
                        assignedWorker = worker.SimDescription;
                    }
                }

                if (assignedWorker == null)
                {
                    return(false);
                }

                mTookSemaphore = GameStates.WaitForInteractionStateChangeSemaphore();
                if (!mTookSemaphore)
                {
                    return(false);
                }

                ResortExpenseDialog.SwitchToCAS();

                try
                {
                    new Sims.Stylist(Sims.CASBase.EditType.Uniform).Perform(new GameHitParameters <SimDescriptionObject>(Sim.ActiveActor, new SimDescriptionObject(assignedWorker), GameObjectHit.NoHit));

                    while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode)
                    {
                        SpeedTrap.Sleep(0);
                    }

                    if (!CASChangeReporter.Instance.CasCancelled)
                    {
                        service = assignedWorker.Service as ResortWorker;
                        if (service != null)
                        {
                            service.SetIsUsingCustomUniform(assignedWorker.SimDescriptionId);
                        }
                        else
                        {
                            ResortMaintenance maintenance = assignedWorker.Service as ResortMaintenance;
                            if (maintenance != null)
                            {
                                maintenance.SetWorkerOutfit(assignedWorker, Target.LotCurrent.LotId, assignedWorker.GetOutfit(OutfitCategories.Career, 0));
                            }
                        }
                    }
                    CASChangeReporter.Instance.ClearChanges();
                }
                finally
                {
                    ResortExpenseDialog.SwitchFromCAS();
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }

            return(false);
        }