Example #1
0
        private static bool CheckAllRequirements(Sim s, Opportunity op, OpportunityNames lastOpName, ref string msg)
        {
            Opportunity.OpportunitySharedData sharedData = op.SharedData;
            WorldName mTargetWorldRequired = sharedData.mTargetWorldRequired;
            WorldName currentWorld         = GameUtils.GetCurrentWorld();

            if (mTargetWorldRequired == WorldName.SunsetValley)
            {
                mTargetWorldRequired = s.SimDescription.HomeWorld;
            }
            if ((mTargetWorldRequired == currentWorld) || (mTargetWorldRequired == WorldName.Undefined))
            {
                foreach (Opportunity.OpportunitySharedData.RequirementInfo info in sharedData.mRequirementList)
                {
                    if (info.mType == RequirementType.OpportunityComplete)
                    {
                        OpportunityNames mGuid = (OpportunityNames)info.mGuid;
                        if (lastOpName == mGuid)
                        {
                            continue;
                        }
                    }
                    if (!op.CheckRequirement(info, s, sharedData))
                    {
                        msg += Common.NewLine + " Failure: " + info.mType;

                        return(false);
                    }
                }
            }
            OpportunityNames mCompletionTriggerOpportunity = sharedData.mCompletionTriggerOpportunity;

            if (mCompletionTriggerOpportunity != OpportunityNames.Undefined)
            {
                Opportunity staticOpportunity = OpportunityManager.GetStaticOpportunity(mCompletionTriggerOpportunity);
                if ((staticOpportunity != null) && !op.CheckAllRequirements(s, staticOpportunity, sharedData.mGuid))
                {
                    msg += Common.NewLine + " Failure: B";
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
 public KillOpportunity(Opportunity.OpportunitySharedData sharedData)
     : base(sharedData)
 {
 }
Example #3
0
 public RecruitOpportunity(Opportunity.OpportunitySharedData sharedData)
     : base(sharedData)
 {
 }
Example #4
0
        protected override void PerformFile(BooterHelper.BootFile file)
        {
            BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile;
            if (dataFile == null) return;

            XmlDbTable table = dataFile.GetTable("OpportunitiesSetup");
            if (table == null)
            {
                if (file.mPrimary)
                {
                    BooterLogger.AddTrace(file + ": No OpportunitiesSetup");
                }
                else
                {
                    BooterLogger.AddError(file + ": No OpportunitiesSetup");
                }
                return;
            }

            BooterLogger.AddTrace(file + ": Found List = " + table.Rows.Count);

            foreach (XmlDbRow row in table.Rows)
            {
                Opportunity.OpportunitySharedData data = new Opportunity.OpportunitySharedData();
                ParserFunctions.TryParseEnum<ProductVersion>(row.GetString("ProductVersion"), out data.mProductVersion, ProductVersion.BaseGame);

                data.mGuid = GenericManager<OpportunityNames, Opportunity, Opportunity>.ParseGuid(row["GUID"]);

                // New Code
                if (data.mGuid == OpportunityNames.Undefined)
                {
                    data.mGuid = unchecked((OpportunityNames)ResourceUtils.HashString64(row["GUID"]));
                }

                if (GameUtils.IsInstalled(data.mProductVersion))
                {
                    string str2 = row.GetString("Icon");
                    if (!string.IsNullOrEmpty(str2))
                    {
                        data.mIconKey = ResourceKey.CreatePNGKey(str2, 0x0);
                    }
                    ParserFunctions.TryParseEnum<Repeatability>(row["RepeatLevel"], out data.mRepeatLevel, Repeatability.Undefined);
                    data.SetFlags(Opportunity.OpportunitySharedData.FlagField.Ordered, row.GetBool("IsOrdered"));
                    data.SetFlags(Opportunity.OpportunitySharedData.FlagField.Counted, row.GetBool("IsCounted"));
                    data.SetFlags(Opportunity.OpportunitySharedData.FlagField.Totaled, row.GetBool("IsTotaled"));
                    data.mCountOrTotal = row.GetFloat("CountOrTotal", 0f);
                    string str3 = row["Timeout"];
                    if (str3 != string.Empty)
                    {
                        ParserFunctions.TryParseEnum<Opportunity.OpportunitySharedData.TimeoutCondition>(row["Timeout"], out data.mTimeout, Opportunity.OpportunitySharedData.TimeoutCondition.None);
                    }
                    if (data.mTimeout == Opportunity.OpportunitySharedData.TimeoutCondition.SimTime)
                    {
                        if (row.GetString("TimeoutData") != null)
                        {
                            data.mTimeoutData = ParserFunctions.ParseTime(row.GetString("TimeoutData"));
                        }
                        else
                        {
                            BooterLogger.AddError(file + ": TimeoutData missing " + row["GUID"]);
                        }
                    }
                    else
                    {
                        data.mTimeoutData = row.GetFloat("TimeoutData");

                        if (row.GetString("TimeoutEnd") != null)
                        {
                            data.mTimeoutEnd = ParserFunctions.ParseTime(row.GetString("TimeoutEnd"));
                        }
                        else
                        {
                            BooterLogger.AddError(file + ": TimeoutEnd missing " + row["GUID"]);
                        }
                    }
                    string name = row["Loss"];
                    if (name != string.Empty)
                    {
                        ParserFunctions.TryParseEnum<Opportunity.OpportunitySharedData.TimeoutCondition>(name, out data.mLoss, Opportunity.OpportunitySharedData.TimeoutCondition.None);
                    }
                    if (data.mLoss == Opportunity.OpportunitySharedData.TimeoutCondition.SimTime)
                    {
                        if (row.GetString("LossData") != null)
                        {
                            data.mLossData = ParserFunctions.ParseTime(row.GetString("LossData"));
                        }
                        else
                        {
                            BooterLogger.AddError(file + ": LossData missing " + row["GUID"]);
                        }
                    }
                    else
                    {
                        data.mLossData = row.GetFloat("LossData");
                    }

                    data.mChanceToGetOnPhone = row.GetFloat("ChanceToGetOnPhone");
                    row.TryGetEnum<OpportunityAvailability>("Availability", out data.mOpportunityAvailability, OpportunityAvailability.Undefined);
                    data.mOpportunityType = OpportunityType.Undefined;
                    row.TryGetEnum<OpportunityType>("OpportunityType", out data.mOpportunityType, OpportunityType.Undefined);
                    data.mEventList = OpportunityManager.ParseEvents(row, data.mGuid);
                    List<string> entry = row.GetStringList("CompletionEvent", ',', false);
                    if (entry.Count == 0x0)
                    {
                        data.mCompletionEvent = null;
                    }
                    else
                    {
                        data.mCompletionEvent = OpportunityManager.ParseOneEvent(entry, row, data.mGuid);
                        if (data.mOpportunityType == OpportunityType.Career)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateCareer);
                        }
                        else if (data.mOpportunityType == OpportunityType.Skill)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateSkill);
                        }
                        else if (data.mOpportunityType == OpportunityType.Location)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateSpecial);
                        }
                        else if (data.mOpportunityType == OpportunityType.AdventureChina)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateAdventureChina);
                        }
                        else if (data.mOpportunityType == OpportunityType.AdventureEgypt)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateAdventureEgypt);
                        }
                        else if (data.mOpportunityType == OpportunityType.AdventureFrance)
                        {
                            data.mCompletionEvent.mEventDelegate = new ProcessEventDelegate(Opportunity.ProcessCompletionEventDelegateAdventureFrance);
                        }
                    }
                    data.SetFlags(Opportunity.OpportunitySharedData.FlagField.AllowPhoneCompletion, row.GetBool("AllowPhoneCompletion"));
                    string str5 = row.GetString("CompletionProceduralTestFunction");
                    if (!string.IsNullOrEmpty(str5) && (OpportunityManager.sOpportunitiesTestClassType != null))
                    {
                        MethodInfo method = OpportunityManager.sOpportunitiesTestClassType.GetMethod(str5, BindingFlags.Public | BindingFlags.Static);
                        if (method != null)
                        {
                            data.mTargetProceduralTestDelegate = Delegate.CreateDelegate(typeof(OpportunityTargetProceduralTestDelegate), method) as OpportunityTargetProceduralTestDelegate;
                        }
                    }
                    Opportunity opportunity = null;
                    string typeName = row.GetString("CustomOpportunityClass");
                    if (typeName.Length > 0x0)
                    {
                        Type type = Type.GetType(typeName);
                        if (type != null)
                        {
                            Type[] types = new Type[] { typeof(Opportunity.OpportunitySharedData) };

                            try
                            {
                                opportunity = (Opportunity)type.GetConstructor(types).Invoke(new object[] { data });
                            }
                            catch
                            {
                                BooterLogger.AddError(file + ": Constructor Fail " + typeName);
                            }
                        }
                    }
                    else if (data.HasFlags(Opportunity.OpportunitySharedData.FlagField.Counted))
                    {
                        opportunity = new CountedOpportunity(data);
                    }
                    else if (data.HasFlags(Opportunity.OpportunitySharedData.FlagField.Totaled))
                    {
                        opportunity = new TotaledOpportunity(data);
                    }
                    else if (data.HasFlags(Opportunity.OpportunitySharedData.FlagField.Ordered))
                    {
                        opportunity = new OrderedOpportunity(data);
                    }
                    else
                    {
                        opportunity = new Opportunity(data);
                    }

                    if (opportunity != null)
                    {
                        // New code
                        GenericManager<OpportunityNames, Opportunity, Opportunity>.sDictionary[(ulong)opportunity.Guid] = opportunity;

                        if (opportunity.IsLocationBased && (opportunity.Guid != OpportunityNames.Special_RestoreGhost))
                        {
                            // New code
                            OpportunityManager.sLocationBasedOpportunityList[opportunity.Guid] = opportunity;
                            continue;
                        }
                        if (opportunity.IsSkill || (opportunity.Guid == OpportunityNames.Special_RestoreGhost))
                        {
                            // New code
                            OpportunityManager.sSkillOpportunityList[opportunity.Guid] = opportunity;
                            continue;
                        }
                        if (opportunity.IsAdventureChina)
                        {
                            // New code
                            OpportunityManager.sAdventureChinaOpportunityList[opportunity.Guid] = opportunity;
                        }
                        else
                        {
                            if (opportunity.IsAdventureEgypt)
                            {
                                // New code
                                OpportunityManager.sAdventureEgyptOpportunityList[opportunity.Guid] = opportunity;
                                continue;
                            }
                            if (opportunity.IsAdventureFrance)
                            {
                                // New code
                                OpportunityManager.sAdventureFranceOpportunityList[opportunity.Guid] = opportunity;
                            }
                        }
                    }
                }
            }

            ParseOpportunityNames(dataFile, table.Rows.Count);
            ParseOpportunityRequirements(dataFile, table.Rows.Count);
            ParseOpportunitySetup(dataFile, table.Rows.Count);
            ParseOpportunityCompletion(dataFile, table.Rows.Count);
        }
Example #5
0
 public OpportunityEx(Opportunity.OpportunitySharedData sharedData)
     : base(sharedData)
 {
 }