Did you know that PaintWorld(layer) is called twice? menu

User Tag List

Results 1 to 5 of 5
  1. #1
    JarJarD3's Avatar Contributor
    Reputation
    106
    Join Date
    Oct 2017
    Posts
    395
    Thanks G/R
    41/101
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Did you know that PaintWorld(layer) is called twice?

    Just for those that want to "optimize" their code, I ques.

    I found that only MonsterPackPlugin does check which layer to use.
    Code:
    if (layer != WorldLayer.Ground)
        return;
    All other plugins execute their PaintWorld method twice, or I did not understand this at all.
    For those plugins that draw both on world map and mini map this is of course convenient!

    Did you know that PaintWorld(layer) is called twice?
  2. Thanks RNN (1 members gave Thanks to JarJarD3 for this useful post)
  3. #2
    KillerJohn's Avatar TurboHUD HUDmaster CoreCoins Purchaser Authenticator enabled
    Reputation
    3693
    Join Date
    Jul 2012
    Posts
    2,532
    Thanks G/R
    46/3335
    Trade Feedback
    0 (0%)
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    yes, it does, but it is by design, because each decorator has a "Layer" property.

    public class MonsterRiftProgressionColoringPlugin : BasePlugin, IInGameWorldPainter
    {
    public void PaintWorld(WorldLayer layer)
    {
    .......
    decorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
    }
    }

    you can see? it passes the layer to the decorator (which is a WorldDecoratorCollection)
    WorldDecoratorCollection.Paint iterates through all decorators which belongs to the given layer and paints only those

    this way you don't have to separate your painter into two methods, but allow the same PaintWorld method be called twice, and let the automagic decide which decorator will be used
    Do not send me private messages unless it is absolutely necessary or the content is sensitive or when I ask you to do that...

  4. #3
    JarJarD3's Avatar Contributor
    Reputation
    106
    Join Date
    Oct 2017
    Posts
    395
    Thanks G/R
    41/101
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Originally Posted by KillerJohn View Post
    yes, it does, but it is by design, because each decorator has a "Layer" property.

    public class MonsterRiftProgressionColoringPlugin : BasePlugin, IInGameWorldPainter
    {
    public void PaintWorld(WorldLayer layer)
    {
    .......
    decorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
    }
    }

    you can see? it passes the layer to the decorator (which is a WorldDecoratorCollection)
    WorldDecoratorCollection.Paint iterates through all decorators which belongs to the given layer and paints only those

    this way you don't have to separate your painter into two methods, but allow the same PaintWorld method be called twice, and let the automagic decide which decorator will be used
    Yes, I understand that this is by design and for convenience.
    And it is good but I have seen here code from people that do not understand programming so well as we
    I just wanted to point out that you might want to optimize your code sometimes?

  5. #4
    RNN's Avatar Legendary
    Reputation
    813
    Join Date
    Sep 2018
    Posts
    1,055
    Thanks G/R
    104/776
    Trade Feedback
    0 (0%)
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    It is good to know this. The plugins that use decorators that apply only to Ground can prevent Paintworld from being processed twice unnecessarily by adding
    if (layer != WorldLayer.Ground) return;

  6. #5
    RNN's Avatar Legendary
    Reputation
    813
    Join Date
    Sep 2018
    Posts
    1,055
    Thanks G/R
    104/776
    Trade Feedback
    0 (0%)
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    It is curious that this can be done to prevent PaintWorld from being processed twice, in plugins containing many instructions it can save a lot of processing time.

    Code to express the idea, it is not functional:

    Code:
    		public WorldDecoratorCollection Decorator { get; set; }
    		public void PaintWorld(WorldLayer layer)
    		{
    			Decorator.Paint(layer, actor, actor.FloorCoordinate, null);
    		}
    replaced by this

    Code:
    		public WorldDecoratorCollection Decorator { get; set; }
    		public void PaintWorld(WorldLayer layer)
    		{
    			if (layer != WorldLayer.Ground) return;
    			Decorator.Paint(layer, actor, actor.FloorCoordinate, null);
    			Decorator.Paint(WorldLayer.Map, actor, actor.FloorCoordinate, null);
    		}

Similar Threads

  1. SO, did you know tag sharing is banable? Yeah news to me...
    By CreativeXtent in forum World of Warcraft General
    Replies: 12
    Last Post: 02-07-2013, 11:31 AM
  2. [Profession] Did you know that Tailoring is profitable?
    By Raage in forum World of Warcraft Guides
    Replies: 5
    Last Post: 06-11-2010, 10:20 PM
  3. Did you know that people have to release there core due to law?
    By Hunterplay in forum World of Warcraft Emulator Servers
    Replies: 25
    Last Post: 05-05-2009, 05:55 PM
  4. How you know when a scam is done with
    By runemaster in forum WoW Scam Prevention
    Replies: 13
    Last Post: 12-04-2008, 09:11 PM
All times are GMT -5. The time now is 05:21 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search