// Use this for initialization
 void Start()
 {
     tScript       = this.GetComponent <Teleporter>();
     cScript       = this.GetComponent <Controller>();
     hScript       = this.GetComponent <Hoverboard>();
     gScript       = this.GetComponent <Grappling>();
     pScript       = this.GetComponent <PlatformMvt>();
     sScript       = this.GetComponent <SwingingArms>();
     zScript       = this.GetComponent <PinchZoom>();
     jScript       = this.GetComponent <JetPack>();
     spScript      = this.GetComponent <SkiPole>();
     eScript       = this.GetComponent <Soar_Earth>();
     TeleMsg       = GameObject.Find("ModeUpdate/Canvas/TeleMsg");
     ControlMsg    = GameObject.Find("ModeUpdate/Canvas/ControlMsg");
     HoverMsg      = GameObject.Find("ModeUpdate/Canvas/HoverMsg");
     GrappleMsg    = GameObject.Find("ModeUpdate/Canvas/GrappleMsg");
     PlatformMsg   = GameObject.Find("ModeUpdate/Canvas/PlatformMsg");
     SwingingMsg   = GameObject.Find("ModeUpdate/Canvas/SwingingMsg");
     PinchMsg      = GameObject.Find("ModeUpdate/Canvas/PinchMsg");
     JetMsg        = GameObject.Find("ModeUpdate/Canvas/JetMsg");
     SkiMsg        = GameObject.Find("ModeUpdate/Canvas/SkiMsg");
     EarthMsg      = GameObject.Find("ModeUpdate/Canvas/EarthMsg");
     TeleInstr     = GameObject.Find("ModeUpdate/Canvas/TeleInstr");
     ControlInstr  = GameObject.Find("ModeUpdate/Canvas/ControlInstr");
     HoverInstr    = GameObject.Find("ModeUpdate/Canvas/HoverInstr");
     GrappleInstr  = GameObject.Find("ModeUpdate/Canvas/GrappleInstr");
     PlatformInstr = GameObject.Find("ModeUpdate/Canvas/PlatformInstr");
     SwingingInstr = GameObject.Find("ModeUpdate/Canvas/SwingingInstr");
     PinchInstr    = GameObject.Find("ModeUpdate/Canvas/PinchInstr");
     JetInstr      = GameObject.Find("ModeUpdate/Canvas/JetInstr");
     SkiInstr      = GameObject.Find("ModeUpdate/Canvas/SkiInstr");
     EarthInstr    = GameObject.Find("ModeUpdate/Canvas/EarthInstr");
     Timer         = GameObject.Find("ModeUpdate/Canvas/Timer");
     Body          = this.GetComponent <Rigidbody>();
 }
Beispiel #2
0
        public static OptionResult Perform(Sims3.Gameplay.Inventory inventory, Item sort)
        {
            if (inventory == null)
            {
                return(OptionResult.Failure);
            }

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

            Dictionary <Type, int> counts = new Dictionary <Type, int>();

            foreach (InventoryStack stack in inventory.mItems.Values)
            {
                foreach (InventoryItem item in stack.List)
                {
                    if (item.mObject == null)
                    {
                        continue;
                    }

                    counts[item.mObject.GetType()] = stack.List.Count;

                    if (!item.mObject.InUse)
                    {
                        item.mInUse = false;
                    }
                }
            }

            List <SortObject> objs = new List <SortObject>();

            foreach (GameObject obj in Inventories.QuickFind <GameObject>(inventory))
            {
                if (obj is Hoverboard)
                {
                    Hoverboard obj2 = obj as Hoverboard;
                    if (obj2 != null)
                    {
                        bool usingHoverboardAlways = obj2.UsingHoverboardAlways;
                        if (inventory.TryToRemove(obj))
                        {
                            objs.Add(new SortObject(obj, counts[obj.GetType()], usingHoverboardAlways));
                        }
                    }
                    continue;
                }

                if (inventory.TryToRemove(obj))
                {
                    objs.Add(new SortObject(obj, counts[obj.GetType()]));
                }
            }

            try
            {
                objs.Sort(sort);
            }
            catch (Exception e)
            {
                Common.Exception(inventory.Owner, e);
            }

            try
            {
                inventory.IgnoreInventoryValidation = true;

                foreach (SortObject obj in objs)
                {
                    if (obj.mObj is Hoverboard)
                    {
                        Hoverboard obj2 = obj.mObj as Hoverboard;
                        if (obj2 != null)
                        {
                            obj2.UsingHoverboardAlways = obj.mUsingHoverboardAlways;

                            if (!Inventories.TryToMove(obj2, inventory))
                            {
                                obj2.Destroy();
                            }
                        }

                        continue;
                    }

                    if (!Inventories.TryToMove(obj.mObj, inventory))
                    {
                        obj.mObj.Destroy();
                    }
                }
            }
            finally
            {
                inventory.IgnoreInventoryValidation = false;
            }

            return(OptionResult.SuccessClose);
        }