Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. MINE:
  2.     RGMine:
  3.         Weapon: AMine
  4.         CrushClasses: apmine
  5.     Health:
  6.         HP: 1
  7.     RenderUnit:
  8.     BelowUnits:
  9. #   InvisibleToOthers:
  10.     RGIndestructible:
  11.     Tooltip:
  12.         Name: Anti-Personnel Mine
  13.     Scale:
  14.         Value: 0.5
  15.  
  16.  
  17.  
  18. using System.Collections.Generic;
  19. using OpenRA;
  20. using OpenRA.Mods.RA;
  21. using OpenRA.Mods.RA.Activities;
  22. using OpenRA.Traits;
  23. using OpenRg.Activities;
  24.  
  25. namespace OpenRg.Traits
  26. {
  27.     class RGMineInfo : ITraitInfo
  28.     {
  29.         public readonly string[] CrushClasses = { };
  30.         [WeaponReference]
  31.         public readonly string Weapon = "ATMine";
  32.         //public readonly bool AvoidFriendly = true;
  33.  
  34.         public object Create(ActorInitializer init) { return new RGMine(init, this); }
  35.     }
  36.  
  37.     class RGMine : ICrushable, IOccupySpace
  38.     {
  39.         public readonly Actor Self;
  40.         public readonly RGMineInfo Info;
  41.         [Sync]
  42.         public readonly int2 Location;
  43.  
  44.         public RGMine(ActorInitializer init, RGMineInfo info)
  45.         {
  46.             Self = init.self;
  47.             Info = info;
  48.             Location = init.Get<LocationInit, int2>();
  49.             Self.World.WorldActor.Trait<UnitInfluence>().Add(Self, this);
  50.         }
  51.  
  52.         public void OnCrush(Actor crusher)
  53.         {
  54.             if (crusher.HasTrait<RGMineImmune>() && crusher.Owner == Self.Owner)
  55.                 return;
  56.             if (crusher.Owner.Stances[Self.Owner] != Stance.Enemy)
  57.                 return;
  58.  
  59.             Combat.DoExplosion(Self, Info.Weapon, crusher.CenterLocation, 0);
  60.             Self.QueueActivity(new RGRemoveSelf());
  61.         }
  62.  
  63.         // TODO: Re-implement friendly-mine avoidance
  64.         public IEnumerable<string> CrushClasses { get { return Info.CrushClasses; } }
  65.  
  66.         public int2 TopLeft { get { return Location; } }
  67.  
  68.         public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
  69.         public int2 PxPosition { get { return Util.CenterOfCell(Location); } }
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement