Ejemplo n.º 1
0
            protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent)
            {
                var map = self.World.Map;
                var fromSubcellOffset = map.Grid.OffsetOfSubCell(mobile.FromSubCell);
                var toSubcellOffset   = map.Grid.OffsetOfSubCell(mobile.ToSubCell);

                if (!IsCanceling || self.Location.Layer == CustomMovementLayerType.Tunnel)
                {
                    var nextCell = parent.PopPath(self);
                    if (nextCell != null)
                    {
                        if (IsTurn(mobile, nextCell.Value.First))
                        {
                            var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.Second);
                            var ret = new MoveFirstHalf(
                                Move,
                                Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                                Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
                                mobile.Facing,
                                Util.GetNearestFacing(mobile.Facing, map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing)),
                                moveFraction - MoveFractionTotal);

                            mobile.FinishedMoving(self);
                            mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second);
                            return(ret);
                        }

                        parent.path.Add(nextCell.Value.First);
                    }
                }

                var toPos = mobile.ToCell.Layer == 0 ? map.CenterOfCell(mobile.ToCell) :
                            self.World.GetCustomMovementLayers()[mobile.ToCell.Layer].CenterOfCell(mobile.ToCell);

                var ret2 = new MoveSecondHalf(
                    Move,
                    Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                    toPos + toSubcellOffset,
                    mobile.Facing,
                    mobile.Facing,
                    moveFraction - MoveFractionTotal);

                mobile.EnteringCell(self);
                mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, mobile.ToCell, mobile.ToSubCell);
                return(ret2);
            }
Ejemplo n.º 2
0
            protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent)
            {
                var fromSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.FromSubCell);
                var toSubcellOffset   = self.World.Map.OffsetOfSubCell(mobile.ToSubCell);

                var nextCell = parent.PopPath(self);

                if (nextCell != null)
                {
                    if (IsTurn(mobile, nextCell.Value.First))
                    {
                        var nextSubcellOffset = self.World.Map.OffsetOfSubCell(nextCell.Value.Second);
                        var ret = new MoveFirstHalf(
                            Move,
                            Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                            Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
                            mobile.Facing,
                            Util.GetNearestFacing(mobile.Facing, self.World.Map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing)),
                            moveFraction - MoveFractionTotal);

                        mobile.FinishedMoving(self);
                        mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second);
                        return(ret);
                    }

                    parent.path.Add(nextCell.Value.First);
                }

                var ret2 = new MoveSecondHalf(
                    Move,
                    Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                    self.World.Map.CenterOfCell(mobile.ToCell) + toSubcellOffset,
                    mobile.Facing,
                    mobile.Facing,
                    moveFraction - MoveFractionTotal);

                mobile.EnteringCell(self);
                mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, mobile.ToCell, mobile.ToSubCell);
                return(ret2);
            }