Example #1
0
 public ExternalCaptureActor(Actor self, Target target)
 {
     this.target = target;
     capturable = target.Actor.Trait<ExternalCapturable>();
     capturesInfo = self.Info.TraitInfo<ExternalCapturesInfo>();
     mobile = self.Trait<Mobile>();
 }
Example #2
0
 public PathSearch(Actor self)
 {
     this.self = self;
     world = self.World;
     cellInfo = InitCellInfo();
     mobile = self.Trait<Mobile>();
     queue = new PriorityQueue<PathDistance>();
 }
Example #3
0
 public FindResources(Actor self)
 {
     harv = self.Trait<Harvester>();
     harvInfo = self.Info.Traits.Get<HarvesterInfo>();
     mobile = self.Trait<Mobile>();
     mobileInfo = self.Info.Traits.Get<MobileInfo>();
     resLayer = self.World.WorldActor.Trait<ResourceLayer>();
     territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
     pathFinder = self.World.WorldActor.Trait<IPathFinder>();
 }
Example #4
0
        public MoveAdjacentTo(Actor self, Target target)
        {
            Target = target;

            mobile = self.Trait<Mobile>();
            pathFinder = self.World.WorldActor.Trait<IPathFinder>();
            domainIndex = self.World.WorldActor.Trait<DomainIndex>();
            movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet);

            if (target.IsValidFor(self))
                targetPosition = self.World.Map.CellContaining(target.CenterPosition);

            repath = true;
        }
Example #5
0
        public Leap(Actor self, Actor target, WeaponInfo weapon, WDist speed, WAngle angle)
        {
            var targetMobile = target.TraitOrDefault<Mobile>();
            if (targetMobile == null)
                throw new InvalidOperationException("Leap requires a target actor with the Mobile trait");

            this.weapon = weapon;
            this.angle = angle;
            mobile = self.Trait<Mobile>();
            mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, targetMobile.FromCell, targetMobile.FromSubCell);
            mobile.IsMoving = true;

            from = self.CenterPosition;
            to = self.World.Map.CenterOfSubCell(targetMobile.FromCell, targetMobile.FromSubCell);
            length = Math.Max((to - from).Length / speed.Length, 1);

            // HACK: why isn't this using the interface?
            self.Trait<WithInfantryBody>().Attacking(self, Target.FromActor(target));

            if (weapon.Report != null && weapon.Report.Any())
                Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
        }
Example #6
0
 public AttackMove(Actor self, AttackMoveInfo info)
 {
     Info = info;
     mobile = self.Trait<Mobile>();
 }