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); }
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); }
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; } }
public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively) { localOrientation = new LocalOrientation(position); dragExclusively = false; return(Selected); }
void MoveTurret() { var desired = DesiredLocalFacing ?? Info.InitialFacing; LocalOrientation = LocalOrientation.WithYaw(Util.TickFacing(LocalOrientation.Yaw, desired, Info.TurnSpeed)); }