/// <summary>
        /// Sets NPC data from RMB layout flat record. (exterior NPCs)
        /// Requires mapID and locationIndex to be passed in as layout may occur without player being in the location.
        /// </summary>
        public void SetLayoutData(DFBlock.RmbBlockFlatObjectRecord obj, int mapId, int locationIndex)
        {
            // Gender flag is invalid for RMB exterior NPCs: get it from FLATS.CFG instead
            int flatID = FlatsFile.GetFlatID(obj.TextureArchive, obj.TextureRecord);

            if (DaggerfallUnity.Instance.ContentReader.FlatsFileReader.GetFlatData(flatID, out FlatsFile.FlatData flatCFG))
            {
                if (flatCFG.gender.Contains("2"))
                {
                    obj.Flags |= 32;
                }
                else
                {
                    obj.Flags &= 223;
                }
            }

            SetLayoutData(ref npcData,
                          obj.XPos, obj.YPos, obj.ZPos,
                          obj.Flags,
                          obj.FactionID,
                          obj.TextureArchive,
                          obj.TextureRecord,
                          obj.Position,
                          mapId,
                          locationIndex,
                          0);
            npcData.context = Context.Custom;
        }
Beispiel #2
0
 public void CreateData(DFBlock.RmbBlockFlatObjectRecord data, bool isExterior)
 {
     HideComponents();
     type            = DataType.Flat;
     this.isExterior = isExterior;
     id        = data.TextureArchive + "." + data.TextureRecord;
     factionID = data.FactionID;
     flags     = data.Flags;
 }
 /// <summary>
 /// Sets NPC data from RMB layout flat record. (exterior NPCs)
 /// </summary>
 public void SetLayoutData(DFBlock.RmbBlockFlatObjectRecord obj)
 {
     SetLayoutData(ref npcData,
                   obj.XPos, obj.YPos, obj.ZPos,
                   obj.Flags,
                   obj.FactionID,
                   obj.TextureArchive,
                   obj.TextureRecord,
                   obj.Position,
                   0);
     npcData.context = Context.Custom;
 }
Beispiel #4
0
        private static void AddLight(DaggerfallUnity dfUnity, DFBlock.RmbBlockFlatObjectRecord obj, Transform parent = null)
        {
            if (dfUnity.Option_CityLightPrefab == null)
            {
                return;
            }

            Vector2 size     = dfUnity.MeshReader.GetScaledBillboardSize(210, obj.TextureRecord);
            Vector3 position = new Vector3(
                obj.XPos,
                -obj.YPos + size.y,
                obj.ZPos + BlocksFile.RMBDimension) * MeshReader.GlobalScale;

            GameObjectHelper.InstantiatePrefab(dfUnity.Option_CityLightPrefab.gameObject, string.Empty, parent, position);
        }
        public static GameObject AddFlatObject(DFBlock.RmbBlockFlatObjectRecord rmbBlock, Quaternion subRecordRotation)
        {
            Vector3 billboardPosition = new Vector3(rmbBlock.XPos, -rmbBlock.YPos, rmbBlock.ZPos) * MeshReader.GlobalScale;

            billboardPosition = subRecordRotation * billboardPosition;

            // Spawn billboard gameobject
            GameObject go = DaggerfallWorkshop.Utility.GameObjectHelper.CreateDaggerfallBillboardGameObject(rmbBlock.TextureArchive, rmbBlock.TextureRecord, null);

            // Set position
            Billboard dfBillboard = go.GetComponent <Billboard>();

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

            return(go);
        }
