void ProcessExtraData(SiObject obj, out bool shouldAddMissingColliders, out bool isMarker) { shouldAddMissingColliders = true; isMarker = false; if (obj is SiObjectNET objNET) { var extraData = !objNET.ExtraData.IsNull ? (SiExtraData)_file.Blocks[objNET.ExtraData.Value] : null; while (extraData != null) { if (extraData is SiStringExtraData strExtraData) { if (strExtraData.Str == "NCO" || strExtraData.Str == "NCC") { shouldAddMissingColliders = false; } else if (strExtraData.Str == "MRK") { shouldAddMissingColliders = false; isMarker = true; } } // Move to the next NiExtraData. if (!extraData.NextExtraData.IsNull) { extraData = (SiExtraData)_file.Blocks[extraData.NextExtraData.Value]; } else { extraData = null; } } } }
void AddColliderFromSiObject(SiObject siObject, GameObject gameObject) { if (siObject.GetType() == typeof(SiTriShape)) { var colliderObj = InstantiateSiTriShape((SiTriShape)siObject, false, true); colliderObj.transform.SetParent(gameObject.transform, false); } else if (siObject.GetType() == typeof(AvoidNode)) { } else { Log($"Unsupported collider SiObject: {siObject.GetType().Name}"); } }
void GmpBlocks(string filePath, short itemId) { _asset.GetGumpDimensions(itemId, out int width, out int height); Name = filePath; Blocks = new SiObject[] { new SiPrimitive { Type = PrimitiveType.Cube, Name = Name, Properties = new[] { new Ref <SiProperty>(1) }, Width = width / ConvertUtils.MeterInUnits, Height = height / ConvertUtils.MeterInUnits }, new SiTexturingProperty { TextureCount = 1, BaseTexture = new TexDesc { Source = new Ref <SiSourceTexture>(2) } }, new SiSourceTexture { FilePath = filePath }, }; }
/// <summary> /// Creates a GameObject representation of an NiObject. /// </summary> /// <returns>Returns the created GameObject, or null if the NiObject does not need its own GameObject.</returns> GameObject InstantiateSiObject(SiObject obj) { if (obj.GetType() == typeof(SiNode)) { return(InstantiateSiNode((SiNode)obj)); } else if (obj.GetType() == typeof(SiPrimitive)) { return(InstantiateSiPrimitive((SiPrimitive)obj, true, false)); } else if (obj.GetType() == typeof(SiTriShape)) { return(InstantiateSiTriShape((SiTriShape)obj, true, false)); } else { throw new NotImplementedException($"Tried to instantiate an unsupported SiObject ({obj.GetType().Name})."); } }
void StaBlocks(string filePath, short itemId) { var itemData = TileData.ItemData[itemId]; Name = filePath + " " + itemData.Name; Blocks = new SiObject[] { new SiPrimitive { Type = PrimitiveType.Cube, Name = Name, Properties = new[] { new Ref <SiProperty>(1) }, Width = 1, Height = itemData.CalcHeight / ConvertUtils.MeterInUnits }, new SiTexturingProperty { TextureCount = 1, BaseTexture = new TexDesc { Source = new Ref <SiSourceTexture>(2) } }, new SiSourceTexture { FilePath = filePath }, }; }
void LndBlocks(string filePath, short itemId) { var landData = TileData.LandData[itemId]; Name = filePath + " " + landData.Name; Blocks = new SiObject[] { new SiPrimitive { Type = PrimitiveType.Cube, Name = Name, Properties = new[] { new Ref <SiProperty>(1) }, Width = 1, Height = 0.01F }, new SiTexturingProperty { TextureCount = 1, BaseTexture = new TexDesc { Source = new Ref <SiSourceTexture>(2) } }, new SiSourceTexture { FilePath = filePath }, }; }
GameObject InstantiateRootSiObject(SiObject obj) { var gameObject = InstantiateSiObject(obj); ProcessExtraData(obj, out bool shouldAddMissingColliders, out bool isMarker); if (_file.Name != null && IsMarkerFileName(_file.Name)) { shouldAddMissingColliders = false; isMarker = true; } // Add colliders to the object if it doesn't already contain one. if (shouldAddMissingColliders && gameObject.GetComponentInChildren <Collider>() == null) { GameObjectUtils.AddMissingMeshCollidersRecursively(gameObject); } if (isMarker) { GameObjectUtils.SetLayerRecursively(gameObject, _markerLayer); } return(gameObject); }