Exemple #1
0
        protected override bool Allow(GameHitParameters <IGameObject> parameters)
        {
            mTarget = Select.GetGiver(parameters.mTarget);
            if (mTarget == null)
            {
                return(false);
            }

            if (RoleManagerTaskEx.IsLoading)
            {
                return(false);
            }

            if (mTarget.CurrentRole == null)
            {
                return(false);
            }

            if (!Common.kDebugging)
            {
                SimDescription sim = mTarget.CurrentRole.mSim;
                if (sim == null)
                {
                    return(false);
                }
            }

            return(base.Allow(parameters));
        }
Exemple #2
0
        protected override OptionResult Run(GameHitParameters <IGameObject> parameters)
        {
            IRoleGiver giver = GetGiver(parameters.mTarget);

            if (giver == null)
            {
                return(OptionResult.Failure);
            }

            SimDescription sim = PrivateRun(parameters.mActor, giver.RoleType, parameters.mHit);

            if (sim == null)
            {
                return(OptionResult.Failure);
            }

            if (GameUtils.IsFutureWorld() && (giver.RoleType == Role.RoleType.BotShopMerchant || giver.RoleType == Role.RoleType.CafeteriaWaiter) && !sim.IsEP11Bot)
            {
                return(OptionResult.Failure);
            }

            if (!Register.DropRole(sim, giver))
            {
                return(OptionResult.Failure);
            }

            if (Register.AssignRole(sim, giver.RoleType, giver))
            {
                return(OptionResult.SuccessClose);
            }
            else
            {
                return(OptionResult.Failure);
            }
        }
Exemple #3
0
        public static bool DropRole(SimDescription sim, IRoleGiver target)
        {
            if (RoleManager.sRoleManager == null)
            {
                return(false);
            }

            if (target != null)
            {
                switch (target.RoleType)
                {
                case Role.RoleType.SpecialMerchant:
                case Role.RoleType.Explorer:
                case Role.RoleType.Tourist:
                    return(false);
                }

                if (target.CurrentRole != null)
                {
                    target.CurrentRole.RemoveSimFromRole();
                }
            }

            if (sim.AssignedRole != null)
            {
                sim.AssignedRole.RemoveSimFromRole();
            }

            return(true);
        }
        private string GetId(object item)
        {
            string id = null;

            if (item != null)
            {
                SimDescription simD = item as SimDescription;
                if (simD != null)
                {
                    id = simD.FullName;
                }

                if (id == null)
                {
                    Sim sim = item as Sim;
                    if (sim != null)
                    {
                        id = sim.FullName;
                    }
                }

                if (id == null)
                {
                    Role roleItem = item as Role;
                    if (roleItem != null)
                    {
                        id = GetId(roleItem.SimInRole);
                    }
                }

                if (id == null)
                {
                    IRoleGiver roleItem = item as IRoleGiver;
                    if (roleItem != null && roleItem.CurrentRole != null)
                    {
                        id = GetId(roleItem.CurrentRole.mSim);
                    }
                }

                if (id == null)
                {
                    IInteractionInstance roleItem = item as IInteractionInstance;
                    if (roleItem != null)
                    {
                        id = GetId(roleItem.IInstanceActor);
                    }
                }

                if (id == null)
                {
                    id = item.GetHashCode().ToString();
                }
            }
            else
            {
                id = "null";
            }

            return(id);
        }
Exemple #5
0
        protected override bool Allow(GameHitParameters <IGameObject> parameters)
        {
            mTarget = Select.GetGiver(parameters.mTarget);
            if (mTarget == null)
            {
                return(false);
            }

            if (RoleManagerTaskEx.IsLoading)
            {
                return(false);
            }

            return(base.Allow(parameters));
        }
Exemple #6
0
        public static bool IsSimGoodForRole(IMiniSimDescription sim, RoleData role, IRoleGiver roleGiver, out string reason)
        {
            if (role == null)
            {
                reason = "No Role";
                return(false);
            }

            if (!IsSimValidForAnyRole(sim, role.Type, out reason))
            {
                return(false);
            }

            return(IsSimGoodForRoleCommonTest(sim, role, roleGiver, out reason));
        }
