protected override OptionResult Run(GameHitParameters<GameObject> parameters) { IEnumerable<FilePersistenceEx.Item> selection = FilePersistenceEx.GetChoices(Name); if (selection == null) return OptionResult.Failure; Common.StringBuilder builder = new Common.StringBuilder(FilePersistence.sHeader + Common.NewLine + "<Settings>"); foreach (FilePersistenceEx.Item choice in selection) { string text = choice.CreateExportString(); if (!string.IsNullOrEmpty(text)) { builder.Append(text); } } builder.Append(Common.NewLine + "</Settings>"); Common.DebugWriteLog(builder); FilePersistence.ExportToFile(builder.ToString()); return OptionResult.SuccessRetain; }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder builder = new Common.StringBuilder(); foreach (VectorBooter.Data vector in VectorBooter.Vectors) { builder.Append(Common.NewLine + Common.NewLine + vector.ToString()); } foreach (SymptomBooter.Data symptom in SymptomBooter.Symptoms) { builder.Append(Common.NewLine + Common.NewLine + symptom.ToString()); } foreach (ResistanceBooter.Data resistance in ResistanceBooter.Resistances) { builder.Append(Common.NewLine + Common.NewLine + resistance.ToString()); } builder.Append(Common.NewLine + Vector.Settings.Dump()); Common.DebugWriteLog(builder); return(OptionResult.SuccessRetain); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { IEnumerable <FilePersistenceEx.Item> selection = FilePersistenceEx.GetChoices(Name); if (selection == null) { return(OptionResult.Failure); } Common.StringBuilder builder = new Common.StringBuilder(FilePersistence.sHeader + Common.NewLine + "<Settings>"); foreach (FilePersistenceEx.Item choice in selection) { string text = choice.CreateExportString(); if (!string.IsNullOrEmpty(text)) { builder.Append(text); } } builder.Append(Common.NewLine + "</Settings>"); Common.DebugWriteLog(builder); FilePersistence.ExportToFile(builder.ToString()); return(OptionResult.SuccessRetain); }
protected override bool PrivatePerform() { List <OptionItem> options = new List <OptionItem>(); Manager.GetOptions(options, true, null); Common.StringBuilder builder = new Common.StringBuilder(); int index = 0; while (index < options.Count) { OptionItem option = options[index]; index++; builder.Append(Common.NewLine + option.Name); MasterListingOption master = option as MasterListingOption; if (master != null) { foreach (OptionItem subItem in master.GetOptions()) { options.Insert(index, subItem); } } } Common.WriteLog(builder); return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder builder = new Common.StringBuilder(); Dictionary <ulong, List <SimDescription> > allSims = SimListing.AllSims <SimDescription>(null, true); foreach (VectorBooter.Data vector in VectorBooter.Vectors) { Dictionary <string, List <SimDescription> > stages = new Dictionary <string, List <SimDescription> >(); foreach (KeyValuePair <ulong, List <DiseaseVector> > sims in Vector.Settings.AllVectors) { List <SimDescription> choices; if (!allSims.TryGetValue(sims.Key, out choices)) { continue; } SimDescription sim = choices[0]; foreach (DiseaseVector disease in sims.Value) { if (disease.Guid != vector.Guid) { continue; } string key = disease.StageName + " " + disease.Strain; List <SimDescription> value; if (!stages.TryGetValue(key, out value)) { value = new List <SimDescription>(); stages.Add(key, value); } value.Add(sim); } } string result = Common.NewLine + vector.Guid; foreach (KeyValuePair <string, List <SimDescription> > stage in stages) { result += Common.NewLine + " " + stage.Key + " : " + stage.Value.Count; foreach (SimDescription sim in stage.Value) { result += Common.NewLine + " " + sim.FullName; } } builder.Append(result); } Common.DebugWriteLog(builder); return(OptionResult.SuccessRetain); }
public static int CalculateHouseholdFamilyScore(FutureDescendantService.FutureDescendantHouseholdInfo ths, Common.StringBuilder results) { results.Append(Common.NewLine + "CalculateHouseholdFamilyScore"); int householdSizeTraitScore = 0x0; foreach (ulong num2 in ths.mProgenitorSimIds) { IMiniSimDescription iMiniSimDescription = SimDescription.GetIMiniSimDescription(num2); if (iMiniSimDescription == null) { continue; } results.Append(Common.NewLine + " Progenitor: " + iMiniSimDescription.FullName); MiniSimDescription miniSim = iMiniSimDescription as MiniSimDescription; SimDescription fullSim = iMiniSimDescription as SimDescription; if (fullSim != null) { foreach (Trait trait in fullSim.TraitManager.List) { results.Append(Common.NewLine + " " + trait.TraitName(fullSim.IsFemale) + " : " + trait.DescendantFamilySizeModifier); householdSizeTraitScore += trait.DescendantFamilySizeModifier; } } else if (miniSim != null) { foreach (TraitNames names in miniSim.Traits) { Trait traitFromDictionary = TraitManager.GetTraitFromDictionary(names); results.Append(Common.NewLine + " " + traitFromDictionary.TraitName(miniSim.IsFemale) + " : " + traitFromDictionary.DescendantFamilySizeModifier); householdSizeTraitScore += traitFromDictionary.DescendantFamilySizeModifier; } } } results.Append(Common.NewLine + " Score : " + householdSizeTraitScore); int result = FutureDescendantService.CalculateDesiredHouseholdSize(householdSizeTraitScore); results.Append(Common.NewLine + " Result : " + result); return(result); }
public void Dispose(bool postLoad, bool isReset) { try { if (mWasFutureSim) { mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim); } if (mSim.CreatedSim != null) { BuffManager buffManager = mSim.CreatedSim.BuffManager; if ((buffManager != null) && (mBuffs != null)) { foreach (BuffInstance buff in mBuffs) { buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false); } } if ((mInventory != null) && (mSim.CreatedSim.Inventory != null)) { Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true); } if (mDreamStore != null) { mDreamStore.Restore(mSim.CreatedSim); } if (mSafeStore != null) { mSafeStore.Dispose(); } if (mSim.DeathStyle != SimDescription.DeathType.None) { Urnstone stone = Urnstones.FindGhostsGrave(mSim); if (stone != null) { stone.GhostSetup(mSim.CreatedSim, true); } } mSim.CreatedSim.ReservedVehicle = mReservedVehicle; } } catch (Exception e) { Common.Exception(mSim, null, "Inventory", e); } // Must be after the opportunities are restored if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null)) { OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged; } try { if (!postLoad) { if ((mSim.CreatedSim != null) && (mSim.CreatedSim.OpportunityManager != null) && (mSim.CreatedSim.OpportunityManager.Count > 0)) { OpportunityTrackerModel.FireOpportunitiesChanged(); } } } catch (Exception e) { Common.Exception(mSim, null, "FireOpportunitiesChanged", e); } EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false; mSim.mGenealogy = mGenealogy; if (mDoll != null) { mDoll.mOwner = mSim; if (SimTypes.IsSelectable(mSim)) { try { mDoll.OnOwnerBecameSelectable(); } catch (Exception e) { Common.Exception(mSim, e); SimDescription sim = mDoll.GetLiveFormSimDescription(); if (sim != null) { new FixInvisibleTask(sim).AddToSimulator(); } } } } if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null)) { if (mAcademicPerformance != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance); if (motive != null) { motive.Value = mAcademicPerformance; } } if (mUniversityStudy != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy); if (motive != null) { motive.Value = mUniversityStudy; } } } Relationships.RestoreRelations(mSim, mRelations); if ((mSim.TraitChipManager != null) && (mChips != null)) { for (int i = 0; i < mChips.Length; i++) { if (mChips[i] == null) continue; Common.StringBuilder name = new Common.StringBuilder(); try { name.Append(mChips[i].GetLocalizedName()); mSim.TraitChipManager.AddTraitChip(mChips[i], i); } catch (Exception e) { Common.Exception(mSim, null, name, e); } } } sChangingWorldsSuppression.Pop(); if ((mChangedHousehold != null) && (mChangedCallback != null)) { mChangedHousehold.HouseholdSimsChanged = mChangedCallback; } }
public void Dispose(bool postLoad, bool isReset) { try { if (mWasFutureSim) { mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim); } if (mSim.CreatedSim != null) { BuffManager buffManager = mSim.CreatedSim.BuffManager; if ((buffManager != null) && (mBuffs != null)) { foreach (BuffInstance buff in mBuffs) { buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false); } } if ((mInventory != null) && (mSim.CreatedSim.Inventory != null)) { Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true); } if (mDreamStore != null) { mDreamStore.Restore(mSim.CreatedSim); } if (mSafeStore != null) { mSafeStore.Dispose(); } if (mSim.DeathStyle != SimDescription.DeathType.None) { Urnstone stone = Urnstones.FindGhostsGrave(mSim); if (stone != null) { stone.GhostSetup(mSim.CreatedSim, true); } } mSim.CreatedSim.ReservedVehicle = mReservedVehicle; } } catch (Exception e) { Common.Exception(mSim, null, "Inventory", e); } // Must be after the opportunities are restored if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null)) { OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged; } try { if (!postLoad) { if ((mSim.CreatedSim != null) && (mSim.CreatedSim.OpportunityManager != null) && (mSim.CreatedSim.OpportunityManager.Count > 0)) { OpportunityTrackerModel.FireOpportunitiesChanged(); } } } catch (Exception e) { Common.Exception(mSim, null, "FireOpportunitiesChanged", e); } EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false; mSim.mGenealogy = mGenealogy; if (mDoll != null) { mDoll.mOwner = mSim; if (SimTypes.IsSelectable(mSim)) { try { mDoll.OnOwnerBecameSelectable(); } catch (Exception e) { Common.Exception(mSim, e); SimDescription sim = mDoll.GetLiveFormSimDescription(); if (sim != null) { new FixInvisibleTask(sim).AddToSimulator(); } } } } if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null)) { if (mAcademicPerformance != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance); if (motive != null) { motive.Value = mAcademicPerformance; } } if (mUniversityStudy != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy); if (motive != null) { motive.Value = mUniversityStudy; } } } Relationships.RestoreRelations(mSim, mRelations); if ((mSim.TraitChipManager != null) && (mChips != null)) { for (int i = 0; i < mChips.Length; i++) { if (mChips[i] == null) { continue; } Common.StringBuilder name = new Common.StringBuilder(); try { name.Append(mChips[i].GetLocalizedName()); mSim.TraitChipManager.AddTraitChip(mChips[i], i); } catch (Exception e) { Common.Exception(mSim, null, name, e); } } } sChangingWorldsSuppression.Pop(); if ((mChangedHousehold != null) && (mChangedCallback != null)) { mChangedHousehold.HouseholdSimsChanged = mChangedCallback; } }
public void OnPerform(RouteEvent e) { Common.StringBuilder msg = new Common.StringBuilder(); msg.Append("Data: " + e.Data); msg.Append(Common.NewLine + "Data2: " + e.Data2); msg.Append(Common.NewLine + "DistanceRemaining: " + e.DistanceRemaining); msg.Append(Common.NewLine + "DistanceTravelled: " + e.DistanceTravelled); msg.Append(Common.NewLine + "EventDirection: " + e.EventDirection); msg.Append(Common.NewLine + "EventPosition: " + e.EventPosition); msg.Append(Common.NewLine + "EventSource: " + e.EventSource); msg.Append(Common.NewLine + "EventType: " + e.EventType); msg.Append(Common.NewLine + "ObjectID: " + e.ObjectID); GameObject obj = GameObject.GetObject <GameObject>(e.ObjectID); if (obj != null) { msg.Append(Common.NewLine + "Object Type: " + obj.GetType()); } Route route = mSim.RoutingComponent.GetCurrentRoute(); if (route != null) { msg.Append(Common.NewLine + "NumPaths: " + route.GetNumPaths()); for (uint i = 0x0; i < route.GetNumPaths(); i++) { PathData pathData = route.GetPathData(i); msg.Append(Common.NewLine + "PathType: " + pathData.PathType); msg.Append(Common.NewLine + "PortalStartPos: " + pathData.PortalStartPos); msg.Append(Common.NewLine + "ObjectId: " + pathData.ObjectId); obj = GameObject.GetObject <GameObject>(pathData.ObjectId); if (obj != null) { msg.Append(Common.NewLine + "Object Type: " + obj.GetType()); } } } Common.DebugStackLog(msg); }
public static bool DoRoute(RoutingComponent ths, Route r) { Sim owner = ths.Owner as Sim; if ((!r.ExecutionFromNonSimTaskIsSafe && (owner != null)) && (Simulator.CurrentTask != ths.Owner.ObjectId)) { Simulator.CurrentTask.ObjectFromId <GameObject>(); return(false); } IBoat boat = ths.Owner as IBoat; if (ths.RoutingParent != null) { if (!(ths.RoutingParent is IBoat) || (r.GetOption2(Route.RouteOption2.EndAsBoat) && (!r.PlanResult.Succeeded() || !RoutingComponent.PlannedRouteHasNonBoatSubpath(r)))) { // Custom if (ths.RoutingParent.RoutingComponent is CarRoutingComponent) { return(CarRoutingComponentEx.DoRoute(ths.RoutingParent.RoutingComponent as CarRoutingComponent, r)); } else { return(ths.RoutingParent.RoutingComponent.DoRoute(r)); } } } else if (((boat != null) && r.PlanResult.Succeeded()) && (!r.GetOption2(Route.RouteOption2.EndAsBoat) || RoutingComponent.PlannedRouteHasNonBoatSubpath(r))) { Sim driver = boat.GetDriver(); if (driver != null) { return(driver.RoutingComponent.DoRoute(r)); } } Common.StringBuilder msg = new Common.StringBuilder("RoutingComponentEx:DoRoute" + Common.NewLine); if (owner != null) { msg += Common.NewLine + owner.FullName + Common.NewLine; } ths.mRouteActions.Clear(); bool routeSuccess = true; try { RouteAction.FailureExplanation explanation = RouteAction.FailureExplanation.None; RoutingComponent.mnNumDoRouteCalls += (ulong)0x1L; if (r.PlanResult.Succeeded()) { ths.OnAboutToStartFollowingRoute(r); if (r.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, r); if (owner != null) { owner.PushBackpackPostureIfNecessary(); owner.PushCanePostureIfNecessary(); owner.PushJetpackPostureIfNecessary(); } } else { routeSuccess = false; } } else { routeSuccess = false; } msg.Append("A"); if (!routeSuccess) { explanation |= RouteAction.FailureExplanation.InitialPlanFailure; LogFailure(ths.Owner, RouteAction.FailureExplanation.InitialPlanFailure, r.PlanResult, "Initial Path Plan Failure (WILL NOT play route fail)"); r.SetRouteActionResult(0x2); return(false); } msg.Append("B"); int failures = 0; if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, false); } else { ths.UpdateDynamicFootprint(ths.Owner, false); } Vector3 originalPosition = ths.Owner.Position; int loops = 0; bool success = true; Route processedPath = r; bool isOutside = ths.Owner.IsOutside; ths.mNumWaterEntriesThisRoute = 0; while (ths.mRouteActions.Count != 0x0) { // Custom if (ths.Owner.Position == originalPosition) { loops++; } if ((loops > 30) || (ths.mRouteActions.Count > 30)) { success = false; ths.mRouteActions.Clear(); break; } if (ths.mRouteActions[0] is GetInBoatRouteAction) { ths.mNumWaterEntriesThisRoute++; if (ths.mNumWaterEntriesThisRoute > 10) { if (owner != null) { owner.SetToResetAndSendHome(); } else { ths.Owner.SetObjectToReset(); } return(false); } } if ((owner != null) && owner.IsOutside) { owner.PushHoverboardPostureIfNecessary(); } // Custom RouteAction routeAction = ths.mRouteActions[0x0]; msg.Append(Common.NewLine + routeAction.GetType()); RouteAction.ActionResult actionResult = RouteAction.ActionResult.Continue; //using (BuffsChangedProxy buffsProxy = new BuffsChangedProxy(owner)) { try { if (routeAction is ObstacleEncounteredRouteInterruptAction) { actionResult = ObstacleEncounteredRouteInterruptActionEx.PerformAction(routeAction as ObstacleEncounteredRouteInterruptAction); } else { actionResult = routeAction.PerformAction(); } } catch (ResetException) { throw; } catch (SacsErrorException e) { Common.DebugException(owner, null, msg, e); failures++; if (failures > 10) { actionResult = RouteAction.ActionResult.Terminate; } else { actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan; } routeAction.OnReset(); } catch (Exception e) { Common.Exception(owner, null, msg.ToString(), e); string stackTrace = e.StackTrace.ToString(); if (stackTrace.Contains("OccultManager:DisallowClothesChange")) { OccultTypeHelper.ValidateOccult(owner.SimDescription, null); actionResult = RouteAction.ActionResult.Terminate; } else if (stackTrace.Contains("CommonDoor:IsAllowedThrough")) { Corrections.CleanupCommonDoors(null); actionResult = RouteAction.ActionResult.Terminate; } else if (stackTrace.Contains("SimRoutingComponent:RequestWalkStyle")) { actionResult = RouteAction.ActionResult.Terminate; } else { failures++; if (failures > 10) { actionResult = RouteAction.ActionResult.Terminate; } else { actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan; } } routeAction.OnReset(); } } msg.Append(Common.NewLine + "C"); // Custom if ((ths.mRouteActions.Count > 0) && (ths.mRouteActions[0x0].ForciblyReplanned) && (actionResult == RouteAction.ActionResult.ContinueAndPopPath)) { actionResult = RouteAction.ActionResult.ContinueAndFollowPath; } msg.Append(Common.NewLine + actionResult + Common.NewLine); if (GoHere.Settings.mDetailedRouting) { if (Sim.ActiveActor == owner) { Common.DebugNotify(msg); } } if (ths.mRouteActions.Count == 0x0) { explanation |= RouteAction.FailureExplanation.InternalPlanFailure; success = false; break; } msg.Append("D"); ths.mPreviousRouteAction = ths.mRouteActions[0x0]; switch (actionResult) { case RouteAction.ActionResult.Continue: case RouteAction.ActionResult.ContinueAndPopPath: case RouteAction.ActionResult.ContinueAndPopPathAndReplan: case RouteAction.ActionResult.ContinueAndPopPathAndRestart: case RouteAction.ActionResult.ContinueAndFollowPath: msg.Append("E"); ths.mRouteActions.RemoveAt(0x0); bool flag3 = (processedPath.GetNumPaths() > 0x1) || (processedPath.IsLoop()); if (((actionResult == RouteAction.ActionResult.ContinueAndPopPath) && flag3) || ((actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart) || (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan))) { if (flag3) { processedPath.PopPath(); } msg.Append("F"); if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan) { Vector3 outPosition = new Vector3(); if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { outPosition = ths.RoutingParent.PositionOnFloor; } else if (ths.Owner != null) { if ((owner != null) && (owner.Posture is SwimmingInPool)) { outPosition = ths.Owner.Position; } else { outPosition = ths.Owner.PositionOnFloor; } } else { processedPath.GetPathStartPoint(0x0, ref outPosition); } processedPath.ReplanFromPoint(outPosition); } msg.Append("G"); if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart) { Vector3 positionOnFloor = new Vector3(); if (ths.Owner != null) { positionOnFloor = ths.Owner.PositionOnFloor; } else { processedPath.GetPathStartPoint(0x0, ref positionOnFloor); } processedPath.SetOption(Route.RouteOption.EnablePlanningAsCar, false); processedPath.SetOption(Route.RouteOption.EnableSubwayPlanning, false); processedPath.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); processedPath.ReplanFromPoint(positionOnFloor); explanation |= RouteAction.FailureExplanation.CancelledByScript; success = false; ths.mRouteActions.Clear(); } else if (processedPath.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, processedPath); } else { explanation |= RouteAction.FailureExplanation.ReplanFailure; success = false; ths.mRouteActions.Clear(); } } else if ((actionResult == RouteAction.ActionResult.ContinueAndFollowPath) && (r.GetNumPaths() > 0x0)) { msg.Append("H"); if (r.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, processedPath); } else { explanation |= RouteAction.FailureExplanation.InternalPlanFailure; success = false; ths.mRouteActions.Clear(); } } break; default: msg.Append("I"); explanation |= ths.mPreviousRouteAction.FailureExplanations; success = false; ths.mRouteActions.Clear(); break; } } msg.Append("J"); ths.mRouteActions.Clear(); r.SetRouteActionResult((uint)explanation); if (!success) { if (ths.mPreviousRouteAction == null) { LogFailure(ths.Owner, explanation, r.PlanResult, "(Null mPreviousRouteAction failure)"); } else { LogFailure(ths.Owner, explanation, r.PlanResult, "(failure in " + ths.mPreviousRouteAction.ToString() + ")"); } } msg.Append("K"); if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, true); } else { ths.UpdateDynamicFootprint(ths.Owner, true); } routeSuccess = (success && (processedPath == r)) && r.PlanResult.Succeeded(); ths.mPreviousRouteAction = null; if (ths.OnRouteActionsFinished != null) { ths.OnRouteActionsFinished(ths.Owner, routeSuccess); } if (((SeasonsManager.Enabled && routeSuccess) && (isOutside && (owner != null))) && ((owner.IsHuman && owner.SimDescription.ChildOrAbove) && (!owner.IsOutside && (owner.CurrentOutfitCategory == OutfitCategories.Outerwear)))) { owner.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.RemovingOuterwear); } if (owner != null) { SwimmingInPool posture = owner.Posture as SwimmingInPool; if ((posture != null) && posture.UsedShortEntryAnimation) { posture.UsedShortEntryAnimation = false; if (owner.SimDescription.IsMatureMermaid) { OccultMermaid.PutOnTailWithSpin(owner.SimDescription); } } } } catch (ResetException) { routeSuccess = false; if (ths.mRouteActions.Count > 0x0) { RouteAction action = ths.mRouteActions[0x0]; if (action != null) { action.OnReset(); } } ths.mRouteActions.Clear(); throw; } catch (Exception e) { Common.Exception(owner, null, msg.ToString(), e); routeSuccess = false; if (ths.mRouteActions.Count > 0x0) { RouteAction action = ths.mRouteActions[0x0]; if (action != null) { action.OnReset(); } } ths.mRouteActions.Clear(); } finally { ths.mRouteActions.Clear(); if (owner != null) { owner.RestoreUsedHoverboard(); } if ((owner != null) && (owner.FirstName == "Roberto")) { Common.DebugStackLog(msg); } } return(routeSuccess); }
private static void Reroute(Route r, AncientPortal closest, AncientPortal destination) { Sim target = r.Follower.Target as Sim; Vector3 currentStartPoint = r.GetCurrentStartPoint(); float distanceRemaining = r.GetDistanceRemaining(); Common.StringBuilder msg = new Common.StringBuilder(); msg.Append("AncientPortal Reroute: " + target.FullName); Route routeToPortal = target.CreateRoute(); routeToPortal.SetOption(Route.RouteOption.EnableSubwayPlanning, false); routeToPortal.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); routeToPortal.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar)); routeToPortal.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller)); routeToPortal.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller)); routeToPortal.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller)); Vector3 slotPosition = closest.GetSlotPosition(closest.GetRoutingSlots()[0]); Vector3 slotFoward = closest.GetForwardOfSlot(closest.GetRoutingSlots()[0]); Vector3 farPosition = new Vector3(slotPosition); farPosition.x -= slotFoward.x / 4f; farPosition.y -= slotFoward.y / 4f; RoutePlanResult result = routeToPortal.PlanToPoint(farPosition); msg.Append(Common.NewLine + "Result: " + result); if (result.Succeeded()) { msg.Append(Common.NewLine + "D" + Common.NewLine + Routes.RouteToString(routeToPortal)); Route portalRoute = target.CreateRoute(); portalRoute.SetOption(Route.RouteOption.EnableSubwayPlanning, false); portalRoute.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); portalRoute.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar)); portalRoute.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller)); portalRoute.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller)); portalRoute.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller)); result = portalRoute.PlanToPointFromPoint(slotPosition, farPosition); msg.Append(Common.NewLine + "Result: " + result); if (result.Succeeded()) { PathData portalData = new PathData(); portalData.PathType = PathType.PortalPath; portalData.ObjectId = closest.ObjectId; portalData.PortalStartPos = slotPosition; portalRoute.SetPathData(ref portalData); msg.Append(Common.NewLine + "A" + Common.NewLine + Routes.RouteToString(portalRoute)); slotPosition = destination.GetSlotPosition(destination.GetRoutingSlots()[0]); r.SetOption(Route.RouteOption.EnableSubwayPlanning, false); if (!r.ReplanFromPoint(slotPosition).Succeeded()) { r.ReplanFromPoint(currentStartPoint); } else if ((routeToPortal.GetDistanceRemaining() + r.GetDistanceRemaining()) < (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway)) { AncientPortalComponent.AddTargetPortal(target, destination); msg.Append(Common.NewLine + "B" + Common.NewLine + Routes.RouteToString(r)); r.InsertRouteSubPathsAtIndex(0x0, portalRoute); r.InsertRouteSubPathsAtIndex(0x0, routeToPortal); msg.Append(Common.NewLine + "C" + Common.NewLine + Routes.RouteToString(r)); r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } else { r.ReplanFromPoint(currentStartPoint); } } } Common.DebugNotify(msg, target); Common.DebugWriteLog(msg); }
public void OnPerform(RouteEvent e) { Common.StringBuilder msg = new Common.StringBuilder(); msg.Append("Data: " + e.Data); msg.Append(Common.NewLine + "Data2: " + e.Data2); msg.Append(Common.NewLine + "DistanceRemaining: " + e.DistanceRemaining); msg.Append(Common.NewLine + "DistanceTravelled: " + e.DistanceTravelled); msg.Append(Common.NewLine + "EventDirection: " + e.EventDirection); msg.Append(Common.NewLine + "EventPosition: " + e.EventPosition); msg.Append(Common.NewLine + "EventSource: " + e.EventSource); msg.Append(Common.NewLine + "EventType: " + e.EventType); msg.Append(Common.NewLine + "ObjectID: " + e.ObjectID); GameObject obj = GameObject.GetObject<GameObject>(e.ObjectID); if (obj != null) { msg.Append(Common.NewLine + "Object Type: " + obj.GetType()); } Route route = mSim.RoutingComponent.GetCurrentRoute(); if (route != null) { msg.Append(Common.NewLine + "NumPaths: " + route.GetNumPaths()); for (uint i = 0x0; i < route.GetNumPaths(); i++) { PathData pathData = route.GetPathData(i); msg.Append(Common.NewLine + "PathType: " + pathData.PathType); msg.Append(Common.NewLine + "PortalStartPos: " + pathData.PortalStartPos); msg.Append(Common.NewLine + "ObjectId: " + pathData.ObjectId); obj = GameObject.GetObject<GameObject>(pathData.ObjectId); if (obj != null) { msg.Append(Common.NewLine + "Object Type: " + obj.GetType()); } } } Common.DebugStackLog(msg); }
public static bool DoRoute(RoutingComponent ths, Route r) { Sim owner = ths.Owner as Sim; if ((!r.ExecutionFromNonSimTaskIsSafe && (owner != null)) && (Simulator.CurrentTask != ths.Owner.ObjectId)) { Simulator.CurrentTask.ObjectFromId<GameObject>(); return false; } IBoat boat = ths.Owner as IBoat; if (ths.RoutingParent != null) { if (!(ths.RoutingParent is IBoat) || (r.GetOption2(Route.RouteOption2.EndAsBoat) && (!r.PlanResult.Succeeded() || !RoutingComponent.PlannedRouteHasNonBoatSubpath(r)))) { // Custom if (ths.RoutingParent.RoutingComponent is CarRoutingComponent) { return CarRoutingComponentEx.DoRoute(ths.RoutingParent.RoutingComponent as CarRoutingComponent, r); } else { return ths.RoutingParent.RoutingComponent.DoRoute(r); } } } else if (((boat != null) && r.PlanResult.Succeeded()) && (!r.GetOption2(Route.RouteOption2.EndAsBoat) || RoutingComponent.PlannedRouteHasNonBoatSubpath(r))) { Sim driver = boat.GetDriver(); if (driver != null) { return driver.RoutingComponent.DoRoute(r); } } Common.StringBuilder msg = new Common.StringBuilder("RoutingComponentEx:DoRoute" + Common.NewLine); if (owner != null) { msg += Common.NewLine + owner.FullName + Common.NewLine; } ths.mRouteActions.Clear(); bool routeSuccess = true; try { RouteAction.FailureExplanation explanation = RouteAction.FailureExplanation.None; RoutingComponent.mnNumDoRouteCalls += (ulong)0x1L; if (r.PlanResult.Succeeded()) { ths.OnAboutToStartFollowingRoute(r); if (r.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, r); if (owner != null) { owner.PushBackpackPostureIfNecessary(); owner.PushCanePostureIfNecessary(); owner.PushJetpackPostureIfNecessary(); } } else { routeSuccess = false; } } else { routeSuccess = false; } msg.Append("A"); if (!routeSuccess) { explanation |= RouteAction.FailureExplanation.InitialPlanFailure; LogFailure(ths.Owner, RouteAction.FailureExplanation.InitialPlanFailure, r.PlanResult, "Initial Path Plan Failure (WILL NOT play route fail)"); r.SetRouteActionResult(0x2); return false; } msg.Append("B"); int failures = 0; if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, false); } else { ths.UpdateDynamicFootprint(ths.Owner, false); } Vector3 originalPosition = ths.Owner.Position; int loops = 0; bool success = true; Route processedPath = r; bool isOutside = ths.Owner.IsOutside; ths.mNumWaterEntriesThisRoute = 0; while (ths.mRouteActions.Count != 0x0) { // Custom if (ths.Owner.Position == originalPosition) { loops++; } if ((loops > 30) || (ths.mRouteActions.Count > 30)) { success = false; ths.mRouteActions.Clear(); break; } if (ths.mRouteActions[0] is GetInBoatRouteAction) { ths.mNumWaterEntriesThisRoute++; if (ths.mNumWaterEntriesThisRoute > 10) { if (owner != null) { owner.SetToResetAndSendHome(); } else { ths.Owner.SetObjectToReset(); } return false; } } if ((owner != null) && owner.IsOutside) { owner.PushHoverboardPostureIfNecessary(); } // Custom RouteAction routeAction = ths.mRouteActions[0x0]; msg.Append(Common.NewLine + routeAction.GetType()); RouteAction.ActionResult actionResult = RouteAction.ActionResult.Continue; //using (BuffsChangedProxy buffsProxy = new BuffsChangedProxy(owner)) { try { if (routeAction is ObstacleEncounteredRouteInterruptAction) { actionResult = ObstacleEncounteredRouteInterruptActionEx.PerformAction(routeAction as ObstacleEncounteredRouteInterruptAction); } else { actionResult = routeAction.PerformAction(); } } catch (ResetException) { throw; } catch (SacsErrorException e) { Common.DebugException(owner, null, msg, e); failures++; if (failures > 10) { actionResult = RouteAction.ActionResult.Terminate; } else { actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan; } routeAction.OnReset(); } catch (Exception e) { Common.Exception(owner, null, msg.ToString(), e); string stackTrace = e.StackTrace.ToString(); if (stackTrace.Contains("OccultManager:DisallowClothesChange")) { OccultTypeHelper.ValidateOccult(owner.SimDescription, null); actionResult = RouteAction.ActionResult.Terminate; } else if (stackTrace.Contains("CommonDoor:IsAllowedThrough")) { Corrections.CleanupCommonDoors(null); actionResult = RouteAction.ActionResult.Terminate; } else if (stackTrace.Contains("SimRoutingComponent:RequestWalkStyle")) { actionResult = RouteAction.ActionResult.Terminate; } else { failures++; if (failures > 10) { actionResult = RouteAction.ActionResult.Terminate; } else { actionResult = RouteAction.ActionResult.ContinueAndPopPathAndReplan; } } routeAction.OnReset(); } } msg.Append(Common.NewLine + "C"); // Custom if ((ths.mRouteActions.Count > 0) && (ths.mRouteActions[0x0].ForciblyReplanned) && (actionResult == RouteAction.ActionResult.ContinueAndPopPath)) { actionResult = RouteAction.ActionResult.ContinueAndFollowPath; } msg.Append(Common.NewLine + actionResult + Common.NewLine); if (GoHere.Settings.mDetailedRouting) { if (Sim.ActiveActor == owner) { Common.DebugNotify(msg); } } if (ths.mRouteActions.Count == 0x0) { explanation |= RouteAction.FailureExplanation.InternalPlanFailure; success = false; break; } msg.Append("D"); ths.mPreviousRouteAction = ths.mRouteActions[0x0]; switch(actionResult) { case RouteAction.ActionResult.Continue: case RouteAction.ActionResult.ContinueAndPopPath: case RouteAction.ActionResult.ContinueAndPopPathAndReplan: case RouteAction.ActionResult.ContinueAndPopPathAndRestart: case RouteAction.ActionResult.ContinueAndFollowPath: msg.Append("E"); ths.mRouteActions.RemoveAt(0x0); bool flag3 = (processedPath.GetNumPaths() > 0x1) || (processedPath.IsLoop()); if (((actionResult == RouteAction.ActionResult.ContinueAndPopPath) && flag3) || ((actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart) || (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan))) { if (flag3) { processedPath.PopPath(); } msg.Append("F"); if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndReplan) { Vector3 outPosition = new Vector3(); if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { outPosition = ths.RoutingParent.PositionOnFloor; } else if (ths.Owner != null) { if ((owner != null) && (owner.Posture is SwimmingInPool)) { outPosition = ths.Owner.Position; } else { outPosition = ths.Owner.PositionOnFloor; } } else { processedPath.GetPathStartPoint(0x0, ref outPosition); } processedPath.ReplanFromPoint(outPosition); } msg.Append("G"); if (actionResult == RouteAction.ActionResult.ContinueAndPopPathAndRestart) { Vector3 positionOnFloor = new Vector3(); if (ths.Owner != null) { positionOnFloor = ths.Owner.PositionOnFloor; } else { processedPath.GetPathStartPoint(0x0, ref positionOnFloor); } processedPath.SetOption(Route.RouteOption.EnablePlanningAsCar, false); processedPath.SetOption(Route.RouteOption.EnableSubwayPlanning, false); processedPath.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); processedPath.ReplanFromPoint(positionOnFloor); explanation |= RouteAction.FailureExplanation.CancelledByScript; success = false; ths.mRouteActions.Clear(); } else if (processedPath.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, processedPath); } else { explanation |= RouteAction.FailureExplanation.ReplanFailure; success = false; ths.mRouteActions.Clear(); } } else if ((actionResult == RouteAction.ActionResult.ContinueAndFollowPath) && (r.GetNumPaths() > 0x0)) { msg.Append("H"); if (r.PlanResult.Succeeded()) { ths.PushActionsForRoute(r, processedPath); } else { explanation |= RouteAction.FailureExplanation.InternalPlanFailure; success = false; ths.mRouteActions.Clear(); } } break; default: msg.Append("I"); explanation |= ths.mPreviousRouteAction.FailureExplanations; success = false; ths.mRouteActions.Clear(); break; } } msg.Append("J"); ths.mRouteActions.Clear(); r.SetRouteActionResult((uint)explanation); if (!success) { if (ths.mPreviousRouteAction == null) { LogFailure(ths.Owner, explanation, r.PlanResult, "(Null mPreviousRouteAction failure)"); } else { LogFailure(ths.Owner, explanation, r.PlanResult, "(failure in " + ths.mPreviousRouteAction.ToString() + ")"); } } msg.Append("K"); if ((ths.RoutingParent != null) && (ths.RoutingParent is IBoat)) { ths.UpdateDynamicFootprint(ths.RoutingParent as GameObject, true); } else { ths.UpdateDynamicFootprint(ths.Owner, true); } routeSuccess = (success && (processedPath == r)) && r.PlanResult.Succeeded(); ths.mPreviousRouteAction = null; if (ths.OnRouteActionsFinished != null) { ths.OnRouteActionsFinished(ths.Owner, routeSuccess); } if (((SeasonsManager.Enabled && routeSuccess) && (isOutside && (owner != null))) && ((owner.IsHuman && owner.SimDescription.ChildOrAbove) && (!owner.IsOutside && (owner.CurrentOutfitCategory == OutfitCategories.Outerwear)))) { owner.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.RemovingOuterwear); } if (owner != null) { SwimmingInPool posture = owner.Posture as SwimmingInPool; if ((posture != null) && posture.UsedShortEntryAnimation) { posture.UsedShortEntryAnimation = false; if (owner.SimDescription.IsMatureMermaid) { OccultMermaid.PutOnTailWithSpin(owner.SimDescription); } } } } catch (ResetException) { routeSuccess = false; if (ths.mRouteActions.Count > 0x0) { RouteAction action = ths.mRouteActions[0x0]; if (action != null) { action.OnReset(); } } ths.mRouteActions.Clear(); throw; } catch (Exception e) { Common.Exception(owner, null, msg.ToString(), e); routeSuccess = false; if (ths.mRouteActions.Count > 0x0) { RouteAction action = ths.mRouteActions[0x0]; if (action != null) { action.OnReset(); } } ths.mRouteActions.Clear(); } finally { ths.mRouteActions.Clear(); if (owner != null) { owner.RestoreUsedHoverboard(); } if ((owner != null) && (owner.FirstName == "Roberto")) { Common.DebugStackLog(msg); } } return routeSuccess; }