Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
 public static byte EncodeDecal(DecalOrientation Orientation, byte Type)
 {
     return((byte)((((byte)Orientation) << 6) + (Type & 0x3F)));
 }
Ejemplo n.º 4
0
 public static DecalOrientation RotateOrientation(DecalOrientation Orientation, int Amount)
 {
     return((DecalOrientation)(((int)Orientation + Amount) % 4));
 }