Exemple #7
0
        public static IRoleGiver GetGiver(IGameObject target)
        {
            IRoleGiver giver = target as IRoleGiver;

            if (giver != null)
            {
                return(giver);
            }

            ShowStage[] stages = target.LotCurrent.GetObjects <ShowStage>();

            if (stages.Length != 1)
            {
                return(null);
            }

            return(stages[0]);
        }
Exemple #8
0
        public static bool AssignRole(SimDescription sim, Role.RoleType type, IRoleGiver target)
        {
            try
            {
                RoleData data = RoleData.GetDataForCurrentWorld(type, true);
                if (data == null)
                {
                    return(false);
                }

                Role role = Role.CreateRole(data, sim, target);
                if (role == null)
                {
                    return(false);
                }

                if ((role.Data.StartTime == role.Data.EndTime) || (data.IsValidTimeForRole()))
                {
                    role.StartRoleAlarmHandler();
                }

                RoleManager.sRoleManager.AddRole(role);

                if (target != null)
                {
                    target.CurrentRole = role;
                }

                ShowNotice(role);
            }
            catch (Exception e)
            {
                Exception(sim, e);
            }

            return(true);
        }
Exemple #9
0
        protected override OptionResult Run(GameHitParameters <IGameObject> parameters)
        {
            IRoleGiver giver = Select.GetGiver(parameters.mTarget);

            if (giver == null)
            {
                return(OptionResult.Failure);
            }

            if (giver.CurrentRole == null)
            {
                return(OptionResult.Failure);
            }

            Sim sim = giver.CurrentRole.SimInRole;

            giver.CurrentRole.RemoveSimFromRole();

            if (sim != null)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Remove:Success", sim.IsFemale, new object[] { sim }));
            }
            return(OptionResult.SuccessRetain);
        }
 public Courtesan(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }
Exemple #11
0
        public static bool IsSimGoodForRole(IMiniSimDescription sim, RoleData role, IRoleGiver roleGiver)
        {
            string reason = null;

            return(IsSimGoodForRole(sim, role, roleGiver, out reason));
        }
 public Anysim(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
     base.mIsStoryProgressionProtected = false;
 }
Exemple #13
0
        public static bool AssignRole(SimDescription sim, Role.RoleType type, IRoleGiver target)
        {
            try
            {
                RoleData data = RoleData.GetDataForCurrentWorld(type, true);
                if (data == null) return false;

                Role role = Role.CreateRole(data, sim, target);
                if (role == null) return false;

                if ((role.Data.StartTime == role.Data.EndTime) || (data.IsValidTimeForRole()))
                {
                    role.StartRoleAlarmHandler();
                }

                RoleManager.sRoleManager.AddRole(role);

                if (target != null)
                {
                    target.CurrentRole = role;
                }

                ShowNotice(role);
            }
            catch(Exception e)
            {
                Exception(sim, e);
            }

            return true;
        }
Exemple #14
0
        public static bool DropRole(SimDescription sim, IRoleGiver target)
        {
            if (RoleManager.sRoleManager == null) return false;

            if (target != null)
            {
                switch (target.RoleType)
                {
                    case Role.RoleType.SpecialMerchant:
                    case Role.RoleType.Explorer:
                    case Role.RoleType.Tourist:
                        return false;
                }

                if (target.CurrentRole != null)
                {
                    target.CurrentRole.RemoveSimFromRole();
                }
            }

            if (sim.AssignedRole != null)
            {
                sim.AssignedRole.RemoveSimFromRole();
            }

            return true;
        }
Exemple #15
0
        public static bool IsSimGoodForRole(IMiniSimDescription sim, RoleData role, IRoleGiver roleGiver, out string reason)
        {
            if (role == null)
            {
                reason = "No Role";
                return false;
            }

            if (!IsSimValidForAnyRole(sim, role.Type, out reason)) return false;

            return IsSimGoodForRoleCommonTest(sim, role, roleGiver, out reason);
        }
 public Drunkard(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }
Exemple #17
0
 public static bool IsSimGoodForRole(IMiniSimDescription sim, RoleData role, IRoleGiver roleGiver)
 {
     string reason = null;
     return IsSimGoodForRole(sim, role, roleGiver, out reason);
 }
