public override bool Draw(UltimaBatcher2D batcher, int posX, int posY) { if (IsDestroyed) { return(false); } ResetHueVector(); if (AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) { _displayedGraphic = AnimationGraphic; Texture = ArtLoader.Instance.GetTexture(AnimationGraphic); Bounds.X = -((Texture.Width >> 1) - 22); Bounds.Y = -(Texture.Height - 44); Bounds.Width = Texture.Width; Bounds.Height = Texture.Height; } posX += (int)Offset.X; posY += (int)(Offset.Y + Offset.Z); //posX += 22; //posY += 22; if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange) { HueVector.X = Constants.OUT_RANGE_COLOR; HueVector.Y = 1; } else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect) { HueVector.X = Constants.DEAD_RANGE_COLOR; HueVector.Y = 1; } else { ShaderHuesTraslator.GetHueVector(ref HueVector, Hue); } //Engine.DebugInfo.EffectsRendered++; if (FixedDir) { batcher.DrawSprite(Texture, posX, posY, false, ref HueVector); } else { batcher.DrawSpriteRotated(Texture, posX, posY, Bounds.X, Bounds.Y, ref HueVector, AngleToTarget); } //Select(posX, posY); Texture.Ticks = Time.Ticks; ref readonly StaticTiles data = ref TileDataLoader.Instance.StaticData[_displayedGraphic];
protected static void DrawLand(UltimaBatcher2D batcher, ushort graphic, int x, int y, ref Vector3 hue) { var texture = ArtLoader.Instance.GetLandTexture(graphic); if (texture != null) { texture.Ticks = Time.Ticks; batcher.DrawSprite(texture, x, y, false, ref hue); } }
protected static void DrawStatic(UltimaBatcher2D batcher, ushort graphic, int x, int y, ref Vector3 hue) { var texture = ArtLoader.Instance.GetTexture(graphic); if (texture != null) { texture.Ticks = Time.Ticks; ref var index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000); batcher.DrawSprite(texture, x - index.Width, y - index.Height, false, ref hue); }
// ## BEGIN - END ## // protected static void DrawLandWF(UltimaBatcher2D batcher, ushort graphic, int x, int y, ref Vector3 hue, bool isImpassable) { UOTexture texture = ArtLoader.Instance.GetLandTextureWF(graphic, isImpassable); if (texture != null) { texture.Ticks = Time.Ticks; batcher.DrawSprite(texture, x, y, false, ref hue); } }
public virtual bool Draw(UltimaBatcher2D batcher, int posX, int posY) { if (DrawTransparent) { int dist = Distance; int maxDist = Engine.Profile.Current.CircleOfTransparencyRadius + 1; if (dist <= maxDist) { HueVector.Z = MathHelper.Lerp(1f, 1f - dist / (float)maxDist, 0.5f); //HueVector.Z = 1f - (dist / (float)maxDist); } else { HueVector.Z = 1f - AlphaHue / 255f; } } else if (AlphaHue != 255) { HueVector.Z = 1f - AlphaHue / 255f; } if (Rotation != 0.0f) { if (!batcher.DrawSpriteRotated(Texture, posX, posY, Bounds.Width, Bounds.Height, Bounds.X, Bounds.Y, ref HueVector, Rotation)) { return(false); } } else if (IsFlipped) { if (!batcher.DrawSpriteFlipped(Texture, posX, posY, Bounds.Width, Bounds.Height, Bounds.X, Bounds.Y, ref HueVector)) { return(false); } } else { if (!batcher.DrawSprite(Texture, posX, posY, Bounds.Width, Bounds.Height, Bounds.X, Bounds.Y, ref HueVector)) { return(false); } } Select(posX, posY); Texture.Ticks = Engine.Ticks; return(true); }
private static sbyte DrawInternal(UltimaBatcher2D batcher, Mobile owner, Item entity, int x, int y, bool mirror, ref sbyte frameIndex, bool hasShadow, ushort id, bool isHuman, bool isParent = true, bool isMount = false) { if (id >= Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT || owner == null) { return(0); } ushort hueFromFile = _viewHue; byte animGroup = AnimationsLoader.Instance.AnimGroup; AnimationDirection direction = AnimationsLoader.Instance.GetBodyAnimationGroup(ref id, ref animGroup, ref hueFromFile, isParent).Direction[AnimationsLoader.Instance.Direction]; AnimationsLoader.Instance.AnimID = id; if (direction == null || direction.Address == -1 || direction.FileIndex == -1) { if (!(_transform && entity == null && !hasShadow)) { return(0); } } if (direction == null || ((direction.FrameCount == 0 || direction.Frames == null) && !AnimationsLoader.Instance.LoadDirectionGroup(ref direction))) { if (!(_transform && entity == null && !hasShadow)) { return(0); } } if (direction == null) { return(0); } direction.LastAccessTime = Time.Ticks; int fc = direction.FrameCount; if ((fc > 0 && frameIndex >= fc) || frameIndex < 0) { frameIndex = 0; } if (frameIndex < direction.FrameCount) { var frame = direction.Frames[frameIndex]; if (frame == null || frame.IsDisposed) { if (!(_transform && entity == null && !hasShadow)) { return(0); } goto SKIP; } frame.Ticks = Time.Ticks; if (mirror) { x -= frame.Width - frame.CenterX; } else { x -= frame.CenterX; } y -= frame.Height + frame.CenterY; SKIP: if (hasShadow) { batcher.DrawSpriteShadow(frame, x, y, mirror); } else { ushort hue = _viewHue; bool partialHue = false; if (hue == 0) { hue = entity?.Hue ?? owner.Hue; partialHue = !isMount && entity != null && entity.ItemData.IsPartialHue; if ((hue & 0x8000) != 0) { partialHue = true; hue &= 0x7FFF; } if (hue == 0) { hue = hueFromFile; if (hue == 0 && _equipConvData.HasValue) { hue = _equipConvData.Value.Color; } partialHue = false; } } ResetHueVector(); ShaderHuesTraslator.GetHueVector(ref HueVector, hue, partialHue, 0); if (_transform) { const float UPPER_BODY_RATIO = 0.35f; const float MID_BODY_RATIO = 0.60f; const float LOWER_BODY_RATIO = 0.94f; if (entity == null && isHuman) { int frameHeight = frame?.Height ?? 61; _characterFrameStartY = y - (frame != null ? 0 : (frameHeight - 4)); _characterFrameHeight = frameHeight; _startCharacterWaistY = (int)(frameHeight * UPPER_BODY_RATIO) + _characterFrameStartY; _startCharacterKneesY = (int)(frameHeight * MID_BODY_RATIO) + _characterFrameStartY; _startCharacterFeetY = (int)(frameHeight * LOWER_BODY_RATIO) + _characterFrameStartY; if (frame == null) { return(0); } } float h3mod = UPPER_BODY_RATIO; float h6mod = MID_BODY_RATIO; float h9mod = LOWER_BODY_RATIO; if (entity != null) { float itemsEndY = y + frame.Height; if (y >= _startCharacterWaistY) { h3mod = 0; } else if (itemsEndY <= _startCharacterWaistY) { h3mod = 1.0f; } else { float upperBodyDiff = _startCharacterWaistY - y; h3mod = upperBodyDiff / frame.Height; if (h3mod < 0) { h3mod = 0; } } if (_startCharacterWaistY >= itemsEndY || y >= _startCharacterKneesY) { h6mod = 0; } else if (_startCharacterWaistY <= y && itemsEndY <= _startCharacterKneesY) { h6mod = 1.0f; } else { float midBodyDiff; if (y >= _startCharacterWaistY) { midBodyDiff = _startCharacterKneesY - y; } else if (itemsEndY <= _startCharacterKneesY) { midBodyDiff = itemsEndY - _startCharacterWaistY; } else { midBodyDiff = _startCharacterKneesY - _startCharacterWaistY; } h6mod = h3mod + midBodyDiff / frame.Height; if (h6mod < 0) { h6mod = 0; } } if (itemsEndY <= _startCharacterKneesY) { h9mod = 0; } else if (y >= _startCharacterKneesY) { h9mod = 1.0f; } else { float lowerBodyDiff = itemsEndY - _startCharacterKneesY; h9mod = h6mod + lowerBodyDiff / frame.Height; if (h9mod < 0) { h9mod = 0; } } } batcher.DrawCharacterSitted(frame, x, y, mirror, h3mod, h6mod, h9mod, ref HueVector); } else if (frame != null) { batcher.DrawSprite(frame, x, y, mirror, ref HueVector); int yy = -(frame.Height + frame.CenterY + 3); int xx = -frame.CenterX; if (mirror) { xx = -(frame.Width - frame.CenterX); } if (xx < owner.FrameInfo.X) { owner.FrameInfo.X = xx; } if (yy < owner.FrameInfo.Y) { owner.FrameInfo.Y = yy; } if (owner.FrameInfo.Width < xx + frame.Width) { owner.FrameInfo.Width = xx + frame.Width; } if (owner.FrameInfo.Height < yy + frame.Height) { owner.FrameInfo.Height = yy + frame.Height; } } owner.Texture = frame; owner.Select(mirror ? x + frame.Width - SelectedObject.TranslatedMousePositionByViewport.X : SelectedObject.TranslatedMousePositionByViewport.X - x, SelectedObject.TranslatedMousePositionByViewport.Y - y); if (entity != null && entity.ItemData.IsLight) { Client.Game.GetScene <GameScene>().AddLight(owner, entity, mirror ? x + frame.Width : x, y); } } return(AnimationsLoader.Instance.DataIndex[id].MountedHeightOffset); } return(0); }
public virtual bool Draw(UltimaBatcher2D batcher, int posX, int posY) { if (DrawTransparent) { int x = RealScreenPosition.X; int y = RealScreenPosition.Y; int fx = (int)(World.Player.RealScreenPosition.X + World.Player.Offset.X); int fy = (int)(World.Player.RealScreenPosition.Y + (World.Player.Offset.Y - World.Player.Offset.Z)); int dist = Math.Max(Math.Abs(x - fx), Math.Abs(y - fy)); int maxDist = ProfileManager.Current.CircleOfTransparencyRadius; if (dist <= maxDist) { HueVector.Z = MathHelper.Lerp(1f, 1f - dist / (float)maxDist, 0.5f); //HueVector.Z = 1f - (dist / (float)maxDist); } else { HueVector.Z = 1f - AlphaHue / 255f; } } else if (AlphaHue != 255) { HueVector.Z = 1f - AlphaHue / 255f; } if (!batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector)) { return(false); } //if (Rotation != 0.0f) //{ // if (!batcher.DrawSpriteRotated(Texture, posX, posY, ref HueVector, Rotation)) // return false; //} //else //{ // //if (DrawTransparent) // //{ // // int dist = Distance; // // int maxDist = ProfileManager.Current.CircleOfTransparencyRadius + 1; // // if (dist <= maxDist) // // { // // HueVector.Z = 0.75f; // MathHelper.Lerp(1f, 1f - dist / (float)maxDist, 0.5f); // // //HueVector.Z = 1f - (dist / (float)maxDist); // // } // // else // // HueVector.Z = 1f - AlphaHue / 255f; // // batcher.DrawSprite(Texture, posX, posY, Bounds.Width, Bounds.Height, Bounds.X, Bounds.Y, ref HueVector); // // HueVector.Z = 0; // // batcher.SetStencil(_stencil.Value); // // batcher.DrawSprite(Texture, posX, posY, Bounds.Width, Bounds.Height, Bounds.X, Bounds.Y, ref HueVector); // // batcher.SetStencil(null); // //} // //else // { // if (!batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector)) // return false; // } //} Select(posX, posY); Texture.Ticks = Time.Ticks; return(true); }
public virtual bool Draw(UltimaBatcher2D batcher, int posX, int posY) { //if (DrawTransparent) //{ // int x = RealScreenPosition.X; // int y = RealScreenPosition.Y; // int fx = (int) (World.Player.RealScreenPosition.X + World.Player.Offset.X); // int fy = (int) (World.Player.RealScreenPosition.Y + (World.Player.Offset.Y - World.Player.Offset.Z)); // int dist = Math.Max(Math.Abs(x - fx), Math.Abs(y - fy)); // int maxDist = ProfileManager.Current.CircleOfTransparencyRadius; // if (dist <= maxDist) // { // HueVector.Z = MathHelper.Lerp(1f, 1f - dist / (float)maxDist, 0.5f); // //HueVector.Z = 1f - (dist / (float)maxDist); // } // else // HueVector.Z = 1f - AlphaHue / 255f; //} //else if (AlphaHue != 255) // HueVector.Z = 1f - AlphaHue / 255f; //if (!batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector)) // return false; if (DrawTransparent) { int maxDist = ProfileManager.Current.CircleOfTransparencyRadius + 44; int fx = (int)(World.Player.RealScreenPosition.X + World.Player.Offset.X); int fy = (int)(World.Player.RealScreenPosition.Y + (World.Player.Offset.Y - World.Player.Offset.Z)); fx -= posX; fy -= posY; int dist = (int)Math.Sqrt(fx * fx + fy * fy); //dist = Math.Max(Math.Abs(fx - x), Math.Abs(fy - y)); if (dist <= maxDist) { switch (ProfileManager.Current.CircleOfTransparencyType) { default: case 0: HueVector.Z = 0.75f; break; case 1: HueVector.Z = MathHelper.Lerp(1f, 0f, (dist / (float)maxDist)); break; } batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector); if (AlphaHue != 255) { HueVector.Z = 1f - AlphaHue / 255f; } else { HueVector.Z = 0; } batcher.SetStencil(_stencil.Value); batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector); batcher.SetStencil(null); goto COT; } } if (AlphaHue != 255) { HueVector.Z = 1f - AlphaHue / 255f; } if (!batcher.DrawSprite(Texture, posX - Bounds.X, posY - Bounds.Y, IsFlipped, ref HueVector)) { return(false); } COT: Select(posX, posY); Texture.Ticks = Time.Ticks; return(true); }
private void DrawLayer(UltimaBatcher2D batcher, int posX, int posY, Layer layer, byte animIndex, bool ishuman) { _equipConvData = null; ushort graphic; ushort color = 0; bool ispartialhue = false; if (layer == Layer.Invalid) { graphic = GetGraphicForAnimation(); AnimationsLoader.Instance.AnimGroup = AnimationsLoader.Instance.GetDieGroupIndex(graphic, UsedLayer); if (color == 0) { color = Hue; } } else if (HasEquipment && ishuman) { Item itemEquip = Equipment[(int)layer]; if (itemEquip == null) { return; } graphic = itemEquip.ItemData.AnimID; ispartialhue = itemEquip.ItemData.IsPartialHue; ushort mobGraphic = Amount; AnimationsLoader.Instance.ConvertBodyIfNeeded(ref mobGraphic); if (AnimationsLoader.Instance.EquipConversions.TryGetValue(mobGraphic, out Dictionary <ushort, EquipConvData> map)) { if (map.TryGetValue(graphic, out EquipConvData data)) { _equipConvData = data; graphic = data.Graphic; } } color = itemEquip.Hue; } else { return; } byte animGroup = AnimationsLoader.Instance.AnimGroup; ushort newHue = 0; AnimationGroup gr = layer == Layer.Invalid ? AnimationsLoader.Instance.GetCorpseAnimationGroup(ref graphic, ref animGroup, ref newHue) : AnimationsLoader.Instance.GetBodyAnimationGroup(ref graphic, ref animGroup, ref newHue); AnimationsLoader.Instance.AnimID = graphic; if (color == 0) { color = newHue; } var direction = gr.Direction[AnimationsLoader.Instance.Direction]; if (direction == null) { return; } if ((direction.FrameCount == 0 || direction.Frames == null) && !AnimationsLoader.Instance.LoadDirectionGroup(ref direction)) { return; } direction.LastAccessTime = Time.Ticks; int fc = direction.FrameCount; if (fc > 0 && animIndex >= fc) { animIndex = (byte)(fc - 1); } if (animIndex < direction.FrameCount) { AnimationFrameTexture frame = direction.Frames[animIndex]; if (frame == null || frame.IsDisposed) { return; } frame.Ticks = Time.Ticks; if (IsFlipped) { posX -= frame.Width - frame.CenterX; } else { posX -= frame.CenterX; } posY -= frame.Height + frame.CenterY; if (color == 0) { if ((color & 0x8000) != 0) { ispartialhue = true; color &= 0x7FFF; } if (color == 0 && _equipConvData.HasValue) { color = _equipConvData.Value.Color; ispartialhue = false; } } ResetHueVector(); if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange) { HueVector.X = Constants.OUT_RANGE_COLOR; HueVector.Y = 1; } else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect) { HueVector.X = Constants.DEAD_RANGE_COLOR; HueVector.Y = 1; } else { if (ProfileManager.Current.GridLootType > 0 && SelectedObject.CorpseObject == this) { color = 0x0034; } else if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this) { color = 0x0023; } ShaderHuesTraslator.GetHueVector(ref HueVector, color, ispartialhue, 0); } Texture = frame; batcher.DrawSprite(frame, posX, posY, IsFlipped, ref HueVector); Select(IsFlipped ? posX + frame.Width - SelectedObject.TranslatedMousePositionByViewport.X : SelectedObject.TranslatedMousePositionByViewport.X - posX, SelectedObject.TranslatedMousePositionByViewport.Y - posY); } }
private static sbyte DrawInternal ( UltimaBatcher2D batcher, Mobile owner, Item entity, int x, int y, ref Vector3 hueVec, bool mirror, sbyte frameIndex, bool hasShadow, ushort id, byte animGroup, byte dir, bool isHuman, bool isParent = true, bool isMount = false, bool forceUOP = false, float alpha = 0 ) { if (id >= Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT || owner == null) { return(0); } ushort hueFromFile = _viewHue; AnimationDirection direction = AnimationsLoader.Instance.GetBodyAnimationGroup ( ref id, ref animGroup, ref hueFromFile, isParent, forceUOP ) .Direction[dir]; if (direction == null || direction.Address == -1 || direction.FileIndex == -1) { if (!(_transform && entity == null && !hasShadow)) { return(0); } } if (direction == null || (direction.FrameCount == 0 || direction.Frames == null) && !AnimationsLoader.Instance.LoadAnimationFrames(id, animGroup, dir, ref direction)) { if (!(_transform && entity == null && !hasShadow)) { return(0); } } if (direction == null) { return(0); } direction.LastAccessTime = Time.Ticks; int fc = direction.FrameCount; if (fc > 0 && frameIndex >= fc) { frameIndex = (sbyte)(fc - 1); } else if (frameIndex < 0) { frameIndex = 0; } if (frameIndex < direction.FrameCount) { AnimationFrameTexture frame = direction.Frames[frameIndex]; if (frame == null || frame.IsDisposed) { if (!(_transform && entity == null && !hasShadow)) { return(0); } goto SKIP; } frame.Ticks = Time.Ticks; if (mirror) { x -= frame.Width - frame.CenterX; } else { x -= frame.CenterX; } y -= frame.Height + frame.CenterY; SKIP: if (hasShadow) { batcher.DrawSpriteShadow(frame, x, y, mirror); } else { ushort hue = _viewHue; bool partialHue = false; if (hue == 0) { hue = entity?.Hue ?? owner.Hue; partialHue = !isMount && entity != null && entity.ItemData.IsPartialHue; if ((hue & 0x8000) != 0) { partialHue = true; hue &= 0x7FFF; } if (hue == 0) { hue = hueFromFile; if (hue == 0 && _equipConvData.HasValue) { hue = _equipConvData.Value.Color; } partialHue = false; } } hueVec = Vector3.Zero; ShaderHueTranslator.GetHueVector(ref hueVec, hue, partialHue, alpha); // this is an hack to make entities partially hued. OG client seems to ignore this. /*if (entity != null && entity.ItemData.AnimID == 0 && entity.ItemData.IsLight) * { * HueVector.X = entity.Hue == 0 ? owner.Hue : entity.Hue; * HueVector.Y = ShaderHueTranslator.SHADER_LIGHTS; * HueVector.Z = alpha; * } */ if (_transform) { const float UPPER_BODY_RATIO = 0.35f; const float MID_BODY_RATIO = 0.60f; const float LOWER_BODY_RATIO = 0.94f; if (entity == null && isHuman) { int frameHeight = frame?.Height ?? 61; _characterFrameStartY = y - (frame != null ? 0 : frameHeight - SIT_OFFSET_Y); _characterFrameHeight = frameHeight; _startCharacterWaistY = (int)(frameHeight * UPPER_BODY_RATIO) + _characterFrameStartY; _startCharacterKneesY = (int)(frameHeight * MID_BODY_RATIO) + _characterFrameStartY; _startCharacterFeetY = (int)(frameHeight * LOWER_BODY_RATIO) + _characterFrameStartY; if (frame == null) { return(0); } } float h3mod = UPPER_BODY_RATIO; float h6mod = MID_BODY_RATIO; float h9mod = LOWER_BODY_RATIO; if (entity != null) { float itemsEndY = y + frame.Height; if (y >= _startCharacterWaistY) { h3mod = 0; } else if (itemsEndY <= _startCharacterWaistY) { h3mod = 1.0f; } else { float upperBodyDiff = _startCharacterWaistY - y; h3mod = upperBodyDiff / frame.Height; if (h3mod < 0) { h3mod = 0; } } if (_startCharacterWaistY >= itemsEndY || y >= _startCharacterKneesY) { h6mod = 0; } else if (_startCharacterWaistY <= y && itemsEndY <= _startCharacterKneesY) { h6mod = 1.0f; } else { float midBodyDiff; if (y >= _startCharacterWaistY) { midBodyDiff = _startCharacterKneesY - y; } else if (itemsEndY <= _startCharacterKneesY) { midBodyDiff = itemsEndY - _startCharacterWaistY; } else { midBodyDiff = _startCharacterKneesY - _startCharacterWaistY; } h6mod = h3mod + midBodyDiff / frame.Height; if (h6mod < 0) { h6mod = 0; } } if (itemsEndY <= _startCharacterKneesY) { h9mod = 0; } else if (y >= _startCharacterKneesY) { h9mod = 1.0f; } else { float lowerBodyDiff = itemsEndY - _startCharacterKneesY; h9mod = h6mod + lowerBodyDiff / frame.Height; if (h9mod < 0) { h9mod = 0; } } } batcher.DrawCharacterSitted ( frame, x, y, mirror, h3mod, h6mod, h9mod, ref hueVec ); } else if (frame != null) { batcher.DrawSprite ( frame, x, y, mirror, ref hueVec ); int yy = -(frame.Height + frame.CenterY + 3); int xx = -frame.CenterX; if (mirror) { xx = -(frame.Width - frame.CenterX); } if (xx < owner.FrameInfo.X) { owner.FrameInfo.X = xx; } if (yy < owner.FrameInfo.Y) { owner.FrameInfo.Y = yy; } if (owner.FrameInfo.Width < xx + frame.Width) { owner.FrameInfo.Width = xx + frame.Width; } if (owner.FrameInfo.Height < yy + frame.Height) { owner.FrameInfo.Height = yy + frame.Height; } } if (AnimationsLoader.Instance.PixelCheck(id, animGroup, dir, direction.IsUOP, frameIndex, mirror ? x + frame.Width - SelectedObject.TranslatedMousePositionByViewport.X : SelectedObject.TranslatedMousePositionByViewport.X - x, SelectedObject.TranslatedMousePositionByViewport.Y - y)) { SelectedObject.Object = owner; } if (entity != null && entity.ItemData.IsLight) { Client.Game.GetScene <GameScene>().AddLight(owner, entity, mirror ? x + frame.Width : x, y); } } return(AnimationsLoader.Instance.DataIndex[id].MountedHeightOffset); } return(0); }