public override void OnInspectorGUI() { if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab) { base.OnInspectorGUI(); return; } Material srcMat = null; MaterialAnimation ma = target as MaterialAnimation; Renderer r = ma.GetComponent <Renderer>(); if (Application.isPlaying) { base.OnInspectorGUI(); if (r != null) { EditorGUILayout.ObjectField("dstMat", r.material, typeof(Material), false); } return; } List <MaterialAnimBase> mabs = new List <MaterialAnimBase>(ma.gameObject.GetComponents <MaterialAnimBase>()); if (r == null || ((srcMat = r.sharedMaterial) == null)) { foreach (MaterialAnimBase mab in mabs) { Object.DestroyImmediate(mab); } return; } if (srcMat == null) { return; } Material copy_mat = null; if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(srcMat))) { copy_mat = srcMat; srcMat = AssetDatabase.LoadAssetAtPath <Material>(AssetDatabase.GUIDToAssetPath(srcMat.name)); } EditorGUILayout.ObjectField("srcMat", srcMat, typeof(Material), false); if (srcMat == null) { return; } if (!ma.gameObject.activeInHierarchy) { ma.LateUpdate(); } OnShowMaterailProperties(mabs, srcMat); }
public void SetCurrentAnimation(string name, bool flipHorizontal = false) { if (this.isOnForcePlay) { return; } this.SetFlipHorizontal(flipHorizontal); if (this.currentAnimation != null && name.Equals(this.currentAnimation.animationName)) { this.isOnForcePlay = this.currentAnimation.forcePlayOnce; return; } this.currentAnimation = null; foreach (MaterialAnimation matAnimation in this.animations) { if (matAnimation.animationName.Equals(name)) { this.currentAnimation = matAnimation; this.isOnForcePlay = this.currentAnimation.forcePlayOnce; break; } } if (this.currentAnimation != null) { this.currentAnimationIndex = -1; this.SetNextAnimationFrame(); } }
private void prepareMaterialPulseView() { nfloat diamter = 150f; nfloat point = (MaterialDevice.Width - diamter) / 2; var pulseView = new MaterialPulseView(new CGRect(point, point, diamter, diamter)); pulseView.Image = UIImage.FromBundle("Graph"); pulseView.Shape = MaterialShape.Square; pulseView.Depth = MaterialDepth.Depth1; pulseView.CornerRadiusPreset = MaterialRadius.Radius3; pulseView.PulseAnimation = PulseAnimation.CenterRadialBeyondBounds; View.AddSubview(pulseView); MaterialAnimation.Delay(4, () => { pulseView.pulse(new CGPoint(30, 30)); }); pulseView.Animate(MaterialAnimation.AnimationGroup(new CAAnimation[] { MaterialAnimation.Rotate(rotation: 0.5f), MaterialAnimation.RotateX(rotation: 2.0f), MaterialAnimation.TranslateY(200f) }, 4)); }
private void ReloadAnimationView(MaterialAnimation materialAnim) { treeView1.Nodes.Clear(); int Index = 0; foreach (var mat in materialAnim.Materials) { mat.Nodes.Clear(); var matWrapper = new TreeNode(mat.Text) { Tag = mat, }; treeView1.Nodes.Add(matWrapper); foreach (var sampler in mat.Samplers) { matWrapper.Nodes.Add(new TreeNode(sampler.Text) { Tag = sampler, }); } if (matWrapper.Nodes.Count > 0 && Index == 0) { treeView1.SelectedNode = matWrapper.Nodes[0]; } Index++; } ReloadAnimationView(); }
public override void OnInspectorGUI() { MaterialAnimation ma = target as MaterialAnimation; Material old = ma.srcMaterial; ma.srcMaterial = (Material)EditorGUILayout.ObjectField("srcMat", ma.srcMaterial, typeof(Material), false); if (old != ma.srcMaterial) { ma.ResetMaterial(ma.srcMaterial); } List <MaterialAnimBase> mabs = new List <MaterialAnimBase>(ma.gameObject.GetComponents <MaterialAnimBase>()); if (ma.srcMaterial == null) { foreach (MaterialAnimBase mab in mabs) { DestroyImmediate(mab); } return; } if (!ma.gameObject.activeInHierarchy) { ma.LateUpdate(); } OnShowMaterailProperties(mabs, ma.srcMaterial); }
public MaterialAnimation.SamplerKeyGroup GetSamplerData(MaterialAnimation materialAnimation) { MaterialAnimation.SamplerKeyGroup sampler = new MaterialAnimation.SamplerKeyGroup(materialAnimation); sampler.Text = samplerNameTB.Text; sampler.Constant = constantChkBox.Checked; return(sampler); }
private void activeAnimCB_SelectedIndexChanged(object sender, EventArgs e) { if (activeAnimCB.SelectedIndex != -1 && IsLoaded) { ActiveMaterialAnim = MaterialAnimations[activeAnimCB.SelectedIndex]; ReloadAnimationView(ActiveMaterialAnim); } }
public void LoadAnim(MaterialAnimation anim) { activeAnim = anim; foreach (var material in anim.Materials) { listViewCustom1.Items.Add(material.Text); } }
public void LoadAnim(MaterialAnimation materialAnimation, MaterialAnimation.Material mat) { activeMat = mat; ActiveMaterialAnim = materialAnimation; foreach (var sampler in mat.Samplers) { listViewCustom1.Items.Add(sampler.Text); } }
public void LoadAnim(FTXP materialAnim) { if (materialAnim.Materials.Count <= 0) { return; } IsLoaded = false; ActiveMaterialAnim = materialAnim; materialCB.Items.Clear(); samplerCB.Items.Clear(); foreach (var mat in materialAnim.Materials) { materialCB.Items.Add(mat.Text); } materialCB.SelectedIndex = 0; material = materialAnim.Materials[materialCB.SelectedIndex]; if (material.Samplers.Count <= 0) { return; } foreach (var sampler in material.Samplers) { samplerCB.Items.Add(sampler.Text); } samplerCB.SelectedIndex = 0; activeSampleU = (FTXP.BfresSamplerAnim)material.Samplers[samplerCB.SelectedIndex]; listViewCustom1.SuspendLayout(); listViewCustom1.Items.Clear(); LoadAniamtion(materialAnim, activeSampleU); listViewCustom1.ResumeLayout(); IsLoaded = true; animationTrackBar.Value = 0; }
public void LoadAnim(MaterialAnimation materialAnim) { if (materialAnim.Materials.Count <= 0) { return; } IsLoaded = false; ReloadAnimationView(materialAnim); IsLoaded = true; activeAnimCB.SelectItemByText(materialAnim.Text); animationTrackBar.Value = 0; }
public void LoadAnim(MaterialAnimation anim) { activeAnimation = anim; listViewCustom1.Items.Clear(); listViewCustom1.Columns.Clear(); materialCB.Items.Clear(); foreach (var material in anim.Materials) { materialCB.Items.Add(material.Text); } if (materialCB.Items.Count > 0) { materialCB.SelectedIndex = 0; } }
public Model(Renderer Renderer, H3DModel BaseModel) { this.Renderer = Renderer; this.BaseModel = BaseModel; Meshes0 = new List <Mesh>(); Meshes1 = new List <Mesh>(); Meshes2 = new List <Mesh>(); Meshes3 = new List <Mesh>(); Shaders = new List <Shader>(); ShaderHashes = new Dictionary <int, int>(); InverseTransforms = new Matrix4[BaseModel.Skeleton.Count]; for (int Bone = 0; Bone < BaseModel.Skeleton.Count; Bone++) { InverseTransforms[Bone] = BaseModel.Skeleton[Bone].InverseTransform.ToMatrix4(); } UpdateShaders(); AddMeshes(Meshes0, BaseModel.MeshesLayer0); AddMeshes(Meshes1, BaseModel.MeshesLayer1); AddMeshes(Meshes2, BaseModel.MeshesLayer2); AddMeshes(Meshes3, BaseModel.MeshesLayer3); SkeletalAnim = new SkeletalAnimation(BaseModel.Skeleton); MaterialAnim = new MaterialAnimation(BaseModel.Materials); VisibilityAnim = new VisibilityAnimation( BaseModel.MeshNodesTree, BaseModel.MeshNodesVisibility); Transform = Matrix4.Identity; UpdateAnimationTransforms(); }
private void ReadColorAnim(MaterialAnimation anim, MaterialAnimation.ParamKeyGroup paramAnim) { ColumnHeader colorHeader = new ColumnHeader() { Text = "Color" }; ColumnHeader alphaHeader = new ColumnHeader() { Text = "Alpha" }; ColumnHeader RHeader = new ColumnHeader() { Text = "R" }; ColumnHeader GHeader = new ColumnHeader() { Text = "G" }; ColumnHeader BHeader = new ColumnHeader() { Text = "B" }; ColumnHeader AHeader = new ColumnHeader() { Text = "A" }; listViewCustom1.Columns.Add(colorHeader); listViewCustom1.Columns.Add(alphaHeader); listViewCustom1.Columns.Add(RHeader); listViewCustom1.Columns.Add(GHeader); listViewCustom1.Columns.Add(BHeader); listViewCustom1.Columns.Add(AHeader); for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { var item1 = new ListViewItem($"{Frame}"); item1.SubItems.Add("Color"); item1.SubItems.Add("Alpha"); item1.UseItemStyleForSubItems = false; int Red = 0, Green = 0, Blue = 0, Alpha = 255; foreach (var track in paramAnim.Values) { Console.WriteLine((ColorOffsets)track.AnimDataOffset + " " + track.GetValue(Frame) + " " + paramAnim.UniformName); if ((ColorOffsets)track.AnimDataOffset == ColorOffsets.Red) { Red = Utils.FloatToIntClamp(track.GetValue(Frame)); item1.SubItems.Add($"R {track.GetValue(Frame)}"); } if ((ColorOffsets)track.AnimDataOffset == ColorOffsets.Green) { Green = Utils.FloatToIntClamp(track.GetValue(Frame)); item1.SubItems.Add($"G {track.GetValue(Frame)}"); } if ((ColorOffsets)track.AnimDataOffset == ColorOffsets.Blue) { Blue = Utils.FloatToIntClamp(track.GetValue(Frame)); item1.SubItems.Add($"B {track.GetValue(Frame)}"); } if ((ColorOffsets)track.AnimDataOffset == ColorOffsets.Alpha) { Alpha = Utils.FloatToIntClamp(track.GetValue(Frame)); item1.SubItems.Add($"A {track.GetValue(Frame)}"); } if (track.GetKeyFrame(Frame, false) != track.GetKeyFrame(Frame + 1, false)) { item1.SubItems[item1.SubItems.Count - 1].Font = new Font(item1.SubItems[item1.SubItems.Count - 1].Font, FontStyle.Bold); } } item1.SubItems[1].BackColor = Color.FromArgb(Red, Green, Blue); item1.SubItems[2].BackColor = Color.FromArgb(Alpha, Alpha, Alpha); listViewCustom1.Items.Add(item1); } }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.Material.Sampler activeSampler) { if (activeSampler == null || IsLoading) { return; } int imageIndex = 0; imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; Thread Thread = new Thread((ThreadStart)(() => { IsLoading = true; for (int Frame = 0; Frame < anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.group.Constant && Frame != 0) { break; } var keyFrame = activeSampler.group.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.group.Constant) { var tex = activeSampler.GetActiveTexture(Frame); if (tex != null) { Bitmap temp = tex.GetBitmap(); Images.Add(Frame, temp); KeyFrames.Add(Frame); if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { // Running on the UI thread listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); imgList.Images.Add(temp); var dummy = imgList.Handle; }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); } } else { if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + activeSampler.GetActiveTextureName(Frame), imageIndex++); }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + activeSampler.GetActiveTextureName(Frame), imageIndex++); } } } } IsLoading = false; })); Thread.Start(); }
private void LoadParam(MaterialAnimation anim, MaterialAnimation.ParamKeyGroup paramAnim) { listViewCustom1.Columns.Clear(); listViewCustom1.Items.Clear(); ColumnHeader frameColumn = new ColumnHeader() { Text = $"Frame" }; listViewCustom1.Columns.Add(frameColumn); if (paramAnim.Type == MaterialAnimation.AnimationType.Color) { ReadColorAnim(anim, paramAnim); } else if (anim.AnimType == MaterialAnimation.AnimationType.TextureSrt) { foreach (var track in paramAnim.Values) { ColumnHeader valueColumn = new ColumnHeader() { Text = $"{(TexSRT)track.AnimDataOffset}" }; listViewCustom1.Columns.Add(valueColumn); } for (int Frame = 0; Frame < anim.FrameCount; Frame++) { if (IsKeyed(paramAnim, Frame)) { var item1 = new ListViewItem($"{Frame}"); listViewCustom1.Items.Add(item1); foreach (var track in paramAnim.Values) { if (track.AnimDataOffset == (uint)TexSRT.Mode) { item1.SubItems.Add(((uint)track.GetValue(Frame)).ToString()); } else { item1.SubItems.Add(track.GetValue(Frame).ToString()); } } } } } else { int columnCount = paramAnim.Values.Count; for (int col = 0; col < columnCount; col++) { ColumnHeader valueColumn = new ColumnHeader() { Text = $"Value {col}" }; listViewCustom1.Columns.Add(valueColumn); } for (int Frame = 0; Frame < anim.FrameCount; Frame++) { if (IsKeyed(paramAnim, Frame)) { var item1 = new ListViewItem($"{Frame}"); listViewCustom1.Items.Add(item1); foreach (var track in paramAnim.Values) { var keyFrame = track.GetKeyFrame(Frame); float value = track.GetValue(Frame); item1.SubItems.Add(value.ToString()); } } } } }
protected void OnShowMaterailProperties(List <MaterialAnimBase> mabs, Material srcMat) { MaterialAnimation ma = target as MaterialAnimation; MaterialProperty[] props = MaterialEditor.GetMaterialProperties(new Object[] { srcMat }); foreach (MaterialProperty prop in props) { if (mabs.Find((MaterialAnimBase mab) => { return(mab.propName == prop.name ? true : false); })) { continue; } switch (prop.type) { case MaterialProperty.PropType.Color: { EditorGUILayout.BeginHorizontal(); EditorGUILayout.ColorField(prop.name, prop.colorValue); if (GUILayout.Button("添加")) { MaterialAnimColor mac = AddMaterialAnimBase <MaterialAnimColor, MaterialAnimColor1, MaterialAnimColor2, MaterialAnimColor3, MaterialAnimColor4>(ma.gameObject); mac.propName = prop.name; mac.color = prop.colorValue; } EditorGUILayout.EndHorizontal(); } break; case MaterialProperty.PropType.Vector: { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Vector4Field(prop.name, prop.vectorValue); if (GUILayout.Button("添加")) { MaterialAnimVector mac = AddMaterialAnimBase <MaterialAnimVector, MaterialAnimVector1, MaterialAnimVector2, MaterialAnimVector3, MaterialAnimVector4>(ma.gameObject); mac.propName = prop.name; mac.value = prop.vectorValue; } EditorGUILayout.EndHorizontal(); } break; case MaterialProperty.PropType.Float: case MaterialProperty.PropType.Range: { EditorGUILayout.BeginHorizontal(); EditorGUILayout.FloatField(prop.name, prop.floatValue); if (GUILayout.Button("添加")) { MaterialAnimValue mac = AddMaterialAnimBase <MaterialAnimValue, MaterialAnimValue1, MaterialAnimValue2, MaterialAnimValue3, MaterialAnimValue4>(ma.gameObject); mac.propName = prop.name; mac.value = prop.floatValue; } EditorGUILayout.EndHorizontal(); } break; case MaterialProperty.PropType.Texture: { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Vector4Field(prop.name, prop.textureScaleAndOffset); if (GUILayout.Button("添加")) { MaterialAnimOffsetScale mac = AddMaterialAnimBase <MaterialAnimOffsetScale, MaterialAnimOffsetScale1, MaterialAnimOffsetScale2, MaterialAnimOffsetScale3, MaterialAnimOffsetScale4>(ma.gameObject); mac.propName = prop.name; Vector4 v = prop.textureScaleAndOffset; mac.scale = new Vector2(v.x, v.y); mac.offset = new Vector2(v.z, v.w); } EditorGUILayout.EndHorizontal(); } break; } } }
public static void BuildFromMesh(DX.Mesh mesh, MeshData <Material> data, Material[][] mats) { void *src = mesh.LockVertexBuffer(DX.LockFlags.None).DataPointer.ToPointer(); byte[] buffer = new byte[mesh.VertexCount * mesh.BytesPerVertex]; fixed(byte *dst = &buffer[0]) { Memory.Copy(src, dst, buffer.Length); data.SetData(dst, buffer.Length); } mesh.UnlockVertexBuffer(); data.Materials = mats; data.MaterialAnimation = new MaterialAnimationInstance[mats.Length]; //{ new MaterialAnimationInstance(matAnimData) }; for (int i = 0; i < mats.Length; i++) { MaterialAnimation matAnimData = new MaterialAnimation(mats[i].Length, 0.025f); data.MaterialAnimation[i] = new MaterialAnimationInstance(matAnimData); } data.VertexSize = mesh.BytesPerVertex; data.VertexCount = mesh.VertexCount; DX.VertexElement[] elements = DX.D3DX.DeclaratorFromFVF(mesh.VertexFormat); data.VertexElements = new VertexElement[elements.Length]; for (int i = 0; i < elements.Length - 1; i++) { data.VertexElements[i] = new VertexElement(elements[i].Offset, Convert(elements[i].Type), Convert(elements[i].Usage), elements[i].UsageIndex); //data.VertexElements [i]= new VertexElement (elements[i].Offset, //data.VertexElements[i].Index = elements[i].UsageIndex; //data.VertexElements[i].Offset = elements[i].Offset; //data.VertexElements[i].s } //Array.Copy(elements, data.VertexElements, elements.Length); int faceCount = mesh.FaceCount; data.Faces = new MeshFace[faceCount]; uint *ab = (uint *)mesh.LockAttributeBuffer(DX.LockFlags.ReadOnly).DataPointer.ToPointer(); if ((mesh.CreationOptions & DX.MeshFlags.Use32Bit) == DX.MeshFlags.Use32Bit) { uint *ib = (uint *)mesh.LockIndexBuffer(DX.LockFlags.ReadOnly).DataPointer.ToPointer(); for (int i = 0; i < faceCount; i++) { int idxId = i * 3; data.Faces[i] = new MeshFace((int)ib[idxId], (int)ib[idxId + 1], (int)ib[idxId + 2], (int)ab[i]); } mesh.UnlockIndexBuffer(); } else { ushort *ib = (ushort *)mesh.LockIndexBuffer(DX.LockFlags.ReadOnly).DataPointer.ToPointer(); for (int i = 0; i < faceCount; i++) { int idxId = i * 3; data.Faces[i] = new MeshFace(ib[idxId], ib[idxId + 1], ib[idxId + 2], (int)ab[i]); } mesh.UnlockIndexBuffer(); } mesh.UnlockAttributeBuffer(); }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.SamplerKeyGroup activeSampler) { if (activeSampler == null || IsLoading) { return; } imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; int ImageIndex = 0; for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrame((int)keyFrame.Value, Frame, ImageIndex++); } } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } Thread = new Thread((ThreadStart)(() => { for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrameImage((int)keyFrame.Value, Frame); } } IsLoading = true; if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } }); } else { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } } IsLoading = false; })); Thread.Start(); }
private void LoadParam(MaterialAnimation anim, MaterialAnimation.ParamKeyGroup paramAnim) { listViewCustom1.Columns.Clear(); listViewCustom1.Items.Clear(); ColumnHeader frameColumn = new ColumnHeader() { Text = $"Frame" }; listViewCustom1.Columns.Add(frameColumn); if (paramAnim.Type == MaterialAnimation.AnimationType.Color) { ReadColorAnim(anim, paramAnim); } else if (anim.AnimType == MaterialAnimation.AnimationType.TextureSrt) { foreach (var track in paramAnim.Values) { ColumnHeader valueColumn = new ColumnHeader() { Text = $"{(TexSRT)track.AnimDataOffset}" }; listViewCustom1.Columns.Add(valueColumn); } for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { var item1 = new ListViewItem($"{Frame}"); item1.UseItemStyleForSubItems = false; listViewCustom1.Items.Add(item1); foreach (var track in paramAnim.Values) { if (track.AnimDataOffset == (uint)TexSRT.Mode) { var keyFrame = track.GetKeyFrame(Frame, false); if (keyFrame != null) { item1.SubItems.Add(((uint)keyFrame.Value).ToString()); } else { item1.SubItems.Add(""); } } else { item1.SubItems.Add(track.GetValue(Frame).ToString()); } if (track.GetKeyFrame(Frame, false) != track.GetKeyFrame(Frame + 1, false)) { item1.SubItems[item1.SubItems.Count - 1].Font = new Font(item1.SubItems[item1.SubItems.Count - 1].Font, FontStyle.Bold); } } } } else { int columnCount = paramAnim.Values.Count; for (int col = 0; col < columnCount; col++) { ColumnHeader valueColumn = new ColumnHeader() { Text = $"Value {col}" }; listViewCustom1.Columns.Add(valueColumn); } for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { var item1 = new ListViewItem($"{Frame}"); item1.UseItemStyleForSubItems = false; listViewCustom1.Items.Add(item1); foreach (var track in paramAnim.Values) { item1.SubItems.Add(track.GetValue(Frame).ToString()); if (track.GetKeyFrame(Frame, false) != track.GetKeyFrame(Frame + 1, false)) { item1.SubItems[item1.SubItems.Count - 1].Font = new Font(item1.SubItems[item1.SubItems.Count - 1].Font, FontStyle.Bold); } } } } }
public void CraftSelectedPart() { if (this.IsMachineLocked) { return; } this.queuedAddScrapActions = 0; BasePart.PartTier partTierFromAmount = this.GetPartTierFromAmount(GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null)); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftLeverCrank); if (partTierFromAmount == BasePart.PartTier.Regular) { this.SetMachineAnimation(this.insufficientScrapAnimationName, false, false, true); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftEmpty); MaterialAnimation component = this.MachineLabel.GetComponent <MaterialAnimation>(); if (component != null) { component.PlayAnimation(true, 5); } return; } SnoutButton.Instance.EnableButton(false); int num = 0; BasePart basePart = null; if (partTierFromAmount == BasePart.PartTier.Legendary && AlienCustomizationManager.GetNextUnlockable(out basePart)) { num = AlienCustomizationManager.GetPrice(); } else if (partTierFromAmount != BasePart.PartTier.Legendary) { num = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, partTierFromAmount.ToString()); basePart = CustomizationManager.GetRandomCraftablePartFromTier(partTierFromAmount, true); } if (basePart && num > 0 && GameProgress.UseScrap(num)) { this.SetMachineAnimation((!this.IsAlienMachine) ? this.craftAnimationName : this.slimeCraftAnimationName, false, false, false); Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftPart); CustomizationManager.UnlockPart(basePart, "crafted"); this.RemoveScrap(num); this.SetMachineIdleSound(0); PlayerProgress.ExperienceType experienceType = PlayerProgress.ExperienceType.CommonPartCrafted; if (partTierFromAmount == BasePart.PartTier.Rare) { experienceType = PlayerProgress.ExperienceType.RarePartCrafted; } if (partTierFromAmount == BasePart.PartTier.Epic) { experienceType = PlayerProgress.ExperienceType.EpicPartCrafted; } if (partTierFromAmount == BasePart.PartTier.Legendary) { experienceType = PlayerProgress.ExperienceType.LegendaryPartCrafted; } PlayerProgressBar.Instance.DelayUpdate(); int exp = Singleton <PlayerProgress> .Instance.AddExperience(experienceType); this.ShowReward(basePart, exp); string key = "CraftCount" + basePart.m_partTier.ToString(); int @int = GameProgress.GetInt(key, 0, GameProgress.Location.Local, null); GameProgress.SetInt(key, @int + 1, GameProgress.Location.Local); if (Singleton <SocialGameManager> .IsInstantiated() && basePart.m_partTier == BasePart.PartTier.Epic) { Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.CRAFT_PARTS", 100.0); } this.partsCraftedWhileInScreen++; EventManager.Send(new CraftingMachineEvent(WorkshopMenu.CraftingMachineAction.CraftPart, 0)); } else if (basePart) { } }