Ejemplo n.º 1
0
        public override void ReplaceWith(GameObject newObj)
        {
            GameObject driver     = _driver;
            GameObject controller = _controller;

            if (_driver != null)
            {
                ReplaceUsedObject(_driver, this, newObj);
            }
            if (_controller != null)
            {
                ReplaceUsedObject(_controller, this, newObj);
            }

            // Drop all bipd's from the new vehicle
            GameObject current = newObj.FirstCarried;

            while (current != null)
            {
                GameObject next = current.NextCarried;
                if (current.TagGroup == TagGroup.Bipd)
                {
                    current.Drop();
                }
                current = next;
            }

            // Now move all bipd's from this vehicle to the new one
            current = FirstCarried;
            while (current != null)
            {
                GameObject next = current.NextCarried;
                if (current.TagGroup == TagGroup.Bipd)
                {
                    newObj.PickUp(current);
                }
                current = next;
            }

            base.ReplaceWith(newObj);

            // Adjust pointers
            VehicleObject newVehicle = newObj as VehicleObject;

            if (newVehicle != null)
            {
                newVehicle._driver     = driver;
                newVehicle._controller = controller;
                driver     = null;
                controller = null;
            }
        }
Ejemplo n.º 2
0
        private bool ProcessObjectEntry(SaveIO.SaveReader reader, bool active, uint datumIndex, ushort flags, uint size, long offset)
        {
            if (!active)
            {
                _objects.Add(null);
                return(true);
            }

            // Read the object entry
            ObjectEntry entry = new ObjectEntry(_objectChunk, reader, datumIndex, flags, offset);

            // Seek to the start of the object data
            reader.Seek(_objectPoolStart + entry.PoolOffset, SeekOrigin.Begin);

            // Process it based on object class
            GameObject obj;

            switch (entry.TagGroup)
            {
            case TagGroup.Bipd:
                obj = new BipedObject(reader, entry);
                break;

            case TagGroup.Vehi:
                obj = new VehicleObject(reader, entry);
                break;

            case TagGroup.Weap:
                obj = new WeaponObject(reader, entry);
                break;

            case TagGroup.Eqip:
                obj = new EquipmentObject(reader, entry);
                break;

            default:
                obj = new GameObject(reader, entry);
                break;
            }
            _objects.Add(obj);

            if (obj.Next == null)
            {
                _lastPoolObject = obj;
            }

            return(true);
        }