Пример #1
0
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, cursor);

            Skill = new ObjectBase(true, Buffer, cursor);
            cursor += Skill.ByteLength;

            return cursor - StartIndex;
        }
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, StartIndex);

            BuffType = (BuffType)Buffer[cursor];
            cursor++;

            NewBuffObject = new ObjectBase(true, Buffer, cursor);
            cursor += NewBuffObject.ByteLength;

            return cursor - StartIndex;
        }
Пример #3
0
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, cursor);

            ushort len = BitConverter.ToUInt16(Buffer, cursor);
            cursor += TypeSizes.SHORT;

            Skills = new ObjectBase[len];
            for (int i = 0; i < len; i++)
            {
                Skills[i] = new ObjectBase(true, Buffer, cursor);
                cursor += Skills[i].ByteLength;
            }

            return cursor - StartIndex;
        }
Пример #4
0
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, cursor);

            TradePartner = new ObjectBase(true, Buffer, cursor);
            cursor += TradePartner.ByteLength;

            ushort len = BitConverter.ToUInt16(Buffer, cursor);
            cursor += TypeSizes.SHORT;

            OfferedItems = new TradeOfferObject[len];
            for (int i = 0; i < len; i++)
            {
                OfferedItems[i] = new TradeOfferObject(Buffer, cursor);
                cursor += OfferedItems[i].ByteLength;
            }

            return cursor - StartIndex;
        }
Пример #5
0
 public void UpdateFromModel(SpellInfo Model, bool RaiseChangedEvent)
 {
     if (RaiseChangedEvent)
     {
         Message    = Model.Message;
         SchoolName = Model.SchoolName;
         SpellLevel = Model.SpellLevel;
         ManaCost   = Model.ManaCost;
         VigorCost  = Model.VigorCost;
         ObjectBase = Model.ObjectBase;
         // don't isvisible
     }
     else
     {
         message    = Model.Message;
         schoolName = Model.SchoolName;
         spellLevel = Model.SpellLevel;
         manaCost   = Model.ManaCost;
         vigorCost  = Model.VigorCost;
         objectBase = Model.ObjectBase;
         // don't isvisible
     }
 }
Пример #6
0
 public void Clear(bool RaiseChangedEvent)
 {
     if (RaiseChangedEvent)
     {
         ObjectBase = new ObjectBase();
         Message    = new ServerString();
         SchoolName = new ServerString();
         SpellLevel = new ServerString();
         ManaCost   = new ServerString();
         VigorCost  = new ServerString();
         IsVisible  = false;
     }
     else
     {
         objectBase = new ObjectBase();
         message    = new ServerString();
         schoolName = new ServerString();
         spellLevel = new ServerString();
         manaCost   = new ServerString();
         vigorCost  = new ServerString();
         isVisible  = false;
     }
 }
Пример #7
0
        public override unsafe void ReadFrom(ref byte* Buffer)
        {
            base.ReadFrom(ref Buffer);

            ushort len = *((ushort*)Buffer);
            Buffer += TypeSizes.SHORT;

            Skills = new ObjectBase[len];
            for (int i = 0; i < len; i++)
                Skills[i] = new ObjectBase(true, ref Buffer);

        }
 public CounterOfferMessage(ObjectBase[] OfferedItems)
     : base(MessageTypeGameMode.CounterOffer)
 {           
     this.OfferedItems = OfferedItems;           
 }
