Exemple #1
0
        /// <summary>
        /// Builds a Billboard object
        /// </summary>
        public void Show()
        {
            if (mBillboard == null)
            {
                StyledQuad cardBackground = new StyledQuad
                                            (
                    "Quad",
                    GameFacade.Instance.RetrieveMediator <FashionGameGui>().GetNamedStyle(StyleName)
                                            );

                FashionCameraMediator cameraMediator = GameFacade.Instance.RetrieveMediator <FashionCameraMediator>();

                Billboard billboard = new Billboard();
                billboard.BillboardGameObject.layer = FashionMinigame.CLOTHING_LAYER;
                Material billboardMat = new Material(Shader.Find("GUI/Flat Color"));
                billboardMat.mainTexture = this.NormalTexture;
                billboard.SetMaterial(billboardMat);
                billboard.BillboardToCamera(cameraMediator.Camera);

                // Hard coded values: a bunch of them
                cardBackground.Size                    = new Vector2(4.0f, 4.0f);
                cardBackground.Transform.parent        = billboard.Transform;
                cardBackground.Transform.localPosition = new Vector3(-1.1f, 1.1f, -0.05f);
                cardBackground.Transform.localScale    = new Vector3(BILLBOARD_ASPECT_RATIO, 1.0f, 1.0f) * 0.55f;
                cardBackground.Transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f);

                mBillboard = new Pair <Billboard, StyledQuad>(billboard, cardBackground);
                SetBillboardSize(BILLBOARD_SIZE);
            }
        }
Exemple #2
0
        public void RestoreSaveData(object dataIn)
        {
            if (!loot)
            {
                return;
            }

            LootContainerData_v1 data = (LootContainerData_v1)dataIn;

            if (data.loadID != LoadID)
            {
                return;
            }

            // Restore billboard only if this is a billboard-based loot container
            if (loot.ContainerType == LootContainerTypes.RandomTreasure ||
                loot.ContainerType == LootContainerTypes.CorpseMarker ||
                loot.ContainerType == LootContainerTypes.DroppedLoot)
            {
                Billboard billboard = loot.GetComponent <Billboard>();

                // Interiors and exteriors need special handling to ensure loot is always placed correctly for pre and post floating y saves
                // Dungeons are not involved with floating y and don't need any changes
                WorldContext lootContext = GetLootWorldContext(loot);
                if (lootContext == WorldContext.Interior)
                {
                    RestoreInteriorPositionHandler(loot, data, lootContext);
                }
                else if (lootContext == WorldContext.Exterior)
                {
                    RestoreExteriorPositionHandler(loot, data, lootContext);
                }
                else
                {
                    loot.transform.position = data.currentPosition;
                }

                // Restore appearance
                if (MeshReplacement.SwapCustomFlatGameobject(data.textureArchive, data.textureRecord, loot.transform, Vector3.zero, lootContext == WorldContext.Dungeon))
                {
                    // Use imported model instead of billboard
                    if (billboard)
                    {
                        Destroy(billboard);
                    }
                    Destroy(GetComponent <MeshRenderer>());
                }
                else
                {
                    // Restore billboard if previously replaced by custom model
                    // This happens when the record is changed and new model is not provided by mods
                    if (!billboard)
                    {
                        billboard = loot.transform.gameObject.AddComponent <DaggerfallBillboard>();
                    }

                    // Restore billboard appearance
                    billboard.SetMaterial(data.textureArchive, data.textureRecord);

                    // Fix position if custom scale changed
                    if (data.heightScale == 0)
                    {
                        data.heightScale = 1;
                    }
                    if (data.heightScale != billboard.transform.localScale.y)
                    {
                        float height = billboard.Summary.Size.y * (data.heightScale / billboard.transform.localScale.y);
                        billboard.transform.Translate(0, (billboard.Summary.Size.y - height) / 2f, 0);
                    }
                }
            }

            // Restore items
            loot.Items.DeserializeItems(data.items);

            // Restore other data
            loot.ContainerType  = data.containerType;
            loot.ContainerImage = data.containerImage;
            loot.TextureArchive = data.textureArchive;
            loot.TextureRecord  = data.textureRecord;
            loot.stockedDate    = data.stockedDate;
            loot.playerOwned    = data.playerOwned;
            loot.customDrop     = data.customDrop;
            loot.entityName     = data.entityName;
            loot.isEnemyClass   = data.isEnemyClass;

            // Remove loot container if empty
            if (loot.Items.Count == 0)
            {
                GameObjectHelper.RemoveLootContainer(loot);
            }
        }