Advertisement
Guest User

Untitled

a guest
Mar 9th, 2020
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System.Collections.Generic;
  3.  
  4. namespace Turbo.Plugins.Miqui.CustomizableActorDecorators
  5. {
  6.     public class CustomizableActorDecoratorsPlugin : BasePlugin, IInGameWorldPainter
  7.     {
  8.         private Dictionary<ActorSnoEnum, List<IActorDecorator>> ActorDecorators { get ; set ; }
  9.  
  10.         public CustomizableActorDecoratorsPlugin()
  11.         {
  12.             Enabled = true;
  13.         }
  14.  
  15.         public override void Load(IController hud)
  16.         {
  17.             base.Load(hud);
  18.             ActorDecorators = new Dictionary<ActorSnoEnum, List<IActorDecorator>>();
  19.         }
  20.  
  21.         /// Allows you to add a decorator for the given Actor.
  22.         public void AddDecorator(ActorSnoEnum actor, IActorDecorator decorator)
  23.         {
  24.             List<IActorDecorator> l;
  25.            
  26.             if (!ActorDecorators.TryGetValue(actor, out l))
  27.             {
  28.                 l = new List<IActorDecorator>();
  29.             }
  30.            
  31.             l.Add(decorator);
  32.             ActorDecorators[actor] = l;
  33.         }
  34.  
  35.         /// Allows you to set the decorators for the given Actor.
  36.         public void SetDecorators(ActorSnoEnum actor, List<IActorDecorator> decorators)
  37.         {
  38.             ActorDecorators[actor] = decorators;
  39.         }
  40.  
  41.         public void PaintWorld(WorldLayer layer)
  42.         {
  43.             Hud.Game.Actors.ForEach(actor =>
  44.             {
  45.                 List<IActorDecorator> decorators;
  46.                 if (ActorDecorators.TryGetValue(actor.SnoActor.Sno, out decorators))
  47.                 {
  48.                     decorators.ForEach(decorator =>
  49.                     {
  50.                         var toPaint = decorator.getActorDecorator(Hud, actor);
  51.                         if (toPaint != null)
  52.                             toPaint.Paint(layer, actor, actor.FloorCoordinate, null);
  53.                     });
  54.                 }
  55.             });
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement