Пример #1
0
        protected override void Tick(Actor self)
        {
            if (IsTraitDisabled)
            {
                return;
            }

            if (lastBodyFacing != null)
            {
                if (lastBodyFacing != facing.Facing)
                {
                    if (initialChange)
                    {
                        // Game.Debug("body facing changed from {0} to {1}", LastBodyFacing, facing.Facing);
                        var facingDiff = lastBodyFacing - facing.Facing;
                        LocalOrientation = LocalOrientation.Rotate(new WRot(WAngle.Zero, WAngle.Zero, facingDiff));
                    }
                    else
                    {
                        initialChange = true;
                    }
                }
            }

            lastBodyFacing = facing.Facing;
            base.Tick(self);
        }
Пример #2
0
        public void StartTransformAction(LocalOrientation localOrientation, DragActionType dragActionType, int part = -1, IRevertable revertable = null)
        {
            AbstractTransformAction transformAction;

            Vector3 pivot;

            draggingDepth = control.PickingDepth;
            if (part != -1)
            {
                pivot = localOrientation.Origin;
            }
            else
            {
                BoundingBox box = BoundingBox.Default;

                foreach (IEditableObject obj in GetObjects())
                {
                    obj.GetSelectionBox(ref box);
                }

                pivot = box.GetCenter();

                if (box == BoundingBox.Default)
                {
                    return;
                }
            }

            switch (dragActionType)
            {
            case DragActionType.TRANSLATE:
                transformAction = new TranslateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.ROTATE:
                transformAction = new RotateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.SCALE:
                transformAction = new ScaleAction(control, control.GetMousePos(), pivot);
                break;

            case DragActionType.SCALE_INDIVIDUAL:
                transformAction = new ScaleActionIndividual(control, control.GetMousePos(), localOrientation);
                break;

            default:
                return;
            }

            StartTransformAction(transformAction, part, revertable);
        }
Пример #3
0
        void MoveTurret()
        {
            var desired = realignDesired ? Info.InitialFacing : DesiredLocalFacing;

            if (desired == LocalOrientation.Yaw)
            {
                return;
            }

            LocalOrientation = LocalOrientation.WithYaw(Util.TickFacing(LocalOrientation.Yaw, desired, Info.TurnSpeed));

            if (desired == LocalOrientation.Yaw)
            {
                realignDesired   = false;
                desiredDirection = WVec.Zero;
            }
        }
Пример #4
0
 public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively)
 {
     localOrientation = new LocalOrientation(position);
     dragExclusively  = false;
     return(Selected);
 }
Пример #5
0
        void MoveTurret()
        {
            var desired = DesiredLocalFacing ?? Info.InitialFacing;

            LocalOrientation = LocalOrientation.WithYaw(Util.TickFacing(LocalOrientation.Yaw, desired, Info.TurnSpeed));
        }