public override void WriteData(ESPWriter writer) { if (EditorID != null) { EditorID.WriteBinary(writer); } if (Model != null) { Model.WriteBinary(writer); } if (Data != null) { Data.WriteBinary(writer); } if (DecalData != null) { DecalData.WriteBinary(writer); } if (TextureSet != null) { TextureSet.WriteBinary(writer); } if (Sound1 != null) { Sound1.WriteBinary(writer); } if (Sound2 != null) { Sound2.WriteBinary(writer); } }
/// <summary> /// CreateBloodDecal is used to create blood decal. /// This method should be called by receive damage behavior when receiving damage. /// Center = the position of the object which attempts to create the decal. But, if DecalData /// </summary> /// <param name="center"></param> /// <param name="DecalData"></param> public static void CreateBloodDecal(Vector3 center, DecalData _DecalData) { //create predefine global decal if (_DecalData.UseGlobalDecal) { GlobalDecalData globalDecalData = Instance.GlobalDecalDataDict[_DecalData.GlobalType]; if (globalDecalData.Decal_OnGround.Length > 0) { Instance.StartCoroutine(Instance.CreateGlobalDecalOnGround(center, globalDecalData, _DecalData)); } if (globalDecalData.Decal_OnWall.Length > 0) { Instance.StartCoroutine(Instance.CreateGlobalDecalOnWall(center, globalDecalData, _DecalData));; } } //Create custom decal defined by Unit else { switch (_DecalData.ProjectDirection) { //Create decal on ground case HorizontalOrVertical.Vertical: Instance.StartCoroutine(Instance.CreateDecalOnGround(center, _DecalData)); break; //Create decal on wall case HorizontalOrVertical.Horizontal: Instance.StartCoroutine(Instance.CreateBloodDecalOnWall(center, _DecalData)); break; } } }
/// <summary> /// CreateBloodDecal is used to create blood decal. /// This method should be called by receive damage behavior when receiving damage. /// Center = the position of the object which attempts to create the decal. But, if DecalData /// </summary> /// <param name="center"></param> /// <param name="DecalData"></param> public static void CreateBloodDecal(Vector3 center, DecalData _DecalData) { //create predefine global decal if (_DecalData.UseGlobalDecal) { GlobalDecalData globalDecalData = Instance.GlobalDecalDataDict[_DecalData.GlobalType]; if(globalDecalData.Decal_OnGround.Length > 0) { Instance.StartCoroutine(Instance.CreateGlobalDecalOnGround(center, globalDecalData, _DecalData)); } if(globalDecalData.Decal_OnWall.Length > 0) { Instance.StartCoroutine(Instance.CreateGlobalDecalOnWall(center, globalDecalData, _DecalData));; } } //Create custom decal defined by Unit else { switch (_DecalData.ProjectDirection) { //Create decal on ground case HorizontalOrVertical.Vertical: Instance.StartCoroutine(Instance.CreateDecalOnGround(center, _DecalData)); break; //Create decal on wall case HorizontalOrVertical.Horizontal: Instance.StartCoroutine(Instance.CreateBloodDecalOnWall(center, _DecalData)); break; } } }
IEnumerator CreateBloodDecalOnWall(Vector3 Center, DecalData _DecalData) { if (_DecalData.CreateDelay > 0) { yield return(new WaitForSeconds(_DecalData.CreateDelay)); } float Radius = 2; //check front/back/right/left direction if there's a collision: Collider[] wallColliders = Physics.OverlapSphere(Center, Radius, _DecalData.ApplicableLayer); if (wallColliders != null && wallColliders.Length > 0) { Collider wall = wallColliders[0]; Vector3 closestPoints = wall.ClosestPointOnBounds(Center); closestPoints.y += Random.Range(0.1f, 0.5f); //Randomize the point closestPoints += Random.onUnitSphere * 1; RaycastHit hitInfo; if (Physics.Raycast(Center, closestPoints - Center, out hitInfo, 20, _DecalData.ApplicableLayer)) { Object decalObjectPrototype = Util.RandomFromArray <Object>(_DecalData.DecalObjects); GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectPrototype, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= _DecalData.ScaleRate; if (_DecalData.DestoryInTimeOut) { Destroy(DecalObject, _DecalData.DestoryTimeOut); } } } }
public void CloneTo(Unit unit) { base.CloneTo(unit as UnitBase); //copy character controller CharacterController cc = unit.gameObject.AddComponent <CharacterController> (); cc.center = this.GetComponent <CharacterController> ().center; cc.radius = this.GetComponent <CharacterController> ().radius; cc.height = this.GetComponent <CharacterController> ().height; //copy animation foreach (AnimationState ani in this.animation) { AnimationClip clip = ani.clip; unit.animation.AddClip(clip, ani.name); } //copy idledata foreach (IdleData idleData in this.IdleData) { IdleData clone = idleData.GetClone(); unit.IdleData = Util.AddToArray <IdleData> (clone, unit.IdleData); } //copy movedata foreach (MoveData moveData in this.MoveData) { MoveData clone = moveData.GetClone(); unit.MoveData = Util.AddToArray <MoveData> (clone, unit.MoveData); } //copy attackdata foreach (AttackData attackData in this.AttackData) { AttackData clone = attackData.GetClone(); unit.AttackData = Util.AddToArray <AttackData> (clone, unit.AttackData); } //copy ReceiveDamageData foreach (ReceiveDamageData receiveDamageData in this.ReceiveDamageData) { ReceiveDamageData clone = receiveDamageData.GetClone(); unit.ReceiveDamageData = Util.AddToArray <ReceiveDamageData> (clone, unit.ReceiveDamageData); } //copy DeathData foreach (DeathData deathData in this.DeathData) { DeathData clone = deathData.GetClone(); unit.DeathData = Util.AddToArray <DeathData> (clone, unit.DeathData); } //copy AudioData foreach (AudioData audioData in this.AudioData) { AudioData clone = audioData.GetClone(); unit.AudioData = Util.AddToArray <AudioData> (clone, unit.AudioData); } //copy DecalData foreach (DecalData decalData in this.DecalData) { DecalData clone = decalData.GetClone(); unit.DecalData = Util.AddToArray <DecalData> (clone, unit.DecalData); } }
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (EditorID != null) { ele.TryPathTo("EditorID", true, out subEle); EditorID.WriteXML(subEle, master); } if (ObjectBounds != null) { ele.TryPathTo("ObjectBounds", true, out subEle); ObjectBounds.WriteXML(subEle, master); } if (BaseImage_Transparency != null) { ele.TryPathTo("BaseImage_Transparency", true, out subEle); BaseImage_Transparency.WriteXML(subEle, master); } if (NormalMap_Specular != null) { ele.TryPathTo("NormalMap_Specular", true, out subEle); NormalMap_Specular.WriteXML(subEle, master); } if (EnvironmentMapMask != null) { ele.TryPathTo("EnvironmentMapMask", true, out subEle); EnvironmentMapMask.WriteXML(subEle, master); } if (GlowMap != null) { ele.TryPathTo("GlowMap", true, out subEle); GlowMap.WriteXML(subEle, master); } if (ParallaxMap != null) { ele.TryPathTo("ParallaxMap", true, out subEle); ParallaxMap.WriteXML(subEle, master); } if (EnvironmentMap != null) { ele.TryPathTo("EnvironmentMap", true, out subEle); EnvironmentMap.WriteXML(subEle, master); } if (DecalData != null) { ele.TryPathTo("DecalData", true, out subEle); DecalData.WriteXML(subEle, master); } if (TextureSetFlags != null) { ele.TryPathTo("TextureSetFlags", true, out subEle); TextureSetFlags.WriteXML(subEle, master); } }
public DecalData GetClone() { DecalData clone = new DecalData(); clone.Name = this.Name; clone.UseGlobalDecal = this.UseGlobalDecal; clone.GlobalType = this.GlobalType; clone.DecalObjects = Util.CloneArray <Object>(this.DecalObjects); clone.ProjectDirection = this.ProjectDirection; clone.DestoryInTimeOut = this.DestoryInTimeOut; clone.DestoryTimeOut = this.DestoryTimeOut; clone.ScaleRate = this.ScaleRate; clone.ApplicableLayer = this.ApplicableLayer; return(clone); }
public virtual void EditDecalData() { EnableEditDecalData = EditorGUILayout.BeginToggleGroup("---Edit Decal Data", EnableEditDecalData); if (EnableEditDecalData) { if (GUILayout.Button("Add Decal data")) { DecalData DecalData = new DecalData(); IList <DecalData> l = selectedRagdoll.DecalData.ToList <DecalData> (); l.Add(DecalData); selectedRagdoll.DecalData = l.ToArray <DecalData> (); } for (int i = 0; i < selectedRagdoll.DecalData.Length; i++) { DecalData DecalData = selectedRagdoll.DecalData [i]; EditorGUILayout.LabelField("------------------------ " + DecalData.Name); DecalData.Name = EditorGUILayout.TextField(new GUIContent("Name", ""), DecalData.Name); DecalData.UseGlobalDecal = EditorGUILayout.Toggle(new GUIContent("UseGlobalDecal?", "使用全局Decal设定?"), DecalData.UseGlobalDecal); if (DecalData.UseGlobalDecal) { DecalData.GlobalType = (GlobalDecalType)EditorGUILayout.EnumPopup(new GUIContent("Global decal type:", ""), DecalData.GlobalType); } else { DecalData.DestoryInTimeOut = EditorGUILayout.Toggle(new GUIContent("Destory this decal in timeout?", "Decal是否有Lifetime?"), DecalData.DestoryInTimeOut); if (DecalData.DestoryInTimeOut) { DecalData.DestoryTimeOut = EditorGUILayout.FloatField(new GUIContent("Destory Timeout:", ""), DecalData.DestoryTimeOut); } DecalData.ProjectDirection = (HorizontalOrVertical)EditorGUILayout.EnumPopup(new GUIContent("Decal Project Direction", "创建Decal的投射方向,对于地上的Decal,投射方向是Vertical,对于墙上的Decal,投射方向是Horizontal."), DecalData.ProjectDirection); DecalData.ApplicableLayer = EditorGUILayoutx.LayerMaskField("ApplicableLayer", DecalData.ApplicableLayer); DecalData.DecalObjects = AIEditor.EditObjectArray("--------------Edit Decal object ------", DecalData.DecalObjects); DecalData.ScaleRate = EditorGUILayout.FloatField(new GUIContent("Scale rate:", "Final scale = initial scale * ScaleRate"), DecalData.ScaleRate); //Delete this DecalData if (GUILayout.Button("Delete DecalData:" + DecalData.Name)) { IList <DecalData> l = selectedRagdoll.DecalData.ToList <DecalData> (); l.Remove(DecalData); selectedRagdoll.DecalData = l.ToArray <DecalData> (); } } EditorGUILayout.Space(); } } EditorGUILayout.EndToggleGroup(); }
public override void WriteData(ESPWriter writer) { if (EditorID != null) { EditorID.WriteBinary(writer); } if (ObjectBounds != null) { ObjectBounds.WriteBinary(writer); } if (BaseImage_Transparency != null) { BaseImage_Transparency.WriteBinary(writer); } if (NormalMap_Specular != null) { NormalMap_Specular.WriteBinary(writer); } if (EnvironmentMapMask != null) { EnvironmentMapMask.WriteBinary(writer); } if (GlowMap != null) { GlowMap.WriteBinary(writer); } if (ParallaxMap != null) { ParallaxMap.WriteBinary(writer); } if (EnvironmentMap != null) { EnvironmentMap.WriteBinary(writer); } if (DecalData != null) { DecalData.WriteBinary(writer); } if (TextureSetFlags != null) { TextureSetFlags.WriteBinary(writer); } }
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (EditorID != null) { ele.TryPathTo("EditorID", true, out subEle); EditorID.WriteXML(subEle, master); } if (Model != null) { ele.TryPathTo("Model", true, out subEle); Model.WriteXML(subEle, master); } if (Data != null) { ele.TryPathTo("Data", true, out subEle); Data.WriteXML(subEle, master); } if (DecalData != null) { ele.TryPathTo("DecalData", true, out subEle); DecalData.WriteXML(subEle, master); } if (TextureSet != null) { ele.TryPathTo("TextureSet", true, out subEle); TextureSet.WriteXML(subEle, master); } if (Sound1 != null) { ele.TryPathTo("Sound1", true, out subEle); Sound1.WriteXML(subEle, master); } if (Sound2 != null) { ele.TryPathTo("Sound2", true, out subEle); Sound2.WriteXML(subEle, master); } }
private static void ValidateDecal1(DecalData data) { Assert.Equal(true, data.Backglass); Assert.Equal(509f, data.Center.X); Assert.Equal(354f, data.Center.Y); Assert.Equal(216, data.Color.Red); Assert.Equal(63, data.Color.Green); Assert.Equal(204, data.Color.Blue); Assert.Equal(DecalType.DecalText, data.DecalType); Assert.Equal("Fixedsys", data.Font.Name); Assert.Equal(100f, data.Height); Assert.Equal("", data.Image); Assert.Equal("", data.Material); Assert.Equal(0f, data.Rotation); Assert.Equal(SizingType.ManualSize, data.SizingType); Assert.Equal("", data.Surface); Assert.Equal("My Decal Text", data.Text); Assert.Equal(true, data.VerticalText); Assert.Equal(100f, data.Width); Assert.Equal(0, data.EditorLayer); Assert.Equal(true, data.IsLocked); }
private static void ValidateDecal0(DecalData data) { Assert.Equal(false, data.Backglass); Assert.Equal(205.4f, data.Center.X); Assert.Equal(540.68f, data.Center.Y); Assert.Equal(60, data.Color.Red); Assert.Equal(217, data.Color.Green); Assert.Equal(142, data.Color.Blue); Assert.Equal(DecalType.DecalImage, data.DecalType); Assert.Equal("Arial Black", data.Font.Name); Assert.Equal(32.5f, data.Height); Assert.Equal("tex_transparent", data.Image); Assert.Equal("DecalMat", data.Material); Assert.Equal(45.98f, data.Rotation); Assert.Equal(SizingType.AutoWidth, data.SizingType); Assert.Equal("", data.Surface); Assert.Equal("", data.Text); Assert.Equal(false, data.VerticalText); Assert.Equal(66.1165f, data.Width); Assert.Equal(2, data.EditorLayer); Assert.Equal(false, data.IsLocked); }
void OnEnable() { // Set data m_Target = target as DecalData; if (!m_Target.isImported) { return; } // Get Properties m_PoolingEnabledProp = serializedObject.FindProperty(PropertyNames.PoolingEnabled); m_InstanceCountProp = serializedObject.FindProperty(PropertyNames.InstanceCount); m_DepthProp = serializedObject.FindProperty(PropertyNames.Depth); m_DepthFalloffProp = serializedObject.FindProperty(PropertyNames.DepthFalloff); m_AngleProp = serializedObject.FindProperty(PropertyNames.Angle); m_AngleFalloffProp = serializedObject.FindProperty(PropertyNames.AngleFalloff); m_LayerMaskProp = serializedObject.FindProperty(PropertyNames.LayerMask); m_SortingOrderProp = serializedObject.FindProperty(PropertyNames.SortingOrder); // Create Editors m_MaterialEditor = Editor.CreateEditor(m_Target.material) as MaterialEditor; }
public virtual void EditDecalData() { EnableEditDecalData = EditorGUILayout.BeginToggleGroup ("---Edit Decal Data", EnableEditDecalData); if (EnableEditDecalData) { if (GUILayout.Button ("Add Decal data")) { DecalData DecalData = new DecalData (); IList<DecalData> l = selectedRagdoll.DecalData.ToList<DecalData> (); l.Add (DecalData); selectedRagdoll.DecalData = l.ToArray<DecalData> (); } for (int i = 0; i < selectedRagdoll.DecalData.Length; i++) { DecalData DecalData = selectedRagdoll.DecalData [i]; EditorGUILayout.LabelField ("------------------------ " + DecalData.Name); DecalData.Name = EditorGUILayout.TextField (new GUIContent ("Name", ""), DecalData.Name); DecalData.UseGlobalDecal = EditorGUILayout.Toggle (new GUIContent ("UseGlobalDecal?", "使用全局Decal设定?"), DecalData.UseGlobalDecal); if (DecalData.UseGlobalDecal) { DecalData.GlobalType = (GlobalDecalType)EditorGUILayout.EnumPopup (new GUIContent ("Global decal type:", ""), DecalData.GlobalType); } else { DecalData.DestoryInTimeOut = EditorGUILayout.Toggle (new GUIContent ("Destory this decal in timeout?", "Decal是否有Lifetime?"), DecalData.DestoryInTimeOut); if (DecalData.DestoryInTimeOut) { DecalData.DestoryTimeOut = EditorGUILayout.FloatField (new GUIContent ("Destory Timeout:", ""), DecalData.DestoryTimeOut); } DecalData.ProjectDirection = (HorizontalOrVertical)EditorGUILayout.EnumPopup (new GUIContent ("Decal Project Direction", "创建Decal的投射方向,对于地上的Decal,投射方向是Vertical,对于墙上的Decal,投射方向是Horizontal."), DecalData.ProjectDirection); DecalData.ApplicableLayer = EditorGUILayoutx.LayerMaskField ("ApplicableLayer", DecalData.ApplicableLayer); DecalData.DecalObjects = AIEditor.EditObjectArray ("--------------Edit Decal object ------", DecalData.DecalObjects); DecalData.ScaleRate = EditorGUILayout.FloatField (new GUIContent ("Scale rate:", "Final scale = initial scale * ScaleRate"), DecalData.ScaleRate); //Delete this DecalData if (GUILayout.Button ("Delete DecalData:" + DecalData.Name)) { IList<DecalData> l = selectedRagdoll.DecalData.ToList<DecalData> (); l.Remove (DecalData); selectedRagdoll.DecalData = l.ToArray<DecalData> (); } } EditorGUILayout.Space (); } } EditorGUILayout.EndToggleGroup (); }
private void DrawStructBuffer(int visibleCount) { NativeArray <DecalData> bufferData = new NativeArray <DecalData>(visibleCount, Allocator.Temp); for (int i = 0; i < visibleCount; i++) { DecalData _data = new DecalData(); _data.worldToLocal = decalDrawData.visibleDecalRenderers[i].transform.worldToLocalMatrix; _data.alpha = decalDrawData.visibleDecalRenderers[i].alpha; _data.normalIntensity = decalDrawData.visibleDecalRenderers[i].normalIntensity; _data.uv = decalDrawData.visibleDecalRenderers[i].uv; _data.tiling = decalDrawData.visibleDecalRenderers[i].tiling; bufferData[i] = _data; } var decalDatasBuffer = rendererFeatures.bufferCache.Alloc <DecalData>("g_AdditiveDecalDatasBuffer", visibleCount); decalDatasBuffer.SetData(bufferData, 0, 0, visibleCount); _cb.SetGlobalBuffer("g_AdditiveDecalDatasBuffer", decalDatasBuffer); _cb.SetGlobalInt(_AdditiveDecalCountId, visibleCount); bufferData.Dispose(); }
private static void ValidateDecal0(DecalData data) { data.Backglass.Should().Be(false); data.Center.X.Should().Be(205.4f); data.Center.Y.Should().Be(540.68f); data.Color.Red.Should().Be(60); data.Color.Green.Should().Be(217); data.Color.Blue.Should().Be(142); data.DecalType.Should().Be(DecalType.DecalImage); data.Font.Name.Should().Be("Arial Black"); data.Height.Should().Be(32.5f); data.Image.Should().Be("tex_transparent"); data.Material.Should().Be("DecalMat"); data.Rotation.Should().Be(45.98f); data.SizingType.Should().Be(SizingType.AutoWidth); data.Surface.Should().Be(""); data.Text.Should().Be(""); data.VerticalText.Should().Be(false); data.Width.Should().Be(66.1165f); data.EditorLayer.Should().Be(2); data.EditorLayerName.Should().Be(string.Empty); data.EditorLayerVisibility.Should().Be(true); data.IsLocked.Should().Be(false); }
IEnumerator CreateDecalOnGround(Vector3 Center, DecalData _DecalData) { if (_DecalData.CreateDelay > 0) { yield return(new WaitForSeconds(_DecalData.CreateDelay)); } float Radius = 1; Vector2 randomFromCircle = Random.insideUnitCircle; randomFromCircle *= Radius; Vector3 random = Vector3.zero; if (_DecalData.OnTransform != null) { random = new Vector3(_DecalData.OnTransform.position.x + randomFromCircle.x, Center.y + 3, _DecalData.OnTransform.position.z + randomFromCircle.y); } else { random = new Vector3(Center.x + randomFromCircle.x, Center.y + 3, Center.z + randomFromCircle.y); } RaycastHit hitInfo; if (Physics.Raycast(random, Vector3.down, out hitInfo, 999, _DecalData.ApplicableLayer)) { Object decalObjectPrototype = Util.RandomFromArray <Object>(_DecalData.DecalObjects); GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectPrototype, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= _DecalData.ScaleRate; if (_DecalData.DestoryInTimeOut) { Destroy(DecalObject, _DecalData.DestoryTimeOut); } } }
private static void ValidateDecal1(DecalData data) { data.Backglass.Should().Be(true); data.Center.X.Should().Be(509f); data.Center.Y.Should().Be(354f); data.Color.Red.Should().Be(216); data.Color.Green.Should().Be(63); data.Color.Blue.Should().Be(204); data.DecalType.Should().Be(DecalType.DecalText); data.Font.Name.Should().Be("Fixedsys"); data.Height.Should().Be(100f); data.Image.Should().Be(""); data.Material.Should().Be(""); data.Rotation.Should().Be(0f); data.SizingType.Should().Be(SizingType.ManualSize); data.Surface.Should().Be(""); data.Text.Should().Be("My Decal Text"); data.VerticalText.Should().Be(true); data.Width.Should().Be(100f); data.EditorLayer.Should().Be(0); data.EditorLayerName.Should().Be(string.Empty); data.EditorLayerVisibility.Should().Be(true); data.IsLocked.Should().Be(true); }
public virtual IEnumerator Die(DamageParameter DamageParameter) { //Basic death processing. unit.IsDead = true; //stop and remove AI foreach (AI _ai in GetComponents <AI>()) { _ai.StopAI(); Destroy(_ai); } //stop and remove navigator foreach (Navigator nav in GetComponents <Navigator>()) { nav.StopAllCoroutines(); Destroy(nav); } if (animation != null) { animation.Stop(); } //Handle DeathData: //1. Find the suitable DeathData: DeathData deathData = null; if (unit.DeathDataDict.ContainsKey(DamageParameter.damageForm)) { IList <DeathData> DeathDataList = unit.DeathDataDict[DamageParameter.damageForm]; deathData = Util.RandomFromList(DeathDataList); } else { //if no DeathData matched to the DamageForm in DamageParameter,use the DamageForm.Common deathData = Util.RandomFromList <DeathData>(unit.DeathDataDict[DamageForm.Common]); } if (deathData.DestoryCharacterController && controller != null) { controller.enabled = false; } //Create effect data if (deathData.EffectDataName != null && deathData.EffectDataName.Length > 0) { foreach (string effectDataName in deathData.EffectDataName) { EffectData effectData = unit.EffectDataDict[effectDataName]; GlobalBloodEffectDecalSystem.CreateEffect(effectData); } } //Create blood decal: if (deathData.DecalDataName != null && deathData.DecalDataName.Length > 0) { foreach (string decalName in deathData.DecalDataName) { DecalData DecalData = unit.DecalDataDict[decalName]; GlobalBloodEffectDecalSystem.CreateBloodDecal(transform.position + controller.center, DecalData); } } //Play audio: if (deathData.AudioDataName != null && deathData.AudioDataName.Length > 0) { foreach (string audioDataName in deathData.AudioDataName) { GetComponent <AudioController>()._PlayAudio(audioDataName); } } if (deathData.UseDieReplacement) { if (deathData.ReplaceAfterAnimationFinish) { animation.CrossFade(deathData.AnimationName); yield return(new WaitForSeconds(animation[deathData.AnimationName].length)); } else if (deathData.ReplaceAfterSeconds > 0) { animation.CrossFade(deathData.AnimationName); yield return(new WaitForSeconds(deathData.ReplaceAfterSeconds)); } GameObject DieReplacement = (GameObject)Object.Instantiate(deathData.DieReplacement, transform.position, transform.rotation); if (deathData.CopyChildrenTransformToDieReplacement) { Util.CopyTransform(transform, DieReplacement.transform); } //if deathData.ReplaceOldObjectInSpawnedList is true, means this object has a replacement in SpawnedList. if (deathData.ReplaceOldObjectInSpawnedList) { // the Spawner must not be null, when ReplaceOldObjectInSpawnedList is true if (unit.Spawner != null) { unit.Spawner.ReplaceSpawnedWithNewObject(this.gameObject, DieReplacement); } else { Debug.LogError(string.Format("Unit:{0} hsa no Spawner", unit.gameObject.name)); } } Destroy(gameObject); } else { animation.Play(deathData.AnimationName); if (deathData.DestoryGameObject) { Destroy(gameObject, deathData.DestoryLagTime); } } }
public DecalData GetClone() { DecalData clone = new DecalData(); clone.Name = this.Name; clone.UseGlobalDecal = this.UseGlobalDecal; clone.GlobalType = this.GlobalType; clone.DecalObjects = Util.CloneArray<Object>(this.DecalObjects); clone.ProjectDirection = this.ProjectDirection; clone.DestoryInTimeOut = this.DestoryInTimeOut; clone.DestoryTimeOut = this.DestoryTimeOut; clone.ScaleRate = this.ScaleRate; clone.ApplicableLayer = this.ApplicableLayer; return clone; }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "MODL": if (Model == null) { Model = new Model(); } Model.ReadBinary(reader); break; case "DATA": if (Data == null) { Data = new ImpactData(); } Data.ReadBinary(reader); break; case "DODT": if (DecalData == null) { DecalData = new DecalData(); } DecalData.ReadBinary(reader); break; case "DNAM": if (TextureSet == null) { TextureSet = new RecordReference(); } TextureSet.ReadBinary(reader); break; case "SNAM": if (Sound1 == null) { Sound1 = new RecordReference(); } Sound1.ReadBinary(reader); break; case "NAM1": if (Sound2 == null) { Sound2 = new RecordReference(); } Sound2.ReadBinary(reader); break; default: throw new Exception(); } } }
public Impact(SimpleSubrecord <String> EditorID, Model Model, ImpactData Data, DecalData DecalData, RecordReference TextureSet, RecordReference Sound1, RecordReference Sound2) { this.EditorID = EditorID; this.Data = Data; }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("Model", false, out subEle)) { if (Model == null) { Model = new Model(); } Model.ReadXML(subEle, master); } if (ele.TryPathTo("Data", false, out subEle)) { if (Data == null) { Data = new ImpactData(); } Data.ReadXML(subEle, master); } if (ele.TryPathTo("DecalData", false, out subEle)) { if (DecalData == null) { DecalData = new DecalData(); } DecalData.ReadXML(subEle, master); } if (ele.TryPathTo("TextureSet", false, out subEle)) { if (TextureSet == null) { TextureSet = new RecordReference(); } TextureSet.ReadXML(subEle, master); } if (ele.TryPathTo("Sound1", false, out subEle)) { if (Sound1 == null) { Sound1 = new RecordReference(); } Sound1.ReadXML(subEle, master); } if (ele.TryPathTo("Sound2", false, out subEle)) { if (Sound2 == null) { Sound2 = new RecordReference(); } Sound2.ReadXML(subEle, master); } }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("ObjectBounds", false, out subEle)) { if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadXML(subEle, master); } if (ele.TryPathTo("BaseImage_Transparency", false, out subEle)) { if (BaseImage_Transparency == null) { BaseImage_Transparency = new SimpleSubrecord <String>(); } BaseImage_Transparency.ReadXML(subEle, master); } if (ele.TryPathTo("NormalMap_Specular", false, out subEle)) { if (NormalMap_Specular == null) { NormalMap_Specular = new SimpleSubrecord <String>(); } NormalMap_Specular.ReadXML(subEle, master); } if (ele.TryPathTo("EnvironmentMapMask", false, out subEle)) { if (EnvironmentMapMask == null) { EnvironmentMapMask = new SimpleSubrecord <String>(); } EnvironmentMapMask.ReadXML(subEle, master); } if (ele.TryPathTo("GlowMap", false, out subEle)) { if (GlowMap == null) { GlowMap = new SimpleSubrecord <String>(); } GlowMap.ReadXML(subEle, master); } if (ele.TryPathTo("ParallaxMap", false, out subEle)) { if (ParallaxMap == null) { ParallaxMap = new SimpleSubrecord <String>(); } ParallaxMap.ReadXML(subEle, master); } if (ele.TryPathTo("EnvironmentMap", false, out subEle)) { if (EnvironmentMap == null) { EnvironmentMap = new SimpleSubrecord <String>(); } EnvironmentMap.ReadXML(subEle, master); } if (ele.TryPathTo("DecalData", false, out subEle)) { if (DecalData == null) { DecalData = new DecalData(); } DecalData.ReadXML(subEle, master); } if (ele.TryPathTo("TextureSetFlags", false, out subEle)) { if (TextureSetFlags == null) { TextureSetFlags = new SimpleSubrecord <TXSTFlags>(); } TextureSetFlags.ReadXML(subEle, master); } }
public TextureSet(SimpleSubrecord <String> EditorID, ObjectBounds ObjectBounds, SimpleSubrecord <String> BaseImage_Transparency, SimpleSubrecord <String> NormalMap_Specular, SimpleSubrecord <String> EnvironmentMapMask, SimpleSubrecord <String> GlowMap, SimpleSubrecord <String> ParallaxMap, SimpleSubrecord <String> EnvironmentMap, DecalData DecalData, SimpleSubrecord <TXSTFlags> TextureSetFlags) { this.EditorID = EditorID; this.ObjectBounds = ObjectBounds; }
public StaticRoom(AreaKey Area, RandoConfigRoom config, LevelData Level, List <Hole> Holes) { // hack: force credits screens into the epilogue roomset if (Area.ID == 7 && Level.Name.StartsWith("credits-")) { Area = new AreaKey(8); } this.Area = Area; this.Level = Level; this.Holes = Holes; this.Name = AreaData.Get(Area).GetSID() + "/" + (Area.Mode == AreaMode.Normal ? "A" : Area.Mode == AreaMode.BSide ? "B" : "C") + "/" + Level.Name; this.ReqEnd = this.ProcessReqs(config.ReqEnd); this.Hub = config.Hub; this.Tweaks = config.Tweaks ?? new List <RandoConfigEdit>(); this.CoreModes = config.Core; this.ExtraSpace = config.ExtraSpace ?? new List <RandoConfigRectangle>(); this.Worth = config.Worth ?? (float)Math.Sqrt(Level.Bounds.Width * Level.Bounds.Width + Level.Bounds.Height * Level.Bounds.Height) / 369.12870384189847f + 1; this.SpinnersShatter = config.SpinnersShatter; this.Collectables = new List <StaticCollectable>(); foreach (var entity in Level.Entities) { if (RandoModule.Instance.MetaConfig.CollectableNames.Contains(entity.Name)) { this.Collectables.Add(new StaticCollectable { Position = entity.Position, MustFly = false, }); } } this.Collectables.Sort((a, b) => { if (a.Position.Y > b.Position.Y) { return(1); } else if (a.Position.Y < b.Position.Y) { return(-1); } else if (a.Position.X > b.Position.X) { return(1); } else if (a.Position.X < b.Position.X) { return(-1); } else { return(0); } }); this.Nodes = new Dictionary <string, StaticNode>() { { "main", new StaticNode() { Name = "main", ParentRoom = this } } }; foreach (var subroom in config.Subrooms ?? new List <RandoConfigRoom>()) { if (subroom.Room == null || this.Nodes.ContainsKey(subroom.Room)) { throw new Exception($"Invalid subroom name in {this.Area} {this.Name}"); } this.Nodes.Add(subroom.Room, new StaticNode() { Name = subroom.Room, ParentRoom = this }); } this.ProcessSubroom(this.Nodes["main"], config); foreach (var subroom in config.Subrooms ?? new List <RandoConfigRoom>()) { this.ProcessSubroom(this.Nodes[subroom.Room], subroom); } // assign unmarked holes foreach (var uhole in this.Holes) { if (uhole.Kind != HoleKind.Unknown) { continue; } var bestDist = 10000f; StaticNode bestNode = null; var lowPos = uhole.LowCoord(this.Level.Bounds); var highPos = uhole.HighCoord(this.Level.Bounds); foreach (var node in this.Nodes.Values) { foreach (var edge in node.Edges.Where(edge => edge.HoleTarget != null)) { if (edge.HoleTarget == uhole) { bestNode = null; goto doublebreak; } var pos = edge.HoleTarget.LowCoord(this.Level.Bounds); var dist = (pos - lowPos).Length(); if (!uhole.LowOpen && dist < bestDist) { bestDist = dist; bestNode = node; } dist = (pos - highPos).Length(); if (!uhole.HighOpen && dist < bestDist) { bestDist = dist; bestNode = node; } pos = edge.HoleTarget.HighCoord(this.Level.Bounds); dist = (pos - lowPos).Length(); if (!uhole.LowOpen && dist < bestDist) { bestDist = dist; bestNode = node; } dist = (pos - highPos).Length(); if (!uhole.HighOpen && dist < bestDist) { bestDist = dist; bestNode = node; } } } doublebreak: bestNode?.Edges?.Add(new StaticEdge { FromNode = bestNode, HoleTarget = uhole, ReqIn = this.ProcessReqs(null, uhole, false), ReqOut = this.ProcessReqs(null, uhole, true), }); } // assign unmarked collectables foreach (var c in this.Collectables) { if (c.ParentNode != null) { continue; } var bestDist = 1000f; StaticNode bestNode = null; foreach (var node in this.Nodes.Values) { foreach (var edge in node.Edges) { if (edge.HoleTarget == null) { continue; } var pos = edge.HoleTarget.LowCoord(new Rectangle(0, 0, this.Level.Bounds.Width, this.Level.Bounds.Height)); var dist = (pos - c.Position).Length(); if (dist < bestDist) { bestDist = dist; bestNode = node; } pos = edge.HoleTarget.HighCoord(new Rectangle(0, 0, this.Level.Bounds.Width, this.Level.Bounds.Height)); dist = (pos - c.Position).Length(); if (dist < bestDist) { bestDist = dist; bestNode = node; } } } if (bestNode != null) { c.ParentNode = bestNode; bestNode.Collectables.Add(c); } } // perform fg tweaks var regex = new Regex("\\r\\n|\\n\\r|\\n|\\r"); var tweakable = new List <List <char> >(); foreach (var line in regex.Split(Level.Solids)) { var lst = new List <char>(); tweakable.Add(lst); foreach (var ch in line) { lst.Add(ch); } } void setTile(int x, int y, char tile) { while (y >= tweakable.Count) { tweakable.Add(new List <char>()); } while (x >= tweakable[y].Count) { tweakable[y].Add('0'); } tweakable[y][x] = tile; } foreach (var tweak in config.Tweaks ?? new List <RandoConfigEdit>()) { if (tweak.Name == "fgTiles") { setTile((int)tweak.X, (int)tweak.Y, tweak.Update.Tile); } } Level.Solids = string.Join("\n", tweakable.Select(line => string.Join("", line))); // peform decal tweaks foreach (var decalList in new[] { Level.FgDecals, Level.BgDecals }) { var removals = new List <DecalData>(); foreach (var decal in decalList) { var fg = object.ReferenceEquals(decalList, Level.FgDecals); foreach (var tweak in config.Tweaks ?? new List <RandoConfigEdit>()) { if (tweak.Decal == (fg ? RandoConfigDecalType.FG : RandoConfigDecalType.BG) && (tweak.Name == null || tweak.Name == decal.Texture) && (tweak.X == null || (int)tweak.X.Value == (int)decal.Position.X) && (tweak.Y == null || (int)tweak.Y.Value == (int)decal.Position.Y)) { if (tweak.Update?.Remove ?? false) { removals.Add(decal); } else { if (tweak.Update?.X != null) { decal.Position.X = tweak.Update.X.Value; } if (tweak.Update?.Y != null) { decal.Position.Y = tweak.Update.Y.Value; } if (tweak.Update?.ScaleX != null) { decal.Position.X = tweak.Update.ScaleX.Value; } if (tweak.Update?.ScaleY != null) { decal.Position.Y = tweak.Update.ScaleY.Value; } } break; } } } foreach (var decal in removals) { decalList.Remove(decal); } } foreach (var tweak in config.Tweaks ?? new List <RandoConfigEdit>()) { if ((tweak.Update?.Add ?? false) && tweak.Decal != RandoConfigDecalType.None) { var newDecal = new DecalData { Texture = tweak.Name, Position = new Vector2(tweak.Update.X.Value, tweak.Update.Y.Value), Scale = new Vector2(tweak.Update.ScaleX.Value, tweak.Update.ScaleY.Value), }; (tweak.Decal == RandoConfigDecalType.BG ? Level.BgDecals : Level.FgDecals).Add(newDecal); } } }
/// <summary> /// This method specifically target on creating blood decal on wall. /// </summary> IEnumerator CreateGlobalDecalOnWall(Vector3 Center, GlobalDecalData globalDecalData, DecalData _DecalData) { if (_DecalData.CreateDelay > 0) { yield return(new WaitForSeconds(_DecalData.CreateDelay)); } float Radius = 2; //check front/back/right/left direction if there's a collision: Collider[] wallColliders = Physics.OverlapSphere(Center, Radius, globalDecalData.WallLayer); if (wallColliders != null && wallColliders.Length > 0) { Collider wall = wallColliders[0]; Vector3 closestPoints = wall.ClosestPointOnBounds(Center); closestPoints.y += Random.Range(0.1f, 0.5f); //Randomize the point closestPoints += Random.onUnitSphere * 1; RaycastHit hitInfo; //Find the point to create wall decal if (Physics.Raycast(Center, closestPoints - Center, out hitInfo, 20, globalDecalData.WallLayer)) { //Randomly select a decal object Object decalObjectProtocal = Util.RandomFromArray <Object>(globalDecalData.Decal_OnWall); //if wall decal instantiation point exists, create the decal object. GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectProtocal, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); float scaleRate = Random.Range(globalDecalData.ScaleRateMin, globalDecalData.ScaleRateMax); DecalObject.transform.localScale *= scaleRate; if (globalDecalData.DecalLifetime > 0) { Destroy(DecalObject, globalDecalData.DecalLifetime); } } } }
public virtual IEnumerator ProcessReceiveDamageData(ReceiveDamageData receiveDamageData) { bool CanHaltAI = false; if (this.unit.receiveDamageStatus == UnitReceiveDamageStatus.vulnerableButNotReactToDamage || this.unit.receiveDamageStatus == UnitReceiveDamageStatus.invincible) { CanHaltAI = false; } #region if the unit is defined with ApplyDamageCondition, update the condition data. else { if (this.ApplyDamagerConditionArray != null && ApplyDamagerConditionArray.Length > 0) { foreach (ApplyDamagerCondition applyDamageCondition in ApplyDamagerConditionArray) { if (applyDamageCondition.IsApplyDamageConditionMatch()) { CanHaltAI = true; continue; } } } else { CanHaltAI = true; } } #endregion //Create effect data if (receiveDamageData.EffectDataName != null && receiveDamageData.EffectDataName.Length > 0) { foreach (string effectDataName in receiveDamageData.EffectDataName) { EffectData effectData = unit.EffectDataDict[effectDataName]; GlobalBloodEffectDecalSystem.CreateEffect(effectData); } } //Create blood decal: if (receiveDamageData.DecalDataName != null && receiveDamageData.DecalDataName.Length > 0) { foreach (string decalName in receiveDamageData.DecalDataName) { DecalData DecalData = unit.DecalDataDict[decalName]; GlobalBloodEffectDecalSystem.CreateBloodDecal(transform.position + controller.center, DecalData); } } //Play audio: if (receiveDamageData.AudioDataName != null && receiveDamageData.AudioDataName.Length > 0) { foreach (string audioName in receiveDamageData.AudioDataName) { GetComponent <AudioController>()._PlayAudio(audioName); } } //Halt AI if set true, stop all animation, and play the receive damage animation if (receiveDamageData.HaltAI && CanHaltAI) { animation.Stop(); animation.Rewind(); animation.CrossFade(receiveDamageData.AnimationName); SendMessage("HaltUnit", animation[receiveDamageData.AnimationName].length); yield return(new WaitForSeconds(animation[receiveDamageData.AnimationName].length)); } }
IEnumerator CreateBloodDecalOnWall(Vector3 Center, DecalData _DecalData) { if(_DecalData.CreateDelay > 0) { yield return new WaitForSeconds(_DecalData.CreateDelay); } float Radius = 2; //check front/back/right/left direction if there's a collision: Collider[] wallColliders = Physics.OverlapSphere(Center, Radius, _DecalData.ApplicableLayer); if (wallColliders != null && wallColliders.Length > 0) { Collider wall = wallColliders[0]; Vector3 closestPoints = wall.ClosestPointOnBounds(Center); closestPoints.y += Random.Range(0.1f, 0.5f); //Randomize the point closestPoints += Random.onUnitSphere*1; RaycastHit hitInfo; if (Physics.Raycast(Center, closestPoints - Center, out hitInfo, 20, _DecalData.ApplicableLayer)) { Object decalObjectPrototype = Util.RandomFromArray<Object>(_DecalData.DecalObjects); GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectPrototype, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= _DecalData.ScaleRate; if (_DecalData.DestoryInTimeOut) Destroy(DecalObject, _DecalData.DestoryTimeOut); } } }
IEnumerator CreateDecalOnGround(Vector3 Center, DecalData _DecalData) { if(_DecalData.CreateDelay > 0) { yield return new WaitForSeconds(_DecalData.CreateDelay); } float Radius = 1; Vector2 randomFromCircle = Random.insideUnitCircle; randomFromCircle *= Radius; Vector3 random = Vector3.zero; if(_DecalData.OnTransform != null) { random = new Vector3(_DecalData.OnTransform.position.x + randomFromCircle.x, Center.y + 3, _DecalData.OnTransform.position.z + randomFromCircle.y); } else { random = new Vector3(Center.x + randomFromCircle.x, Center.y + 3, Center.z + randomFromCircle.y); } RaycastHit hitInfo; if (Physics.Raycast(random, Vector3.down, out hitInfo, 999, _DecalData.ApplicableLayer)) { Object decalObjectPrototype = Util.RandomFromArray<Object>(_DecalData.DecalObjects); GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectPrototype, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= _DecalData.ScaleRate; if (_DecalData.DestoryInTimeOut) Destroy(DecalObject, _DecalData.DestoryTimeOut); } }
/// <summary> /// This method specifically target on creating blood decal on wall. /// </summary> IEnumerator CreateGlobalDecalOnWall(Vector3 Center, GlobalDecalData globalDecalData, DecalData _DecalData) { if(_DecalData.CreateDelay > 0) { yield return new WaitForSeconds(_DecalData.CreateDelay); } float Radius = 2; //check front/back/right/left direction if there's a collision: Collider[] wallColliders = Physics.OverlapSphere(Center, Radius, globalDecalData.WallLayer); if (wallColliders != null && wallColliders.Length > 0) { Collider wall = wallColliders[0]; Vector3 closestPoints = wall.ClosestPointOnBounds(Center); closestPoints.y += Random.Range(0.1f, 0.5f); //Randomize the point closestPoints += Random.onUnitSphere * 1; RaycastHit hitInfo; //Find the point to create wall decal if (Physics.Raycast(Center, closestPoints - Center, out hitInfo, 20, globalDecalData.WallLayer)) { //Randomly select a decal object Object decalObjectProtocal = Util.RandomFromArray<Object>(globalDecalData.Decal_OnWall); //if wall decal instantiation point exists, create the decal object. GameObject DecalObject = (GameObject)Object.Instantiate(decalObjectProtocal, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); float scaleRate = Random.Range(globalDecalData.ScaleRateMin , globalDecalData.ScaleRateMax); DecalObject.transform.localScale *= scaleRate; if (globalDecalData.DecalLifetime > 0) Destroy(DecalObject, globalDecalData.DecalLifetime); } } }
/// <summary> /// This method specifically target on creating blood decal on ground. /// </summary> IEnumerator CreateGlobalDecalOnGround(Vector3 Center, GlobalDecalData globalDecalData, DecalData _DecalData) { if (_DecalData.CreateDelay > 0) { yield return(new WaitForSeconds(_DecalData.CreateDelay)); } float Radius = 1; Vector2 randomFromCircle = Random.insideUnitCircle; randomFromCircle *= Radius; Vector3 random = Vector3.zero; if (_DecalData.OnTransform != null) { random = new Vector3(_DecalData.OnTransform.position.x + randomFromCircle.x, _DecalData.OnTransform.position.y + 3, _DecalData.OnTransform.position.z + randomFromCircle.y); } else { random = new Vector3(Center.x + randomFromCircle.x, Center.y + 3, Center.z + randomFromCircle.y); } RaycastHit hitInfo; //If there is ground point projection exists, create the decal object. if (Physics.Raycast(random, Vector3.down, out hitInfo, 999, globalDecalData.GroundLayer)) { //Randomly select a decalObject Object decalObject = Util.RandomFromArray <Object>(globalDecalData.Decal_OnGround); float scaleRate = Random.Range(globalDecalData.ScaleRateMin, globalDecalData.ScaleRateMax); //Instantiate the DecalObject GameObject DecalObject = (GameObject)Object.Instantiate(decalObject, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= scaleRate; if (globalDecalData.DecalLifetime > 0) { Destroy(DecalObject, globalDecalData.DecalLifetime); } } }
/// <summary> /// This method specifically target on creating blood decal on ground. /// </summary> IEnumerator CreateGlobalDecalOnGround(Vector3 Center, GlobalDecalData globalDecalData, DecalData _DecalData) { if(_DecalData.CreateDelay > 0) { yield return new WaitForSeconds(_DecalData.CreateDelay); } float Radius = 1; Vector2 randomFromCircle = Random.insideUnitCircle; randomFromCircle *= Radius; Vector3 random = Vector3.zero; if(_DecalData.OnTransform != null) { random = new Vector3(_DecalData.OnTransform.position.x + randomFromCircle.x, _DecalData.OnTransform.position.y + 3, _DecalData.OnTransform.position.z + randomFromCircle.y); } else { random = new Vector3(Center.x + randomFromCircle.x, Center.y + 3, Center.z + randomFromCircle.y); } RaycastHit hitInfo; //If there is ground point projection exists, create the decal object. if (Physics.Raycast(random, Vector3.down, out hitInfo, 999, globalDecalData.GroundLayer)) { //Randomly select a decalObject Object decalObject = Util.RandomFromArray<Object>(globalDecalData.Decal_OnGround); float scaleRate = Random.Range(globalDecalData.ScaleRateMin, globalDecalData.ScaleRateMax); //Instantiate the DecalObject GameObject DecalObject = (GameObject)Object.Instantiate(decalObject, hitInfo.point + hitInfo.normal * 0.1f, Quaternion.identity); DecalObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); DecalObject.transform.RotateAround(DecalObject.transform.up, Random.Range(0, 360)); DecalObject.transform.localScale *= scaleRate; if(globalDecalData.DecalLifetime > 0) { Destroy(DecalObject, globalDecalData.DecalLifetime); } } }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "OBND": if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadBinary(reader); break; case "TX00": if (BaseImage_Transparency == null) { BaseImage_Transparency = new SimpleSubrecord <String>(); } BaseImage_Transparency.ReadBinary(reader); break; case "TX01": if (NormalMap_Specular == null) { NormalMap_Specular = new SimpleSubrecord <String>(); } NormalMap_Specular.ReadBinary(reader); break; case "TX02": if (EnvironmentMapMask == null) { EnvironmentMapMask = new SimpleSubrecord <String>(); } EnvironmentMapMask.ReadBinary(reader); break; case "TX03": if (GlowMap == null) { GlowMap = new SimpleSubrecord <String>(); } GlowMap.ReadBinary(reader); break; case "TX04": if (ParallaxMap == null) { ParallaxMap = new SimpleSubrecord <String>(); } ParallaxMap.ReadBinary(reader); break; case "TX05": if (EnvironmentMap == null) { EnvironmentMap = new SimpleSubrecord <String>(); } EnvironmentMap.ReadBinary(reader); break; case "DODT": if (DecalData == null) { DecalData = new DecalData(); } DecalData.ReadBinary(reader); break; case "DNAM": if (TextureSetFlags == null) { TextureSetFlags = new SimpleSubrecord <TXSTFlags>(); } TextureSetFlags.ReadBinary(reader); break; default: throw new Exception(); } } }