public override void Update(DwarfGame game, DwarfTime time) { if (Player.IsCameraRotationModeActive()) { Player.VoxSelector.Enabled = false; Player.World.SetMouse(null); return; } Player.VoxSelector.Enabled = true; Player.BodySelector.Enabled = false; Player.World.SetMouse(Player.World.MousePointer); if (Command.Contains("Decal/")) { KeyboardState state = Keyboard.GetState(); bool leftKey = state.IsKeyDown(ControlSettings.Mappings.RotateObjectLeft); bool rightKey = state.IsKeyDown(ControlSettings.Mappings.RotateObjectRight); if (RotateLeftPressed && !leftKey) { DecalOrientation = DecalType.RotateOrientation(DecalOrientation, -1); } else if (RotateRightPressed && !rightKey) { DecalOrientation = DecalType.RotateOrientation(DecalOrientation, 1); } RotateLeftPressed = leftKey; RotateRightPressed = rightKey; } }
public override void Update(DwarfGame game, DwarfTime time) { if (Player.IsCameraRotationModeActive()) { Player.VoxSelector.Enabled = false; Player.World.SetMouse(null); return; } Player.VoxSelector.Enabled = true; Player.BodySelector.Enabled = false; Player.World.SetMouse(Player.World.MousePointer); if (Command.Contains("Decal/")) { KeyboardState state = Keyboard.GetState(); bool leftKey = state.IsKeyDown(ControlSettings.Mappings.RotateObjectLeft); bool rightKey = state.IsKeyDown(ControlSettings.Mappings.RotateObjectRight); if (RotateLeftPressed && !leftKey) { DecalOrientation = DecalType.RotateOrientation(DecalOrientation, -1); } else if (RotateRightPressed && !rightKey) { DecalOrientation = DecalType.RotateOrientation(DecalOrientation, 1); } RotateLeftPressed = leftKey; RotateRightPressed = rightKey; } else if (Command == "Repulse") { var location = Player.VoxSelector.VoxelUnderMouse; var center = location.GetBoundingBox().Center(); foreach (var body in Player.World.EnumerateIntersectingObjects(location.GetBoundingBox(), CollisionType.Dynamic)) { var delta = center - body.Position; delta.Normalize(); if (delta.Y < 0) { delta.Y = 0; } var transform = body.LocalTransform; transform.Translation += delta * (float)time.ElapsedGameTime.TotalSeconds * 5; body.LocalTransform = transform; } } }
public static byte EncodeDecal(DecalOrientation Orientation, byte Type) { return((byte)((((byte)Orientation) << 6) + (Type & 0x3F))); }
public static DecalOrientation RotateOrientation(DecalOrientation Orientation, int Amount) { return((DecalOrientation)(((int)Orientation + Amount) % 4)); }