Пример #9
0
        protected void Calculate(
            ObjectBase Data,
            BgfBitmap MainFrame,
            bool UseViewerFrame = true,
            bool ApplyYOffset = true,
            byte RootHotspotIndex = 0,
            Real Quality = DEFAULTQUALITY,
            bool ScalePow2 = false,
            uint Width = 0,
            uint Height = 0,
            bool CenterVertical = false,
            bool CenterHorizontal = false)
        {
            BgfBitmap mainFrame = MainFrame;
            BgfFile mainResource = Data.Resource;
            byte mainColor = Data.ColorTranslation;
            BgfBitmap subOvFrame;
            BgfBitmapHotspot subOvHotspot;
            SubOverlay subOvParent;
            BgfBitmap subOvParentFrame;
            BgfBitmapHotspot subOvParentHotspot;
            bool rootSpotFound = false;

            // use custom compose root (suboverlay=mainoverlay)
            // if it's not found, fallback to full compose
            if (RootHotspotIndex > 0)
            {
                SubOverlay subOv = Data.GetSubOverlayByHotspot(RootHotspotIndex);

                if (subOv != null)
                {
                    rootSpotFound = true;

                    if (UseViewerFrame)
                        mainFrame = subOv.ViewerFrame;
                    else
                        mainFrame = subOv.FrontFrame;

                    mainResource = subOv.Resource;
                    mainColor = subOv.ColorTranslation;
                }
            }

            if (mainFrame != null && mainResource != null)
            {
                Bgf = mainFrame;
                BgfColor = mainColor;
                size.X = (Real)mainFrame.Width / (Real)mainResource.ShrinkFactor;
                size.Y = (Real)mainFrame.Height / (Real)mainResource.ShrinkFactor;
                origin.X = (Real)mainFrame.XOffset / (Real)mainResource.ShrinkFactor;
                origin.Y = (Real)mainFrame.YOffset / (Real)mainResource.ShrinkFactor;
                MaxShrink = mainResource.ShrinkFactor;

                // used to calculate the boundingbox
                V2 min = new V2(Origin.X, Origin.Y);
                V2 max = (ApplyYOffset) ? 
                    new V2(Size.X, Size.Y) : 
                    new V2(Origin.X + Size.X, Origin.Y + Size.Y);

                Real x, y;

                // walk suboverlay structure
                foreach (SubOverlay subOv in Data.CurrentSubOverlays)
                {
                    if (UseViewerFrame)
                    {
                        subOvFrame = subOv.ViewerFrame;
                        subOvHotspot = subOv.ViewerHotspot;
                        subOvParent = subOv.ViewerParent;
                    }
                    else
                    {
                        subOvFrame = subOv.FrontFrame;
                        subOvHotspot = subOv.FrontHotspot;
                        subOvParent = subOv.FrontParent;
                    }

                    bool isSubRoot = (subOvParent != null && subOvParent.HotSpot == RootHotspotIndex);

                    if (subOv.Resource != null &&
                        subOvFrame != null &&
                        subOvHotspot != null &&
                        (RootHotspotIndex <= 0 || !rootSpotFound || isSubRoot))
                    {
                        SubOverlay.RenderInfo subOvInfo = new SubOverlay.RenderInfo();
                        
                        // save subov & bitmap
                        subOvInfo.SubOverlay = subOv;
                        subOvInfo.Bgf = subOvFrame;

                        // calculate the size of this suboverlay
                        subOvInfo.Size.X = (Real)subOvFrame.Width / (Real)subOv.Resource.ShrinkFactor;
                        subOvInfo.Size.Y = (Real)subOvFrame.Height / (Real)subOv.Resource.ShrinkFactor;

                        // update maxshrink if greater
                        if (subOv.Resource.ShrinkFactor > MaxShrink)
                            MaxShrink = subOv.Resource.ShrinkFactor;

                        // CASE 1: SubOverlay on mainoverlay
                        if (subOvParent == null || isSubRoot)
                        {
                            // calculate the origin of this suboverlay on the mainoverlay
                            subOvInfo.Origin.X = mainFrame.XOffset
                                + ((Real)subOvHotspot.X)
                                + ((Real)subOvFrame.XOffset);

                            subOvInfo.Origin.Y = mainFrame.YOffset
                                + ((Real)subOvHotspot.Y)
                                + ((Real)subOvFrame.YOffset);

                            subOvInfo.Origin.X /= mainResource.ShrinkFactor;
                            subOvInfo.Origin.Y /= mainResource.ShrinkFactor;

                            // determine type of hotspot
                            if (subOvHotspot.Index < 0)
                                subOvInfo.HotspotType = HotSpotType.HOTSPOT_UNDER;
                            else
                                subOvInfo.HotspotType = HotSpotType.HOTSPOT_OVER;
                        }

                        // CASE 2: SubOverlay on SubOverlay on MainOverlay
                        else
                        {
                            if (UseViewerFrame)
                            {
                                subOvParentFrame = subOvParent.ViewerFrame;
                                subOvParentHotspot = subOvParent.ViewerHotspot;
                            }
                            else
                            {
                                subOvParentFrame = subOvParent.FrontFrame;
                                subOvParentHotspot = subOvParent.FrontHotspot;
                            }

                            if (subOvParentHotspot != null &&
                                subOvParentFrame != null &&
                                subOvParent.Resource != null)
                            {
                                // calculate the origin of this suboverlay on the suboverlay on the mainoverlay
                                subOvInfo.Origin.X = 
                                    (mainFrame.XOffset +
                                    (Real)subOvParentHotspot.X +
                                    (Real)subOvParentFrame.XOffset) / (Real)mainResource.ShrinkFactor;

                                subOvInfo.Origin.X +=
                                    ((Real)subOvHotspot.X +
                                    (Real)subOvFrame.XOffset) / (Real)subOvParent.Resource.ShrinkFactor;

                                subOvInfo.Origin.Y = 
                                    (mainFrame.YOffset +
                                    (Real)subOvParentHotspot.Y +
                                    (Real)subOvParentFrame.YOffset) / (Real)mainResource.ShrinkFactor;

                                subOvInfo.Origin.Y +=
                                    ((Real)subOvHotspot.Y +
                                    (Real)subOvFrame.YOffset) / (Real)subOvParent.Resource.ShrinkFactor;

                                // determine type of nested hotspot
                                if (subOvParentHotspot.Index > 0 && subOvHotspot.Index > 0)
                                    subOvInfo.HotspotType = HotSpotType.HOTSPOT_OVEROVER;

                                else if (subOvParentHotspot.Index > 0 && subOvHotspot.Index < 0)
                                    subOvInfo.HotspotType = HotSpotType.HOTSPOT_OVERUNDER;

                                else if (subOvParentHotspot.Index < 0 && subOvHotspot.Index > 0)
                                    subOvInfo.HotspotType = HotSpotType.HOTSPOT_UNDEROVER;

                                else if (subOvParentHotspot.Index < 0 && subOvHotspot.Index < 0)
                                    subOvInfo.HotspotType = HotSpotType.HOTSPOT_UNDERUNDER;
                            }
                        }

                        // update max boundingbox
                        if (subOvInfo.Origin.X < min.X)
                            min.X = subOvInfo.Origin.X;

                        if (subOvInfo.Origin.Y < min.Y)
                            min.Y = subOvInfo.Origin.Y;

                        x = subOvInfo.Origin.X + subOvInfo.Size.X;
                        y = subOvInfo.Origin.Y + subOvInfo.Size.Y;

                        if (x > max.X)
                            max.X = x;

                        if (y > max.Y)
                            max.Y = y;

                        // save info for this suboverlay
                        SubBgf.Add(subOvInfo);
                    }
                }

                // get dimension from boundingbox
                dimension.X = Math.Abs(max.X - min.X);
                dimension.Y = Math.Abs(max.Y - min.Y);

                // move all origins so minimum hits 0/0
                // preparation for drawing (pixel origin is 0/0)
                Translate(-min);

                // get the center of the dimension box
                // this is also the center of our image after the translate above
                V2 bbCenter = dimension * 0.5f;

                // get the center of the main overlay
                V2 mainOriginCenter = Origin + (Size * 0.5f);

                // move the x center of the main overlay to the x center of dimensionbox
                V2 centerMove = new V2(bbCenter.X - mainOriginCenter.X, 0.0f);
                Translate(centerMove);

                // since this moves a part outside the dimension box
                // we need to add this size of the move to the dimension, 
                // to the right AND left side, so our centering above stays centered
                // then we remove to the center.
                V2 center = new V2(Math.Abs(centerMove.X), 0.0f);
                dimension.X += center.X * 2.0f;
                Translate(center);

                // scale so highest resolution resource has 1:1 ratio (no downscale)
                // and apply custom quality level
                Scale((Real)MaxShrink);

                // scale up to pow2 if set
                if (ScalePow2)
                {
                    Real maxQuality = Quality * QUALITYBASE;
                    Real ratioX = maxQuality / dimension.X;
                    Real ratioY = maxQuality / dimension.Y;

                    if (ratioX <= ratioY && ratioX < 1.0f)
                        Scale(ratioX);
                    else if (ratioX > ratioY && ratioY < 1.0f)
                        Scale(ratioY);

                    // get next power of 2 size
                    V2 pow2Size = new V2(
                        MathUtil.NextPowerOf2((uint)dimension.X),
                        MathUtil.NextPowerOf2((uint)dimension.Y));

                    // scale so we use at least all pixels either from upscaled width or height
                    ScaleToBox(pow2Size, CenterHorizontal, CenterVertical);
                }
                else if (Width > 0 && Height > 0)
                {
                    // use user given size
                    V2 userSize = new V2(Width, Height);

                    // scale so we use at least all pixels either from upscaled width or height
                    ScaleToBox(userSize, CenterHorizontal, CenterVertical);
                }
            }
        }
