/// <summary> /// Updates the ViewerFrameIndex for this instance /// and all suboverlays. /// </summary> protected virtual void UpdateFrameIndices() { if (resource != null) { ViewerFrameIndex = resource.GetFrameIndex(Animation.CurrentGroup, viewerAngle); if (ViewerFrameIndex > -1 && resource.Frames.Count > ViewerFrameIndex) { ViewerFrame = resource.Frames[ViewerFrameIndex]; } else { ViewerFrame = null; } } else { ViewerFrameIndex = -1; ViewerFrame = null; } foreach (SubOverlay subOv in subOverlays) { subOv.UpdateFrameIndices(viewerAngle); } }
/// <summary> /// Sets middle texture to another num /// </summary> /// <param name="TextureNum"></param> /// <param name="TextureFile"></param> /// <param name="ResetAnimation"></param> public void SetMiddleTexture(ushort TextureNum, BgfFile TextureFile, bool ResetAnimation = true) { ushort group = (animation != null) ? animation.CurrentGroup : (ushort)1; int frameidx = 0; string oldmaterial = MaterialNameMiddle; MiddleTexture = TextureNum; ResourceMiddle = TextureFile; if (ResourceMiddle != null && ResourceMiddle.Frames.Count > 0) { // possibly reset animation if (animation != null && ResetAnimation) { animation.SetValues(1, ResourceMiddle.FrameSets.Count, false); group = animation.CurrentGroup; } frameidx = ResourceMiddle.GetFrameIndex(group, 0); frameidx = Math.Max(frameidx, 0); if (ResourceMiddle.Frames.Count > frameidx) { TextureMiddle = ResourceMiddle.Frames[frameidx]; SpeedMiddle = GetWallScrollSpeed(TextureMiddle.Width, TextureMiddle.Height); } else { TextureMiddle = null; SpeedMiddle = V2.ZERO; } TextureNameMiddle = RooFile.GetNameForTexture( ResourceMiddle, frameidx); MaterialNameMiddle = RooFile.GetNameForMaterial( ResourceMiddle, frameidx, SpeedMiddle); } else { TextureMiddle = null; SpeedMiddle = V2.ZERO; TextureNameMiddle = null; MaterialNameMiddle = null; } if (TextureChanged != null) { TextureChanged(this, new WallTextureChangedEventArgs(this, WallPartType.Middle, oldmaterial)); } }
/// <summary> /// Sets lower texture to another num /// </summary> /// <param name="TextureNum"></param> /// <param name="TextureFile"></param> public void SetUpperTexture(ushort TextureNum, BgfFile TextureFile) { ushort group = (animation != null) ? animation.CurrentGroup : (ushort)1; int frameidx = 0; string oldmaterial = MaterialNameUpper; UpperTexture = TextureNum; ResourceUpper = TextureFile; if (ResourceUpper != null && ResourceUpper.Frames.Count > 0) { frameidx = ResourceUpper.GetFrameIndex(group, 0); frameidx = Math.Max(frameidx, 0); if (ResourceUpper.Frames.Count > frameidx) { TextureUpper = ResourceUpper.Frames[frameidx]; SpeedUpper = GetWallScrollSpeed(TextureUpper.Width, TextureUpper.Height); } else { TextureUpper = null; SpeedUpper = V2.ZERO; } TextureNameUpper = RooFile.GetNameForTexture( ResourceUpper, frameidx); MaterialNameUpper = RooFile.GetNameForMaterial( ResourceUpper, frameidx, SpeedUpper); } else { TextureUpper = null; SpeedUpper = V2.ZERO; TextureNameUpper = null; MaterialNameUpper = null; } if (TextureChanged != null) { TextureChanged(this, new WallTextureChangedEventArgs(this, WallPartType.Upper, oldmaterial)); } }
/// <summary> /// Updates the ViewerFrameIndex for this instance. /// </summary> public virtual void UpdateFrameIndices() { if (resource != null) { ViewerFrameIndex = resource.GetFrameIndex(Animation.CurrentGroup, viewerAngle); if (ViewerFrameIndex > -1 && resource.Frames.Count > ViewerFrameIndex) { ViewerFrame = resource.Frames[ViewerFrameIndex]; } else { ViewerFrame = null; } } else { ViewerFrameIndex = -1; ViewerFrame = null; } }