void SetNexusPosition(Actor self)
        {
            int x = 0, y = 0, cnt = 0;

            foreach (var se in slaveEntries)
            {
                if (!se.IsValid || !se.Actor.IsInWorld)
                {
                    continue;
                }

                var pos = se.Actor.CenterPosition;
                x += pos.X;
                y += pos.Y;
                cnt++;
            }

            if (cnt == 0)
            {
                return;
            }

            var newPos = new WPos(x / cnt, y / cnt, aircraft != null ? aircraft.Info.CruiseAltitude.Length : 0);

            if (aircraft == null)
            {
                position.SetPosition(self, newPos);                 // breaks arrival detection of the aircraft if we set position.
            }
            position.SetVisualPosition(self, newPos);
        }
Beispiel #2
0
        public override Activity Tick(Actor self)
        {
            if (disableable != null && disableable.IsTraitDisabled)
            {
                return(this);
            }

            var pos = length > 1
                                ? WPos.Lerp(start, end, ticks, length - 1)
                                : end;

            positionable.SetVisualPosition(self, pos);
            if (++ticks >= length)
            {
                if (movement != null)
                {
                    movement.IsMoving = false;
                }

                return(NextActivity);
            }

            if (movement != null)
            {
                movement.IsMoving = true;
            }

            return(this);
        }
Beispiel #3
0
        public override Activity Tick(Actor self)
        {
            var nextPosition = self.CenterPosition - fallVector;

            if (nextPosition.Z < groundLevel)
            {
                return(NextActivity);
            }

            pos.SetVisualPosition(self, nextPosition);

            return(this);
        }
Beispiel #4
0
        public override bool Tick(Actor self)
        {
            var nextPosition = self.CenterPosition - fallVector;

            if (nextPosition.Z < groundLevel)
            {
                return(true);
            }

            pos.SetVisualPosition(self, nextPosition);

            return(false);
        }
Beispiel #5
0
        public override bool Tick(Actor self)
        {
            currentPosition -= fallVector;
            pos.SetVisualPosition(self, currentPosition);

            // If the unit has landed, this will be the last tick
            if (self.World.Map.DistanceAboveTerrain(currentPosition).Length <= 0)
            {
                var dat = self.World.Map.DistanceAboveTerrain(currentPosition);
                pos.SetPosition(self, currentPosition - new WVec(WDist.Zero, WDist.Zero, dat));

                return(true);
            }

            return(false);
        }
Beispiel #6
0
        public override bool Tick(Actor self)
        {
            if (disableable != null && disableable.IsTraitDisabled)
            {
                return(false);
            }

            var pos = length > 1
                                ? WPos.Lerp(start, end, ticks, length - 1)
                                : end;

            positionable.SetVisualPosition(self, pos);
            if (++ticks >= length)
            {
                return(true);
            }

            return(false);
        }
Beispiel #7
0
        public override Activity Tick(Actor self)
        {
            // If this is the first tick
            if (!triggered)
            {
                return(FirstTick(self));
            }

            currentPosition -= fallVector;

            // If the unit has landed, this will be the last tick
            if (self.World.Map.DistanceAboveTerrain(currentPosition).Length <= 0)
            {
                return(LastTick(self));
            }

            pos.SetVisualPosition(self, currentPosition);

            return(this);
        }
Beispiel #8
0
        public override Activity Tick(Actor self)
        {
            // If this is the first tick
            if (!triggered)
            {
                return(FirstTick(self));
            }

            currentPosition -= fallVector;

            // If the unit has landed, this will be the last tick
            if (currentPosition.Z <= 0)
            {
                return(LastTick(self));
            }

            pos.SetVisualPosition(self, currentPosition);

            return(this);
        }
Beispiel #9
0
        /// <summary>
        /// Pull self to dest.
        /// </summary>
        /// <returns>true when done, false otherwise.</returns>
        bool FlyToward(Actor self, CPos dest)
        {
            var step = self.World.Map.CenterOfCell(dest) - self.CenterPosition;

            if (step.HorizontalLengthSquared == 0)
            {
                return(true);
            }

            step = new WVec(step.X, step.Y, 0);
            step = cruiseSpeedMultiplier * Info.CruiseSpeed.Length * step / step.Length;

            var altitude      = self.World.Map.DistanceAboveTerrain(self.CenterPosition);
            var altitudeDelta = new WVec(0, 0, CalcAltitudeDelta(self, altitude, Info.CruiseAltitude));

            // SetPosition(self, self.CenterPosition + step); No need for SetPosition!
            positionable.SetVisualPosition(self, self.CenterPosition + step + altitudeDelta);

            return(false);
        }