Пример #10
0
 public BuyListMessage(ObjectBase TradePartner, TradeOfferObject[] OfferedItems)
     : base(MessageTypeGameMode.BuyList)
 {           
     this.TradePartner = TradePartner; 
     this.OfferedItems = OfferedItems;          
 }
Пример #11
0
        /// <summary>
        /// Updates values of this instance to values taken from parameter instance.
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="RaiseChangedEvent"></param>
        public override void UpdateFromModel(ObjectBase Model, bool RaiseChangedEvent)
        {
            base.UpdateFromModel(Model, RaiseChangedEvent);

            if (RaiseChangedEvent)
            {
                OverlayFileRID = Model.OverlayFileRID;
                NameRID        = Model.NameRID;
                Flags.UpdateFromModel(Model.Flags, RaiseChangedEvent);
                LightFlags         = Model.LightFlags;
                LightIntensity     = Model.LightIntensity;
                LightColor         = Model.LightColor;
                FirstAnimationType = Model.FirstAnimationType;
                ColorTranslation   = Model.ColorTranslation;
                Effect             = Model.Effect;

                if (Animation != null)
                {
                    Animation.PropertyChanged -= OnAnimationPropertyChanged;
                }

                Animation = Model.Animation;
                Animation.PropertyChanged += OnAnimationPropertyChanged;

                subOverlays.Clear();
                subOverlays.AddRange(Model.SubOverlays);

                Name        = Model.Name;
                OverlayFile = Model.OverlayFile;
                Resource    = Model.Resource;
            }
            else
            {
                overlayFileRID = Model.OverlayFileRID;
                nameRID        = Model.NameRID;
                Flags.UpdateFromModel(Model.Flags, RaiseChangedEvent);
                lightFlags         = Model.LightFlags;
                lightIntensity     = Model.LightIntensity;
                lightColor         = Model.LightColor;
                firstAnimationType = Model.FirstAnimationType;
                colorTranslation   = Model.ColorTranslation;
                effect             = Model.Effect;

                if (animation != null)
                {
                    animation.PropertyChanged -= OnAnimationPropertyChanged;
                }

                animation = Model.Animation;
                animation.PropertyChanged += OnAnimationPropertyChanged;

                subOverlays.Clear();
                subOverlays.AddRange(Model.SubOverlays);

                name        = Model.Name;
                overlayFile = Model.OverlayFile;
                resource    = Model.Resource;
            }

            // appearance update
            ProcessAppearance(true);
        }
