private static void PlaceHorse(bool fromSave = false) { if (fromSave == false) { HorseMapPixel = GameManager.Instance.PlayerGPS.CurrentMapPixel; SetHorsePositionAndRotation(); } else { PlaceHorseOnGround(); } //GameObject HorseBill = MeshReplacement.ImportCustomFlatGameobject(538, 1, HorsePosition, null); Horse = GameObjectHelper.CreateDaggerfallBillboardGameObject(201, 0, null); Horse.transform.SetPositionAndRotation(HorsePosition, HorseRotation); if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon) { Horse.SetActive(false); } else { Horse.SetActive(true); } AddHorseAudioSource(Horse); HorseDeployed = true; }
public void Die() { if (!mobile) { return; } // Get corpse marker texture indices int archive, record; EnemyBasics.ReverseCorpseTexture(mobile.Summary.Enemy.CorpseTexture, out archive, out record); // Leave corpse marker DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (dfUnity) { // Spawn marker GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, transform.parent, true); go.transform.position = transform.position; // Align to ground. Be generous with distance as flying enemies might have a way to drop. // This could also be hanlded by adding a Rigidbody and collider then let gravity do the work. GameObjectHelper.AlignBillboardToGround(go, go.GetComponent <DaggerfallBillboard>().Summary.Size, 16f); } // Disable enemy gameobject and schedule for destruction gameObject.SetActive(false); GameObject.Destroy(gameObject); }
/// <summary> /// Add interior flats. /// </summary> private void AddFlats() { GameObject node = new GameObject("Interior Flats"); node.transform.parent = this.transform; // Add block flats markers.Clear(); foreach (DFBlock.RmbBlockFlatObjectRecord obj in recordData.Interior.BlockFlatObjectRecords) { // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform); // Set position DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); go.transform.position = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0); // Add to enter marker list, which is TEXTURE.199, index 8. // Sometimes marker 199.4 is used where the 199.8 enter marker should be // Being a little forgiving and also accepting 199.4 as enter marker // Will add more of these cases if I find them if (obj.TextureArchive == TextureReader.EditorFlatsTextureArchive && (obj.TextureRecord == 8 || obj.TextureRecord == 4)) { markers.Add(go); } // Add point lights if (obj.TextureArchive == TextureReader.LightsTextureArchive) { AddLight(obj, go.transform); } } }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople() { GameObject node = new GameObject("People Flats"); node.transform.parent = this.transform; // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Calculate position Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Import 3D character instead of billboard 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 RMB data to billboard dfBillboard.SetRMBPeopleData(obj); // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj); } }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData) { GameObject node = new GameObject("People Flats"); node.transform.parent = this.transform; bool isMemberOfBuildingGuild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID).IsMember(); // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Calculate position Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Import 3D character instead of billboard 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 RMB data to billboard dfBillboard.SetRMBPeopleData(obj); // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj, entryDoor.buildingKey); // Disable people if shop or building is closed DFLocation.BuildingTypes buildingType = buildingData.buildingType; if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) || (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) && !PlayerActivate.IsBuildingOpen(buildingType))) { go.SetActive(false); } // Disable people if player owns this house else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey)) { go.SetActive(false); } // Disable people if this is TG/DB house and player is not a member else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild) { go.SetActive(false); } // Disable people if they are TG spymaster, but not in a legit TG house (TODO: spot any other instances for TG/DB) else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID == 0 && npc.Data.factionID == (int)GuildNpcServices.TG_Spymaster) { go.SetActive(false); } } }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData) { GameObject node = new GameObject(peopleFlats); node.transform.parent = this.transform; IGuild guild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID); bool isMemberOfBuildingGuild = guild.IsMember(); // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Calculate position Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; // Make person gameobject GameObject go = MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform); if (!go) { // Spawn billboard 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 RMB data to billboard dfBillboard.SetRMBPeopleData(obj); } // Add StaticNPC behaviour StaticNPC npc = go.AddComponent <StaticNPC>(); npc.SetLayoutData(obj, entryDoor.buildingKey); // Disable people if shop or building is closed DFLocation.BuildingTypes buildingType = buildingData.buildingType; if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) || (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) && !(PlayerActivate.IsBuildingOpen(buildingType) || buildingType == DFLocation.BuildingTypes.GuildHall && guild.HallAccessAnytime()))) { go.SetActive(false); } // Disable people if player owns this house else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey)) { go.SetActive(false); } // Disable people if this is TG/DB house and player is not a member else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild) { go.SetActive(false); } } }
private void Start() { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(candleArchive, candleRecord, transform); go.transform.localPosition = Vector3.zero; startLocalPosition = transform.localPosition; lastOffsetPosition = startLocalPosition; SaveLoadManager.OnStartLoad += SaveLoadManager_OnStartLoad; StartGameBehaviour.OnNewGame += StartGameBehaviour_OnNewGame; }
/// <summary> /// Add interior people flats. /// </summary> private void AddPeople() { GameObject node = new GameObject("People Flats"); node.transform.parent = this.transform; // Add block flats foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords) { // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform); go.transform.position = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; } }
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; } }
private void Start() { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(candleArchive, candleRecord, transform); go.transform.localPosition = Vector3.zero; startLocalPosition = transform.localPosition; lastOffsetPosition = startLocalPosition; SaveLoadManager.OnStartLoad += SaveLoadManager_OnStartLoad; StartGameBehaviour.OnNewGame += StartGameBehaviour_OnNewGame; // Observe spell shadow setting GetComponent <Light>().shadows = (DaggerfallUnity.Settings.EnableSpellShadows) ? LightShadows.Soft : LightShadows.None; }
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; } }
public void PlaceCorpseMarker(int corpseTexture) { // Get corpse marker texture indices int archive, record; EnemyBasics.ReverseCorpseTexture(corpseTexture, out archive, out record); // Spawn corpse marker GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, transform.parent, true); go.transform.position = transform.position; // Align to ground. Be generous with distance as flying enemies might have a way to drop. // This could also be handled by adding a Rigidbody and collider then let gravity do the work. // TODO: Ensure corpse markers never land on top of other monsters GameObjectHelper.AlignBillboardToGround(go, go.GetComponent <DaggerfallBillboard>().Summary.Size, 16f); }
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); }
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 AddFlatObject(DFBlock.RdbObject obj) { int archive = obj.Resources.FlatResource.TextureArchive; int record = obj.Resources.FlatResource.TextureRecord; // Add GameObject to scene Vector3 targetPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale; GameObject go = MeshReplacement.ImportCustomFlatGameobject(archive, record, targetPosition, null, true); if (!go) { // Setup standard billboard and assign RDB data go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, null); go.transform.position = targetPosition; Billboard dfBillboard = go.GetComponent <Billboard>(); dfBillboard.SetRDBResourceData(obj.Resources.FlatResource); } return(go); }
public static void DeployTent(bool fromSave = false) { if (fromSave == false) { CampMapPixel = GameManager.Instance.PlayerGPS.CurrentMapPixel; SetTentPositionAndRotation(); DaggerfallUI.MessageBox("You set up camp"); } else { PlaceTentOnGround(); } //Attempt to load a model replacement Tent = MeshReplacement.ImportCustomGameobject(tentModelID, null, TentMatrix); Fire = GameObjectHelper.CreateDaggerfallBillboardGameObject(210, 1, null); if (Tent == null) { Tent = GameObjectHelper.CreateDaggerfallMeshGameObject(tentModelID, null); } //Set the model's position in the world Tent.transform.SetPositionAndRotation(TentPosition, TentRotation); if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon) { FirePosition = Tent.transform.position + (Tent.transform.up * 0.8f); Tent.SetActive(false); } else { FirePosition = Tent.transform.position + (Tent.transform.forward * 3) + (Tent.transform.up * 0.8f); Tent.SetActive(true); } Fire.transform.SetPositionAndRotation(FirePosition, TentRotation); Fire.SetActive(true); AddTorchAudioSource(Fire); GameObject lightsNode = new GameObject("Lights"); lightsNode.transform.parent = Fire.transform; AddLight(DaggerfallUnity.Instance, Fire, lightsNode.transform); CampDeployed = true; FireLit = true; }
/// <summary> /// Add interior flats. /// </summary> private void AddFlats() { 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 point lights if (obj.TextureArchive == TextureReader.LightsTextureArchive) { AddLight(obj, go.transform); } } }
/// <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); } } }
public static GameObject CreatePlacedObject(PlacedObjectData_v2 data, Transform parent, bool previewGo = false) { // Custom models like Handpainted Models have insanley different scales (< 0.0 to 200+) Set all models as a child to a parent, so // EditMode can uniformly scale properly. GameObject parentGo = new GameObject(); GameObject childGo; parentGo.transform.parent = parent; if (data.modelID == 0) { childGo = MeshReplacement.ImportCustomFlatGameobject(data.archive, data.record, Vector3.zero, parentGo.transform); if (childGo == null) { childGo = GameObjectHelper.CreateDaggerfallBillboardGameObject(data.archive, data.record, parentGo.transform); } } else { Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one); childGo = MeshReplacement.ImportCustomGameobject(data.modelID, parentGo.transform, matrix); if (childGo == null) { childGo = GameObjectHelper.CreateDaggerfallMeshGameObject(data.modelID, parentGo.transform); } } parentGo.transform.eulerAngles = Vector3.zero; childGo.transform.eulerAngles = Vector3.zero; if (previewGo) { data.isLight = true; } BoxCollider parentCollider = parentGo.AddComponent <BoxCollider>(); BoxCollider childCollider; //Expanding collider a little gives better hit detection. float buffer = 0.02f; // Some custom models have a box collider and are made of multiple smaller models. Get the parent collider size. if (childCollider = childGo.GetComponent <BoxCollider>()) { parentCollider.size = new Vector3((childCollider.size.x * childGo.transform.localScale.x) + buffer, (childCollider.size.y * childGo.transform.localScale.y) + buffer, (childCollider.size.z * childGo.transform.localScale.z) + buffer); parentCollider.center = new Vector3(childCollider.center.x * childGo.transform.localScale.x, childCollider.center.y * childGo.transform.localScale.y, childCollider.center.z * childGo.transform.localScale.z); // Child colliders screw with EditMode. GameObject.Destroy(childCollider); } else { Bounds childBounds = childGo.GetComponent <MeshFilter>().sharedMesh.bounds; parentCollider.size = new Vector3((childBounds.size.x * childGo.transform.localScale.x) + buffer, (childBounds.size.y * childGo.transform.localScale.y) + buffer, (childBounds.size.z * childGo.transform.localScale.z) + buffer); parentCollider.center = new Vector3(childBounds.center.x * childGo.transform.localScale.x, childBounds.center.y * childGo.transform.localScale.y, childBounds.center.z * childGo.transform.localScale.z); } parentCollider.isTrigger = true; parentGo.AddComponent <PlacedObject>(); SetPlacedObject(data, parentGo); return(parentGo); }