Exemple #18
0
        private static bool IsSimGoodForRoleCommonTest(IMiniSimDescription desc, RoleData data, IRoleGiver roleGiver, out string reason)
        {
            WorldName homeWorld = desc.HomeWorld;

            /*
            bool isCelebrity = desc.IsCelebrity;
            if (!data.CanBeCelebrity && isCelebrity)
            {
                reason = "Celebrity Fail";
                return false;
            }
            */
            if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(desc.Age | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None)
            {
                reason = "Age/Species Fail";
                return false;
            }

            SimDescription description = desc as SimDescription;
            if (((description != null) && (description.CreatedSim == null)) && (description.WillAgeUpOnInstantiation && ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(AgingState.GetNextOlderAge(desc.Age, desc.Species) | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None)))
            {
                reason = "Age/Species Fail";
                return false;
            }

            if (data.FillRoleFrom == Role.RoleFillFrom.PeopleWhoDontLiveInThisWorld)
            {                
                if ((homeWorld != WorldName.TouristWorld) && (GameUtils.GetWorldType(homeWorld) != WorldType.Vacation) && (GameUtils.GetWorldType(homeWorld) != WorldType.Future))
                {
                    reason = "Vacation World Fail";
                    return false;
                }
                if (homeWorld == GameUtils.GetCurrentWorld())
                {
                    reason = "Home World Fail";
                    return false;
                }
                if (GameUtils.GetWorldType(homeWorld) == WorldType.Future)
                {
                    if (Sims3.Gameplay.Queries.CountObjects<ITimePortal>() == 0)
                    {
                        reason = "Time Portal Fail";
                        return false;
                    }                    
                }
            }
            /*
            else if (data.FillRoleFrom == RoleFillFrom.CustomCreatedSim)
            {
                return false;
            }
            */

            IRoleGiverCustomIsSimGoodTest test = roleGiver as IRoleGiverCustomIsSimGoodTest;
            if ((test != null) && (!test.IsSimGoodForRole(desc)))
            {
                reason = "Role Giver Fail";
                return false;
            }

            reason = "Success";
            return true;
        }
Exemple #19
0
        private static bool IsSimGoodForRoleCommonTest(IMiniSimDescription desc, RoleData data, IRoleGiver roleGiver, out string reason)
        {
            WorldName homeWorld = desc.HomeWorld;

            /*
             * bool isCelebrity = desc.IsCelebrity;
             * if (!data.CanBeCelebrity && isCelebrity)
             * {
             *  reason = "Celebrity Fail";
             *  return false;
             * }
             */
            if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(desc.Age | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None)
            {
                reason = "Age/Species Fail";
                return(false);
            }

            SimDescription description = desc as SimDescription;

            if (((description != null) && (description.CreatedSim == null)) && (description.WillAgeUpOnInstantiation && ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(AgingState.GetNextOlderAge(desc.Age, desc.Species) | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None)))
            {
                reason = "Age/Species Fail";
                return(false);
            }

            if (data.FillRoleFrom == Role.RoleFillFrom.PeopleWhoDontLiveInThisWorld)
            {
                if ((homeWorld != WorldName.TouristWorld) && (GameUtils.GetWorldType(homeWorld) != WorldType.Vacation) && (GameUtils.GetWorldType(homeWorld) != WorldType.Future))
                {
                    reason = "Vacation World Fail";
                    return(false);
                }
                if (homeWorld == GameUtils.GetCurrentWorld())
                {
                    reason = "Home World Fail";
                    return(false);
                }
                if (GameUtils.GetWorldType(homeWorld) == WorldType.Future)
                {
                    if (Sims3.Gameplay.Queries.CountObjects <ITimePortal>() == 0)
                    {
                        reason = "Time Portal Fail";
                        return(false);
                    }
                }
            }

            /*
             * else if (data.FillRoleFrom == RoleFillFrom.CustomCreatedSim)
             * {
             *  return false;
             * }
             */

            IRoleGiverCustomIsSimGoodTest test = roleGiver as IRoleGiverCustomIsSimGoodTest;

            if ((test != null) && (!test.IsSimGoodForRole(desc)))
            {
                reason = "Role Giver Fail";
                return(false);
            }

            reason = "Success";
            return(true);
        }
Exemple #20
0
 public Anysim(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
     base.mIsStoryProgressionProtected = false;
 }
 public ExoticDancer(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }
Exemple #22
0
 public Drunkard(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }
 public Courtesan(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }
 public ExoticDancer(RoleData data, SimDescription s, IRoleGiver roleGiver)
     : base(data, s, roleGiver)
 {
 }