public override bool Run() { try { string str; mTimeTravelDef = InteractionDefinition as Definition; if (!Target.RouteToMachine(Actor, false, null)) { return(false); } if (!TimePortalTravelEx.PreTimeTravel1(this)) { return(false); } if (!TimePortalTravelEx.PreTimeTravel2(this)) { return(false); } Actor.SimDescription.Contactable = false; EnterStateMachine("TimeMachine", "Enter", "x"); SetActor("timeMachine", Target); SetParameter("isFuture", mTimeTravelDef.TimePeriod == TimeMachine.TravelTimePeriod.Future); AddOneShotScriptEventHandler(0x3ee, OnEnterAnimationEvent); AddOneShotScriptEventHandler(0x66, ToggleHiddenAnimationEvent); AnimateSim("GetIn"); Target.EnableRoutingFootprint(Actor); mTimeTravelAlarm = AlarmManager.Global.AddAlarmRepeating(RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, new AlarmTimerCallback(TimeTravelCallback), RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, "Time Travel Alarm For:" + Actor.SimDescription.FullName, AlarmType.AlwaysPersisted, Actor); Target.SetMaterial("InUse"); bool succeeded = true; if (!GameUtils.IsFutureWorld()) { // Custom succeeded = TimePortalEx.TravelToFuture(null, Actor, new List <Sim>(), new List <ulong>()); } succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); EndCommodityUpdates(succeeded); Target.PickExitStateAndSound(mTimeTravelDef.TimePeriod, out str, out mExitSound); AddOneShotScriptEventHandler(0x3e9, OnExitAnimationEvent); AddOneShotScriptEventHandler(0x3ef, OnExitAnimationEvent); AddOneShotScriptEventHandler(0x67, ToggleHiddenAnimationEvent); AnimateSim(str); if (!TimePortalTravelEx.PostTimeTravel1(this, succeeded)) { return(false); } Target.SetMaterial("default"); AnimateSim("Exit"); if (!string.IsNullOrEmpty(mTravelSummary)) { Actor.ShowTNSIfSelectable(mTravelSummary, StyledNotification.NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId); } StandardExit(); Target.Repairable.UpdateBreakage(Actor); InventingSkill skill = Actor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing); if (succeeded && (skill != null)) { skill.RegisterTimeTravelDone(); } if (GameUtils.IsFutureWorld()) { EventTracker.SendEvent(EventTypeId.kTravelToPresent, Actor); // Custom GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld(); } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } finally { TravelUtil.PlayerMadeTravelRequest = false; } }
public override bool Run() { try { bool succeeded = true; Target.mRoutingSims.Add(Actor); if (!Target.RouteToPortal(Actor)) { Actor.AddExitReason(ExitReason.RouteFailed); Target.mRoutingSims.Remove(Actor); return(false); } Target.mRoutingSims.Remove(Actor); if (!TimePortalTravelEx.PreTimeTravel1(this)) { return(false); } mTargetPortal = Target; mTargetPortal.AddToUseList(Actor); if (!TimePortalTravelEx.PreTimeTravel2(this)) { return(false); } mTargetPortal.EnableFootprint(FootprintPlacementHash); mTargetPortal.PushSimsFromFootprint(FootprintPlacementHash, Actor, null, false); EnterStateMachine("AncientPortal", "Enter", "x", "portal"); AddOneShotScriptEventHandler(0x65, HideSim); AddOneShotScriptEventHandler(0x66, ShowSim); AnimateSim("InsidePortal"); SetActor("portal", mTargetPortal); if (!GameUtils.IsFutureWorld()) { // Custom succeeded = TimePortalEx.TravelToFuture(null, Actor, new List <Sim>(), new List <ulong>()); } Slot slotName = mTargetPortal.GetRoutingSlots()[0x0]; Vector3 positionOfSlot = mTargetPortal.GetPositionOfSlot(slotName); Vector3 forwardOfSlot = mTargetPortal.GetForwardOfSlot(slotName); Actor.SetPosition(positionOfSlot); Actor.SetForward(forwardOfSlot); mTargetPortal.DisableFootprint(FootprintPlacementHash); if (!TimePortalTravelEx.PostTimeTravel1(this, succeeded)) { return(false); } AnimateSim("Exit"); for (int i = 0x0; i < kPotentialTravelBuffs.Length; i++) { if (RandomUtil.RandomChance(kChanceForEachBuff)) { Actor.BuffManager.AddElement(kPotentialTravelBuffs[i], Origin.FromAncientPortal); } } EndCommodityUpdates(succeeded); StandardExit(); mTargetPortal.RemoveFromUseList(Actor); Actor.Wander(1f, 2f, false, RouteDistancePreference.PreferNearestToRouteOrigin, false); if (GameUtils.IsFutureWorld()) { EventTracker.SendEvent(EventTypeId.kTravelToPresent, Actor); // Custom GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld(); } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } finally { TravelUtil.PlayerMadeTravelRequest = false; } }