Beispiel #6
0
        /// <summary>
        /// Adds interior point light.
        /// </summary>
        private static void AddLight(DFBlock.RmbBlockFlatObjectRecord obj, Transform parent = null)
        {
            if (DaggerfallUnity.Instance.Option_InteriorLightPrefab == null)
            {
                return;
            }

            // Create gameobject
            GameObject go = GameObjectHelper.InstantiatePrefab(DaggerfallUnity.Instance.Option_InteriorLightPrefab.gameObject, string.Empty, parent, Vector3.zero);

            // Set local position to billboard origin, otherwise light transform is at base of billboard
            go.transform.localPosition = Vector3.zero;

            // Adjust position of light for standing lights as their source comes more from top than middle
            Vector2 size = DaggerfallUnity.Instance.MeshReader.GetScaledBillboardSize(210, obj.TextureRecord) * MeshReader.GlobalScale;

            switch (obj.TextureRecord)
            {
            case 0:             // Bowl with fire
                go.transform.localPosition += new Vector3(0, -0.1f, 0);
                break;

            case 1:             // Campfire
                // todo
                break;

            case 2:             // Skull candle
                go.transform.localPosition += new Vector3(0, 0.1f, 0);
                break;

            case 3:             // Candle
                go.transform.localPosition += new Vector3(0, 0.1f, 0);
                break;

            case 4:             // Candle in bowl
                // todo
                break;

            case 5:             // Candleholder with 3 candles
                go.transform.localPosition += new Vector3(0, 0.15f, 0);
                break;

            case 6:             // Skull torch
                go.transform.localPosition += new Vector3(0, 0.6f, 0);
                break;

            case 7:             // Wooden chandelier with extinguished candles
                // todo
                break;

            case 8:             // Turkis lamp
                // do nothing
                break;

            case 9:            // Metallic chandelier with burning candles
                go.transform.localPosition += new Vector3(0, 0.4f, 0);
                break;

            case 10:             // Metallic chandelier with extinguished candles
                // todo
                break;

            case 11:            // Candle in lamp
                go.transform.localPosition += new Vector3(0, -0.4f, 0);
                break;

            case 12:             // Extinguished lamp
                // todo
                break;

            case 13:            // Round lamp (e.g. main lamp in mages guild)
                go.transform.localPosition += new Vector3(0, -0.35f, 0);
                break;

            case 14:            // Standing lantern
                go.transform.localPosition += new Vector3(0, size.y / 2, 0);
                break;

            case 15:            // Standing lantern round
                go.transform.localPosition += new Vector3(0, size.y / 2, 0);
                break;

            case 16:             // Mounted Torch with thin holder
                // todo
                break;

            case 17:            // Mounted torch 1
                go.transform.localPosition += new Vector3(0, 0.2f, 0);
                break;

            case 18:             // Mounted Torch 2
                // todo
                break;

            case 19:             // Pillar with firebowl
                // todo
                break;

            case 20:            // Brazier torch
                go.transform.localPosition += new Vector3(0, 0.6f, 0);
                break;

            case 21:            // Standing candle
                go.transform.localPosition += new Vector3(0, size.y / 2.4f, 0);
                break;

            case 22:             // Round lantern with medium chain
                go.transform.localPosition += new Vector3(0, -0.5f, 0);
                break;

            case 23:             // Wooden chandelier with burning candles
                // todo
                break;

            case 24:            // Lantern with long chain
                go.transform.localPosition += new Vector3(0, -1.85f, 0);
                break;

            case 25:            // Lantern with medium chain
                go.transform.localPosition += new Vector3(0, -1.0f, 0);
                break;

            case 26:            // Lantern with short chain
                // todo
                break;

            case 27:            // Lantern with no chain
                go.transform.localPosition += new Vector3(0, -0.02f, 0);
                break;

            case 28:            // Street Lantern 1
                // todo
                break;

            case 29:            // Street Lantern 2
                // todo
                break;
            }

            // adjust properties of light sources (e.g. Shrink light radius of candles)
            Light light = go.GetComponent <Light>();

            switch (obj.TextureRecord)
            {
            case 0:             // Bowl with fire
                light.range     = 20.0f;
                light.intensity = 1.1f;
                light.color     = new Color(0.95f, 0.91f, 0.63f);
                break;

            case 1:             // Campfire
                // todo
                break;

            case 2:             // Skull candle
                light.range    /= 3f;
                light.intensity = 0.6f;
                light.color     = new Color(1.0f, 0.99f, 0.82f);
                break;

            case 3:             // Candle
                light.range /= 3f;
                break;

            case 4:             // Candle with base
                light.range /= 3f;
                break;

            case 5:             // Candleholder with 3 candles
                light.range     = 7.5f;
                light.intensity = 0.33f;
                light.color     = new Color(1.0f, 0.89f, 0.61f);
                break;

            case 6:             // Skull torch
                light.range     = 15.0f;
                light.intensity = 0.75f;
                light.color     = new Color(1.0f, 0.93f, 0.62f);
                break;

            case 7:             // Wooden chandelier with extinguished candles
                // todo
                break;

            case 8:             // Turkis lamp
                light.color = new Color(0.68f, 1.0f, 0.94f);
                break;

            case 9:            // metallic chandelier with burning candles
                light.range     = 15.0f;
                light.intensity = 0.65f;
                light.color     = new Color(1.0f, 0.92f, 0.6f);
                break;

            case 10:             // Metallic chandelier with extinguished candles
                // todo
                break;

            case 11:            // Candle in lamp
                light.range     = 5.0f;
                light.intensity = 0.5f;
                break;

            case 12:             // Extinguished lamp
                // todo
                break;

            case 13:            // Round lamp (e.g. main lamp in mages guild)
                light.range    *= 1.2f;
                light.intensity = 1.1f;
                light.color     = new Color(0.93f, 0.84f, 0.49f);
                break;

            case 14:            // Standing lantern
                // todo
                break;

            case 15:            // Standing lantern round
                // todo
                break;

            case 16:             // Mounted Torch with thin holder
                // todo
                break;

            case 17:            // Mounted torch 1
                light.intensity = 0.8f;
                light.color     = new Color(1.0f, 0.97f, 0.87f);
                break;

            case 18:             // Mounted Torch 2
                // todo
                break;

            case 19:             // Pillar with firebowl
                // todo
                break;

            case 20:            // Brazier torch
                light.range     = 12.0f;
                light.intensity = 0.75f;
                light.color     = new Color(1.0f, 0.92f, 0.72f);
                break;

            case 21:            // Standing candle
                light.range    /= 3f;
                light.intensity = 0.5f;
                light.color     = new Color(1.0f, 0.95f, 0.67f);
                break;

            case 22:             // Round lantern with medium chain
                light.intensity = 1.5f;
                light.color     = new Color(1.0f, 0.95f, 0.78f);
                break;

            case 23:             // Wooden chandelier with burning candles
                // todo
                break;

            case 24:            // Lantern with long chain
                light.intensity = 1.4f;
                light.color     = new Color(1.0f, 0.98f, 0.64f);
                break;

            case 25:            // Lantern with medium chain
                light.intensity = 1.4f;
                light.color     = new Color(1.0f, 0.98f, 0.64f);
                break;

            case 26:            // Lantern with short chain
                light.intensity = 1.4f;
                light.color     = new Color(1.0f, 0.98f, 0.64f);
                break;

            case 27:            // Lantern with no chain
                light.intensity = 1.4f;
                light.color     = new Color(1.0f, 0.98f, 0.64f);
                break;

            case 28:            // Street Lantern 1
                // todo
                break;

            case 29:            // Street Lantern 2
                // todo
                break;
            }

            // TODO: Could also adjust light colour and intensity, or change prefab entirely above for any obj.TextureRecord
        }