Пример #1
0
        private void AddFurnitureAction(DFBlock.RmbBlock3dObjectRecord obj, GameObject go, PlayerGPS.DiscoveredBuilding buildingData)
        {
            // Create unique LoadID for save system, using 9 lsb and the sign bit from each coord pos int
            ulong loadID = ((ulong)buildingData.buildingKey) << 30 |
                           (uint)(obj.XPos << 1 & posMask) << 20 |
                           (uint)(obj.YPos << 1 & posMask) << 10 |
                           (uint)(obj.ZPos << 1 & posMask);

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;

            // Handle shelves:
            if (shopShelvesObjectGroupIndices.Contains(obj.ModelIdNum - containerObjectGroupOffset))
            {
                if (RMBLayout.IsShop(buildingType))
                {
                    // Shop shelves, so add a DaggerfallLoot component
                    DaggerfallLoot loot = go.AddComponent <DaggerfallLoot>();
                    if (loot)
                    {
                        // Set as shelves, assign load id and create serialization object
                        loot.ContainerType  = LootContainerTypes.ShopShelves;
                        loot.ContainerImage = InventoryContainerImages.Shelves;
                        loot.LoadID         = loadID;
                        if (SaveLoadManager.Instance != null)
                        {
                            go.AddComponent <SerializableLootContainer>();
                        }
                    }
                }
                else if (buildingType == DFLocation.BuildingTypes.Library ||
                         buildingType == DFLocation.BuildingTypes.GuildHall ||
                         buildingType == DFLocation.BuildingTypes.Temple)
                {
                    // Bookshelves, add DaggerfallBookshelf component
                    go.AddComponent <DaggerfallBookshelf>();
                }
                else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey))
                {   // Player owned house, everything is a house container
                    MakeHouseContainer(obj, go, loadID);
                }
            }
            // Handle generic furniture as (private) house containers:
            // (e.g. shelves, boxes, wardrobes, drawers etc)
            else if (obj.ModelIdNum / 100 == houseContainerObjectGroup ||
                     houseContainerObjectGroupIndices.Contains(obj.ModelIdNum - containerObjectGroupOffset))
            {
                MakeHouseContainer(obj, go, loadID);
            }
        }
Пример #2
0
        private static void MakeHouseContainer(DFBlock.RmbBlock3dObjectRecord obj, GameObject go, ulong loadID)
        {
            DaggerfallLoot loot = go.AddComponent <DaggerfallLoot>();

            if (loot)
            {
                // Set as house container (private furniture) and assign load id
                loot.ContainerType  = LootContainerTypes.HouseContainers;
                loot.ContainerImage = InventoryContainerImages.Shelves;
                loot.LoadID         = loadID;
                loot.TextureRecord  = (int)obj.ModelIdNum % 100;
                if (SaveLoadManager.Instance != null)
                {
                    go.AddComponent <SerializableLootContainer>();
                }
            }
        }
Пример #3
0
        public NearbyObjectFlags GetLootFlags(DaggerfallLoot loot)
        {
            NearbyObjectFlags result = NearbyObjectFlags.None;

            if (!loot)
            {
                return(result);
            }

            // Set treasure flag when container not empty
            // Are any other conditions required?
            // Should corspes loot container be filtered out?
            if (loot.Items.Count > 0)
            {
                result |= NearbyObjectFlags.Treasure;
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Add interior flats.
        /// </summary>
        private void AddFlats(PlayerGPS.DiscoveredBuilding buildingData)
        {
            GameObject node = new GameObject("Interior Flats");

            node.transform.parent = this.transform;

            // Add block flats
            markers.Clear();
            foreach (DFBlock.RmbBlockFlatObjectRecord obj in recordData.Interior.BlockFlatObjectRecords)
            {
                // Calculate position
                Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale;

                // Import custom 3d gameobject instead of flat
                if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform) != null)
                {
                    continue;
                }

                // Spawn billboard gameobject
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform);

                // Set position
                DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
                go.transform.position  = billboardPosition;
                go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);

                // Add editor markers to list
                if (obj.TextureArchive == TextureReader.EditorFlatsTextureArchive)
                {
                    InteriorEditorMarker marker = new InteriorEditorMarker();
                    marker.type       = (InteriorMarkerTypes)obj.TextureRecord;
                    marker.gameObject = go;
                    markers.Add(marker);

                    // Add loot containers for treasure markers (always use pile of clothes icon)
                    if (marker.type == InteriorMarkerTypes.Treasure)
                    {
                        // Create unique LoadID for save system, using 9 lsb and the sign bit from each coord pos int
                        ulong loadID = ((ulong)buildingData.buildingKey) << 30 |
                                       (uint)(obj.XPos << 1 & posMask) << 20 |
                                       (uint)(obj.YPos << 1 & posMask) << 10 |
                                       (uint)(obj.ZPos << 1 & posMask);

                        DaggerfallLoot loot = GameObjectHelper.CreateLootContainer(
                            LootContainerTypes.RandomTreasure,
                            InventoryContainerImages.Chest,
                            billboardPosition,
                            node.transform,
                            DaggerfallLootDataTables.clothingArchive,
                            0, loadID);

                        if (!LootTables.GenerateLoot(loot, (int)GameManager.Instance.PlayerGPS.CurrentLocationType))
                        {
                            DaggerfallUnity.LogMessage(string.Format("DaggerfallInterior: Location type {0} is out of range or unknown.", GameManager.Instance.PlayerGPS.CurrentLocationType), true);
                        }
                    }
                }

                // Add point lights
                if (obj.TextureArchive == TextureReader.LightsTextureArchive)
                {
                    AddLight(obj, go.transform);
                }
            }
        }
 private void Start()
 {
     daggerfallLoot = this.GetComponent <DaggerfallLoot>();
     DaggerfallUI.UIManager.OnWindowChange += AddStock;
 }