Пример #12
0
        public GuildShieldInfo()
        {
            ExampleModel = new ObjectBase();

            Clear(false);
        }
        /// <summary>
        /// Updates the ViewerParent and ViewerHotspot property.
        /// </summary>
        /// <param name="Root">The object this suboverlay belongs to</param>
        /// <param name="SubOverlays">The current suboverlays of the object</param>
        public void UpdateHotspots(ObjectBase Root, IList<SubOverlay> SubOverlays)
        {
            FrontParent = null;
            FrontHotspot = null;
            ViewerParent = null;
            ViewerHotspot = null;

            // try find hotspot on active mainoverlay frame
            if (Root.ViewerFrame != null)
                ViewerHotspot = Root.ViewerFrame.FindHotspot(hotSpot);

            // if not found
            if (ViewerHotspot == null)
            {
                // try find on suboverlays
                foreach (SubOverlay subOv in SubOverlays)
                {
                    if (subOv.ViewerFrame != null)
                    {
                        ViewerHotspot = subOv.ViewerFrame.FindHotspot(hotSpot);
                        if (ViewerHotspot != null)
                        {
                            ViewerParent = subOv;
                            break;
                        }
                    }
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Updates values of this instance to values taken from parameter instance.
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="RaiseChangedEvent"></param>
        public override void UpdateFromModel(ObjectBase Model, bool RaiseChangedEvent)
        {
            base.UpdateFromModel(Model, RaiseChangedEvent);

            if (RaiseChangedEvent)
            {
                OverlayFileRID = Model.OverlayFileRID;
                NameRID = Model.NameRID;
                Flags.UpdateFromModel(Model.Flags, RaiseChangedEvent);
                LightFlags = Model.LightFlags;
                LightIntensity = Model.LightIntensity;
                LightColor = Model.LightColor;
                FirstAnimationType = Model.FirstAnimationType;
                ColorTranslation = Model.ColorTranslation;
                Effect = Model.Effect;
                
                if (Animation != null)
                    Animation.PropertyChanged -= OnAnimationPropertyChanged;

                Animation = Model.Animation;
                Animation.PropertyChanged += OnAnimationPropertyChanged;

                subOverlays.Clear();
                subOverlays.AddRange(Model.SubOverlays);
               
                Name = Model.Name;
                OverlayFile = Model.OverlayFile;
                Resource = Model.Resource;
            }
            else
            {
                overlayFileRID = Model.OverlayFileRID;
                nameRID = Model.NameRID;
                Flags.UpdateFromModel(Model.Flags, RaiseChangedEvent);
                lightFlags = Model.LightFlags;
                lightIntensity = Model.LightIntensity;
                lightColor = Model.LightColor;
                firstAnimationType = Model.FirstAnimationType;
                colorTranslation = Model.ColorTranslation;
                effect = Model.Effect;

                if (animation != null)
                    animation.PropertyChanged -= OnAnimationPropertyChanged;

                animation = Model.Animation;
                animation.PropertyChanged += OnAnimationPropertyChanged;

                subOverlays.Clear();
                subOverlays.AddRange(Model.SubOverlays);
                
                name = Model.Name;
                overlayFile = Model.OverlayFile;
                resource = Model.Resource;
            }
            
            // appearance update
            ProcessAppearance(true);
        }
 public AddEnchantmentMessage(BuffType BuffType, ObjectBase buffObject) 
     : base(MessageTypeGameMode.AddEnchantment)
 {         
     this.BuffType = BuffType;
     this.NewBuffObject = buffObject;
 }
 public ObjectContentsMessage(ObjectID ObjectID, ObjectBase[] InventoryObjects) 
     : base(MessageTypeGameMode.ObjectContents)
 {
     this.ObjectID = ObjectID;
     this.ContentObjects = InventoryObjects;
 }
Пример #17
0
 public SkillAddMessage(ObjectBase Skill) 
     : base(MessageTypeGameMode.SkillAdd)
 {         
     this.Skill = Skill;                      
 }
Пример #18
0
 public QuestObjectInfo(ObjectBase ObjectBase, ServerString Description, ServerString Requirements)
 {
     objectBase   = ObjectBase;
     description  = Description;
     requirements = Requirements;
 }
Пример #19
0
        public GuildShieldInfo(byte[] Buffer, int StartIndex = 0)
        {
            ExampleModel = new ObjectBase();

            ReadFrom(Buffer, StartIndex);
        }
Пример #20
0
 public OfferedMessage(ObjectBase[] OfferedItems)
     : base(MessageTypeGameMode.Offered)
 {           
     this.OfferedItems = OfferedItems;         
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="RaiseChangedEvent"></param>
 public void Clear(bool RaiseChangedEvent)
 {
     if (RaiseChangedEvent)
     {
         IsVisible = false;
         IsPending = false;
         IsBackgroundOffer = false;
         IsItemsYouSet = false;
         IsItemsPartnerSet = false;
         TradePartner = null;
         itemsYou.Clear();
         itemsPartner.Clear();
     }
     else
     {
         isVisible = false;
         isPending = false;
         isBackgroundOffer = false;
         isItemsYouSet = false;
         isItemsPartnerSet = false;
         tradePartner = null;
         itemsYou.Clear();
         itemsPartner.Clear();
     }
 }
 public WithdrawAlListMessage(ObjectBase NPC, TradeOfferObject[] Items)
     : base(MessageTypeGameMode.WithDrawAlList)
 {
     this.NPC = NPC;
     this.Items = Items;         
 }
Пример #23
0
        public RenderInfo(
            ObjectBase Data,
            bool ApplyYOffset = true,
            byte RootHotspotIndex = 0,
            Real Quality = DEFAULTQUALITY,
            bool ScalePow2 = false,
            uint Width = 0,
            uint Height = 0,
            bool CenterVertical = false,
            bool CenterHorizontal = false)
        {
            Clear();

            Calculate(Data, Data.ViewerFrame, true, ApplyYOffset, RootHotspotIndex, Quality, ScalePow2, Width, Height, CenterVertical, CenterHorizontal);
        }
Пример #24
0
 public SkillsMessage(ObjectBase[] Skills) 
     : base(MessageTypeGameMode.Skills)
 {           
     this.Skills = Skills;
 }
Пример #25
0
 public void Clear(bool RaiseChangedEvent)
 {
     if (RaiseChangedEvent)
     {
         TradePartner = null;
         Items.Clear();
         IsVisible = false;
     }
     else
     {
         tradePartner = null;
         items.Clear();
         isVisible = false;
     }
 }
Пример #26
0
 public OfferMessage(ObjectBase TradePartner, ObjectBase[] OfferedItems)
     : base(MessageTypeGameMode.Offer)
 {           
     this.TradePartner = TradePartner; 
     this.OfferedItems = OfferedItems;           
 }