/// <summary> /// Creates a generic loot container. /// </summary> /// <param name="containerType">Type of container.</param> /// <param name="containerImage">Icon to display in loot UI.</param> /// <param name="position">Position to spawn container.</param> /// <param name="parent">Parent GameObject.</param> /// <param name="textureArchive">Texture archive for billboard containers.</param> /// <param name="textureRecord">Texture record for billboard containers.</param> /// <param name="loadID">Unique LoadID for save system.</param> /// <returns>DaggerfallLoot.</returns> public static DaggerfallLoot CreateLootContainer( LootContainerTypes containerType, InventoryContainerImages containerImage, Vector3 position, Transform parent, int textureArchive, int textureRecord, ulong loadID = 0) { // Setup initial loot container prefab GameObject go = InstantiatePrefab(DaggerfallUnity.Instance.Option_LootContainerPrefab.gameObject, containerType.ToString(), parent, position); // Setup billboard component DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetMaterial(textureArchive, textureRecord); // Setup DaggerfallLoot component to make lootable DaggerfallLoot loot = go.GetComponent <DaggerfallLoot>(); if (loot) { loot.LoadID = loadID; loot.ContainerType = containerType; loot.ContainerImage = containerImage; loot.TextureArchive = textureArchive; loot.TextureRecord = textureRecord; } // Now move up loot icon by half own size so bottom is aligned with position position.y += (dfBillboard.Summary.Size.y / 2f); loot.transform.position = position; return(loot); }
/// <summary> /// Aligns billboard GameObject to centre of base. /// This is required for exterior billboard. /// </summary> /// <param name="go">GameObject with DaggerfallBillboard component.</param> public static void AlignBillboardToBase(GameObject go) { DaggerfallBillboard c = go.GetComponent <DaggerfallBillboard>(); if (c) { c.AlignToBase(); } }
public void RestoreSaveData(object dataIn) { if (!loot) { return; } LootContainerData_v1 data = (LootContainerData_v1)dataIn; if (data.loadID != LoadID) { return; } DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // Restore position loot.transform.position = data.currentPosition; // Restore appearance if (MeshReplacement.ImportCustomFlatGameobject(data.textureArchive, data.textureRecord, Vector3.zero, loot.transform)) { // Use imported model instead of billboard if (billboard) { Destroy(billboard); } Destroy(GetComponent <MeshRenderer>()); } else if (billboard) { // Restore billboard appearance if present billboard.SetMaterial(data.textureArchive, data.textureRecord); } // Restore items loot.Items.DeserializeItems(data.items); // Restore other data loot.ContainerType = data.containerType; loot.ContainerImage = data.containerImage; loot.LootTableKey = data.lootTableKey; loot.TextureArchive = data.textureArchive; loot.TextureRecord = data.textureRecord; loot.playerOwned = data.playerOwned; loot.customDrop = data.customDrop; loot.name = loot.ContainerType.ToString(); loot.entityName = data.entityName; loot.isEnemyClass = data.isEnemyClass; // Remove loot container if empty if (loot.Items.Count == 0) { GameObjectHelper.RemoveLootContainer(loot); } }
private void AddRDBFlat(DFBlock.RdbObject obj, Transform parent) { int archive = obj.Resources.FlatResource.TextureArchive; int record = obj.Resources.FlatResource.TextureRecord; // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, parent, true); Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Add RDB data to billboard DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetResourceData(obj.Resources.FlatResource); // Set transform go.transform.position = billboardPosition; // Handle supported editor flats if (dfUnity.Option_ImportEnemies && archive == 199) { switch (record) { case 10: // Start marker startMarkers.Add(go); break; case 15: // Random enemy AddRandomRDBEnemy(obj); go.SetActive(false); break; case 16: // Fixed enemy AddFixedRDBEnemy(obj); go.SetActive(false); break; } } // Add torch burning sound if (dfUnity.Option_DefaultSounds && archive == 210) { switch (record) { case 0: case 1: case 6: case 16: case 17: case 18: case 19: case 20: AddTorchAudioSource(go); break; } } }
/// <summary> /// Add a quest NPC to marker position. /// </summary> static void AddQuestNPC(SiteTypes siteType, Quest quest, QuestMarker marker, Person person, Transform parent) { // Get billboard texture data FactionFile.FlatData flatData; if (person.IsIndividualNPC) { // Individuals are always flat1 no matter gender flatData = FactionFile.GetFlatData(person.FactionData.flat1); } if (person.Gender == Genders.Male) { // Male has flat1 flatData = FactionFile.GetFlatData(person.FactionData.flat1); } else { // Female has flat2 flatData = FactionFile.GetFlatData(person.FactionData.flat2); } // Create target GameObject GameObject go = CreateDaggerfallBillboardGameObject(flatData.archive, flatData.record, parent); go.name = string.Format("Quest NPC [{0}]", person.DisplayName); // Set position and adjust up by half height if not inside a dungeon Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide); go.transform.localPosition = dungeonBlockPosition + marker.flatPosition; DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); if (siteType != SiteTypes.Dungeon) { go.transform.localPosition += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0); } // Add people data to billboard dfBillboard.SetRMBPeopleData(person.FactionIndex, person.FactionData.flags); // Add QuestResourceBehaviour to GameObject QuestResourceBehaviour questResourceBehaviour = go.AddComponent <QuestResourceBehaviour>(); questResourceBehaviour.AssignResource(person); // Set QuestResourceBehaviour in Person object person.QuestResourceBehaviour = questResourceBehaviour; // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData((int)marker.flatPosition.x, (int)marker.flatPosition.y, (int)marker.flatPosition.z, person); // Set tag go.tag = QuestMachine.questPersonTag; }
public void RestoreSaveData(object dataIn) { if (!loot) { return; } LootContainerData_v1 data = (LootContainerData_v1)dataIn; if (data.loadID != LoadID) { return; } DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // Restore position loot.transform.position = data.currentPosition; // Restore billboard appearance if present if (billboard) { billboard.SetMaterial(data.textureArchive, data.textureRecord); // Setup custom material if available if (TextureReplacement.CustomTextureExist(data.textureArchive, data.textureRecord)) { TextureReplacement.SetBillboardCustomMaterial(billboard.gameObject, data.textureArchive, data.textureRecord); } } // Restore items loot.Items.DeserializeItems(data.items); // Restore other data loot.ContainerType = data.containerType; loot.ContainerImage = data.containerImage; loot.LootTableKey = data.lootTableKey; loot.TextureArchive = data.textureArchive; loot.TextureRecord = data.textureRecord; loot.playerOwned = data.playerOwned; loot.customDrop = data.customDrop; loot.name = loot.ContainerType.ToString(); // Remove loot container if empty if (loot.Items.Count == 0) { GameObjectHelper.RemoveLootContainer(loot); } }
/// <summary> /// Adds a quest item to marker position. /// </summary> static void AddQuestItem(SiteTypes siteType, Quest quest, QuestMarker marker, Item item, Transform parent = null) { // Texture indices for quest items are from world texture record int textureArchive = item.DaggerfallUnityItem.WorldTextureArchive; int textureRecord = item.DaggerfallUnityItem.WorldTextureRecord; // Create billboard GameObject go = CreateDaggerfallBillboardGameObject(textureArchive, textureRecord, parent); DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); // Set name go.name = string.Format("Quest Item [{0} | {1}]", item.Symbol.Original, item.DaggerfallUnityItem.LongName); // Setup custom material if available if (AssetInjection.TextureReplacement.CustomTextureExist(textureArchive, textureRecord)) { AssetInjection.TextureReplacement.SetBillboardCustomMaterial(go, textureArchive, textureRecord); } // Marker position Vector3 position; Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide); position = dungeonBlockPosition + marker.flatPosition; // Dungeon flats have a different origin (centre point) than elsewhere (base point) // Find bottom of marker in world space as it should be aligned to placement surface (e.g. ground, table, shelf, etc.) if (siteType == SiteTypes.Dungeon) { position.y += (-DaggerfallLoot.randomTreasureMarkerDim / 2 * MeshReader.GlobalScale); } // Now move up item icon by half own size and assign position position.y += (dfBillboard.Summary.Size.y / 2f); go.transform.localPosition = position; // Add QuestResourceBehaviour to GameObject QuestResourceBehaviour questResourceBehaviour = go.AddComponent <QuestResourceBehaviour>(); questResourceBehaviour.AssignResource(item); // Set QuestResourceBehaviour in Item object item.QuestResourceBehaviour = questResourceBehaviour; // Assign a trigger collider for clicks SphereCollider collider = go.AddComponent <SphereCollider>(); collider.isTrigger = true; }
public void ShowMagicSparkles(Vector3 sparklesPosition) { // Create oneshot animated billboard for sparkles effect DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (dfUnity) { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(bloodArchive, sparklesIndex, null); go.name = "MagicSparkles"; DaggerfallBillboard c = go.GetComponent <DaggerfallBillboard>(); go.transform.position = sparklesPosition + transform.forward * 0.02f; c.OneShot = true; c.FramesPerSecond = 10; } }
public static GameObject CreateDaggerfallBillboardGameObject(int archive, int record, Transform parent, bool dungeon = false) { GameObject go = new GameObject(string.Format("DaggerfallBillboard [TEXTURE.{0:000}, Index={1}]", archive, record)); if (parent) { go.transform.parent = parent; } DaggerfallBillboard dfBillboard = go.AddComponent <DaggerfallBillboard>(); dfBillboard.SetMaterial(archive, record, 0, dungeon); return(go); }
public void ShowBloodSplash(int bloodIndex, Vector3 bloodPosition) { // Create oneshot animated billboard for blood effect DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (dfUnity) { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(bloodArchive, bloodIndex, null, true); go.name = "BloodSplash"; DaggerfallBillboard c = go.GetComponent <DaggerfallBillboard>(); go.transform.position = bloodPosition + transform.forward * 0.02f; c.OneShot = true; c.FramesPerSecond = 10; } }
private void Start() { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(candleArchive, candleRecord, transform); go.transform.localPosition = Vector3.zero; myBillboard = go.GetComponent <DaggerfallBillboard>(); myBillboard.FramesPerSecond = candleFramesPerSecond; myBillboard.FaceY = true; myBillboard.OneShot = false; myBillboard.GetComponent <MeshRenderer>().receiveShadows = false; startLocalPosition = transform.localPosition; lastOffsetPosition = startLocalPosition; SaveLoadManager.OnStartLoad += SaveLoadManager_OnStartLoad; StartGameBehaviour.OnNewGame += StartGameBehaviour_OnNewGame; }
// WIP, Rolls if a valid building will spawn a service NPC and returns what type will spawn (as an appropriate object, void just for now.) public static void RollServiceNPC(bool newBuilding) { int texArchive = 184; int texRecord = 1; string serviceFlat = "Service Person Flat"; GameObject node = new GameObject(serviceFlat); GameObject go = null; Vector3 billboardPosition = new Vector3(10, 0, 10) * MeshReader.GlobalScale; // Spawn billboard gameobject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(texArchive, texRecord, node.transform); // This has something to do with creating a Flat/billboard NPC in the world, play around more and test. // Set position DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); go.transform.position = billboardPosition; go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0); }
private static void AddAnimalAudioSource(GameObject go) { DaggerfallAudioSource source = go.AddComponent <DaggerfallAudioSource>(); source.AudioSource.maxDistance = animalSoundMaxDistance; DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); SoundClips sound = SoundClips.None; switch (dfBillboard.Summary.Record) { case 0: case 1: sound = SoundClips.AnimalHorse; break; case 3: case 4: sound = SoundClips.AnimalCow; break; case 5: case 6: sound = SoundClips.AnimalPig; break; case 7: case 8: sound = SoundClips.AnimalCat; break; case 9: case 10: sound = SoundClips.AnimalDog; break; default: sound = SoundClips.None; break; } source.SetSound(sound, AudioPresets.PlayRandomlyIfPlayerNear); }
private static GameObject AddFlat(DFBlock.RdbObject obj, Transform parent) { int archive = obj.Resources.FlatResource.TextureArchive; int record = obj.Resources.FlatResource.TextureRecord; // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, parent, true); Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Add RDB data to billboard DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetResourceData(obj.Resources.FlatResource); // Set transform go.transform.position = billboardPosition; // Disable enemy flats if (archive == TextureReader.EditorFlatsTextureArchive && (record == 15 || record == 16)) { go.SetActive(false); } // Add torch burning sound if (archive == TextureReader.LightsTextureArchive) { switch (record) { case 0: case 1: case 6: case 16: case 17: case 18: case 19: case 20: AddTorchAudioSource(go); break; } } return(go); }
void UseSpellBillboardAnims(int record = 0, bool oneShot = false) { // Destroy any existing billboard game object if (myBillboard) { myBillboard.gameObject.SetActive(false); Destroy(myBillboard.gameObject); } // Add new billboard parented to this missile GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(GetMissileTextureArchive(), record, transform); go.transform.localPosition = Vector3.zero; myBillboard = go.GetComponent <DaggerfallBillboard>(); myBillboard.FramesPerSecond = BillboardFramesPerSecond; myBillboard.FaceY = true; myBillboard.OneShot = oneShot; myBillboard.GetComponent <MeshRenderer>().receiveShadows = false; }
public static GameObject CreateDaggerfallBillboardGameObject(int archive, int record, Transform parent) { GameObject go = new GameObject(string.Format("DaggerfallBillboard [TEXTURE.{0:000}, Index={1}]", archive, record)); if (parent) { go.transform.parent = parent; } DaggerfallBillboard dfBillboard = go.AddComponent <DaggerfallBillboard>(); dfBillboard.SetMaterial(archive, record); // Import custom texture(s) if (AssetInjection.TextureReplacement.CustomTextureExist(archive, record)) { AssetInjection.TextureReplacement.SetBillboardCustomMaterial(go, archive, record); } return(go); }
/// <summary> /// Add subrecord (building) exterior block flats. /// </summary> public static void AddExteriorBlockFlats( ref DFBlock blockData, Transform flatsParent, Transform lightsParent, int mapId, int locationIndex, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer) { DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return; } // Get Nature Archive int natureArchive = ClimateSwaps.GetNatureArchive(climateNature, climateSeason); foreach (DFBlock.RmbSubRecord subRecord in blockData.RmbBlock.SubRecords) { Vector3 subRecordPosition = new Vector3(subRecord.XPos, 0, -subRecord.ZPos) * MeshReader.GlobalScale; foreach (DFBlock.RmbBlockFlatObjectRecord obj in subRecord.Exterior.BlockFlatObjectRecords) { // Don't add building exterior editor flats since they can't be used by any DFU systems int archive = obj.TextureArchive; if (archive == TextureReader.EditorFlatsTextureArchive) { continue; } // Calculate position Vector3 billboardPosition = new Vector3( obj.XPos, -obj.YPos + blockFlatsOffsetY, obj.ZPos + BlocksFile.RMBDimension) * MeshReader.GlobalScale; billboardPosition += subRecordPosition; // Add natures using correct climate set archive if (archive >= (int)DFLocation.ClimateTextureSet.Nature_RainForest && archive <= (int)DFLocation.ClimateTextureSet.Nature_Mountains_Snow) { archive = natureArchive; billboardPosition.z = natureFlatsOffsetY; } // Import custom 3d gameobject instead of flat if (MeshReplacement.ImportCustomFlatGameobject(archive, obj.TextureRecord, billboardPosition, flatsParent) != null) { continue; } // Add standalone billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, obj.TextureRecord, flatsParent); go.transform.position = billboardPosition; AlignBillboardToBase(go); // Add animal sound if (archive == TextureReader.AnimalsTextureArchive) { AddAnimalAudioSource(go); } // If flat record has a non-zero faction id, then it's an exterior NPC if (obj.FactionID != 0) { // Add RMB data to billboard DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetRMBPeopleData(obj.FactionID, obj.Flags, obj.Position); // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj, mapId, locationIndex); } // If this is a light flat, import light prefab if (archive == TextureReader.LightsTextureArchive) { 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; position += subRecordPosition; GameObjectHelper.InstantiatePrefab(dfUnity.Option_CityLightPrefab.gameObject, string.Empty, lightsParent, position); } } } }
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) { DaggerfallBillboard billboard = loot.GetComponent <DaggerfallBillboard>(); // 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 if (billboard) { // Restore billboard appearance if present billboard.SetMaterial(data.textureArchive, data.textureRecord); } } // 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); } }
void Start() { Texture2D npcTempTexture = null; marker.mobileNPC = GetComponentInParent <MobilePersonNPC>(); marker.mobileEnemy = gameObject.GetComponent <DaggerfallEnemy>(); marker.flatNPC = GetComponentInParent <StaticNPC>(); //setup base npc marker object and properties. marker.markerObject = GameObject.CreatePrimitive(PrimitiveType.Quad); marker.npcMesh = marker.markerObject.GetComponent <MeshRenderer>(); //updateMaterials(); marker.npcMesh.material = Minimap.minimapNpcManager.npcIconMaterialDict[marker.markerType]; marker.npcMesh.material.mainTexture = Minimap.minimapNpcManager.npcDotTexture; Destroy(marker.markerObject.GetComponent <Collider>()); marker.markerObject.transform.SetParent(transform, false); marker.markerObject.layer = Minimap.layerMinimap; marker.markerObject.transform.Rotate(90, 0, 0); marker.npcMesh.material.mainTexture = Minimap.minimapNpcManager.npcDotTexture; marker.isActive = true; //check if player is inside or not, and then setup proper marker size. //This needs moved to update in some way, so it updates on entering a building/dungeon. if (GameManager.Instance.IsPlayerInside) { markerScale = new Vector3(Minimap.indicatorSize, Minimap.indicatorSize, Minimap.indicatorSize); } else { markerScale = new Vector3(Minimap.indicatorSize, Minimap.indicatorSize, Minimap.indicatorSize); } //set marker object scale. marker.markerObject.transform.localScale = markerScale; //if friendly npc present, setup flat npc marker color, type, and activate marker object so iit shows on minimap. if (marker.mobileNPC != null) { if (marker.mobileNPC.IsGuard) { textures = Minimap.minimapNpcManager.guardTextures; } else { switch (marker.mobileNPC.Race) { case Races.Redguard: textures = (marker.mobileNPC.Gender == Genders.Male) ? NPCManager.maleRedguardTextures : NPCManager.femaleRedguardTextures; break; case Races.Nord: textures = (marker.mobileNPC.Gender == Genders.Male) ? NPCManager.maleNordTextures : NPCManager.femaleNordTextures; break; case Races.Breton: default: textures = (marker.mobileNPC.Gender == Genders.Male) ? NPCManager.maleBretonTextures : NPCManager.femaleBretonTextures; break; } } npcTempTexture = ImageReader.GetTexture("TEXTURE." + textures[marker.mobileNPC.PersonOutfitVariant], 5, 0, true, 0); npcIconTexture = npcTempTexture; marker.npcMarkerColor = Color.green; marker.markerType = Minimap.MarkerGroups.Friendlies; marker.markerObject.SetActive(false); marker.markerObject.name = marker.markerObject.name + " " + marker.mobileNPC.NameNPC; } //if enemy npc present, setup flat npc marker color, type, and activate marker object so iit shows on minimap. else if (marker.mobileEnemy != null) { // Monster genders are always unspecified as there is no male/female variant if (marker.mobileEnemy.MobileUnit.Summary.Enemy.Gender == MobileGender.Male || marker.mobileEnemy.MobileUnit.Summary.Enemy.Gender == MobileGender.Unspecified) { npcTempTexture = ImageReader.GetTexture(string.Concat("TEXTURE.", marker.mobileEnemy.MobileUnit.Summary.Enemy.MaleTexture), 0, 0, true, 0); } else { npcTempTexture = ImageReader.GetTexture(string.Concat("TEXTURE.", marker.mobileEnemy.MobileUnit.Summary.Enemy.FemaleTexture), 0, 0, true, 0); } npcIconTexture = npcTempTexture; marker.npcMarkerColor = Color.red; marker.markerType = Minimap.MarkerGroups.Enemies; marker.markerObject.SetActive(false); marker.enemySenses = GetComponentInParent <DaggerfallEnemy>().GetComponent <EnemySenses>(); } //if static npc present, setup flat npc marker color, type, and activate marker object so iit shows on minimap. else if (marker.flatNPC != null) { DaggerfallBillboard flatBillboard = GetComponentInParent <DaggerfallBillboard>(); marker.npcMarkerColor = Color.yellow; npcTempTexture = ImageReader.GetTexture("TEXTURE." + flatBillboard.Summary.Archive, flatBillboard.Summary.Record, 0, true, 0); npcIconTexture = npcTempTexture; marker.markerType = Minimap.MarkerGroups.Resident; marker.markerObject.SetActive(false); } else { marker.isActive = false; } marker.npcMesh.material.color = marker.npcMarkerColor; }
/// <summary> /// Add misc block flats. /// Batching is conditionally supported. /// </summary> public static void AddMiscBlockFlats( ref DFBlock blockData, Transform flatsParent, DaggerfallBillboardBatch animalsBillboardBatch = null, TextureAtlasBuilder miscBillboardsAtlas = null, DaggerfallBillboardBatch miscBillboardsBatch = null) { DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return; } // Add block flats foreach (DFBlock.RmbBlockFlatObjectRecord obj in blockData.RmbBlock.MiscFlatObjectRecords) { // Ignore lights as they are handled by AddLights() if (obj.TextureArchive == TextureReader.LightsTextureArchive) { continue; } // Calculate position Vector3 billboardPosition = new Vector3( obj.XPos, -obj.YPos + blockFlatsOffsetY, obj.ZPos + BlocksFile.RMBDimension) * MeshReader.GlobalScale; // Import custom 3d gameobject instead of flat if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, flatsParent) != null) { continue; } //// Use misc billboard atlas where available //if (miscBillboardsAtlas != null && miscBillboardsBatch != null) //{ // TextureAtlasBuilder.AtlasItem item = miscBillboardsAtlas.GetAtlasItem(obj.TextureArchive, obj.TextureRecord); // if (item.key != -1) // { // miscBillboardsBatch.AddItem(item.rect, item.textureItem.size, item.textureItem.scale, billboardPosition); // continue; // } //} // Add to batch where available //if (obj.TextureArchive == TextureReader.AnimalsTextureArchive && animalsBillboardBatch != null) //{ // animalsBillboardBatch.AddItem(obj.TextureRecord, billboardPosition); // continue; //} // Add standalone billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, flatsParent); go.transform.position = billboardPosition; AlignBillboardToBase(go); // Add animal sound if (obj.TextureArchive == TextureReader.AnimalsTextureArchive) { AddAnimalAudioSource(go); } // If flat record has a non-zero faction id, then it's an exterior NPC if (obj.FactionID != 0) { // Add RMB data to billboard DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetRMBPeopleData(obj.FactionID, obj.Flags, obj.Position); // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj); } } }