Esempio n. 1
0
        public override void OnReset()
        {
            try
            {
                if (mSMC != null)
                {
                    mSMC.Dispose();
                    mSMC = null;
                }

                if (mPortal != null)
                {
                    if (mCurrentlyRoutingSim != null)
                    {
                        mPortal.RemoveFromUseList(mCurrentlyRoutingSim);
                    }
                }

                if ((mCurrentlyRoutingSim != null) && (!mCurrentlyRoutingSim.HasBeenDestroyed))
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);

                    AncientPortal targetPortal = null;
                    if (sTargetPortals.TryGetValue(mCurrentlyRoutingSim, out targetPortal))
                    {
                        targetPortal.RemoveFromUseList(mCurrentlyRoutingSim);

                        targetPortal.DisableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash);
                    }
                }

                mCurrentlyRoutingSim = null;

                base.OnReset();
            }
            catch (Exception e)
            {
                Common.Exception(Owner, e);
            }
        }
Esempio n. 2
0
        public override bool OnPortalStop(Sim sim)
        {
            try
            {
                AncientPortal targetPortal = null;
                if (!sTargetPortals.TryGetValue(sim, out targetPortal))
                {
                    sim.PlayRouteFailure(mPortal);
                    return(false);
                }

                mSMC.SetActor("portal", targetPortal);

                Slot    slotName       = targetPortal.GetRoutingSlots()[0x0];
                Vector3 positionOfSlot = targetPortal.GetPositionOfSlot(slotName);
                Vector3 forwardOfSlot  = targetPortal.GetForwardOfSlot(slotName);
                sim.SetPosition(positionOfSlot);
                sim.SetForward(forwardOfSlot);

                targetPortal.DisableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash);

                mSMC.RequestState("x", "Exit");

                if (SimTypes.IsSelectable(sim))
                {
                    for (int i = 0x0; i < AncientPortal.CatchABeam.kPotentialTravelBuffs.Length; i++)
                    {
                        if (RandomUtil.RandomChance(AncientPortal.CatchABeam.kChanceForEachBuff))
                        {
                            sim.BuffManager.AddElement(AncientPortal.CatchABeam.kPotentialTravelBuffs[i], Origin.FromAncientPortal);
                        }
                    }
                }

                targetPortal.RemoveFromUseList(sim);

                if (targetPortal.LotCurrent.IsResidentialLot && !sim.IsGreetedOnLot(targetPortal.LotCurrent))
                {
                    sim.GreetSimOnLot(targetPortal.LotCurrent);
                }

                if (mSMC != null)
                {
                    mSMC.Dispose();
                    mSMC = null;
                }

                mCurrentlyRoutingSim = null;

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(sim, Owner, e);
                return(false);
            }
            finally
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }
            }
        }