Removed BarotraumaServer's MonoGame dependency
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Source\Camera.cs" />
|
||||
<Compile Include="Source\Characters\AICharacter.cs" />
|
||||
<Compile Include="Source\Characters\AI\AIController.cs" />
|
||||
<Compile Include="Source\Characters\AI\AITarget.cs" />
|
||||
<Compile Include="Source\Characters\AI\CrewCommander.cs" />
|
||||
<Compile Include="Source\Characters\AI\EnemyAIController.cs" />
|
||||
@@ -89,6 +90,7 @@
|
||||
<Compile Include="Source\Fonts\ScalableFont.cs" />
|
||||
<Compile Include="Source\GameMain.cs" />
|
||||
<Compile Include="Source\GameSession\CrewManager.cs" />
|
||||
<Compile Include="Source\GameSession\GameMode.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\SinglePlayerMode.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\TraitorManager.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\BasicTutorial.cs" />
|
||||
@@ -148,6 +150,7 @@
|
||||
<Compile Include="Source\Map\FireSource.cs" />
|
||||
<Compile Include="Source\Map\Gap.cs" />
|
||||
<Compile Include="Source\Map\Hull.cs" />
|
||||
<Compile Include="Source\Map\Levels\CaveGenerator.cs" />
|
||||
<Compile Include="Source\Map\Levels\Level.cs" />
|
||||
<Compile Include="Source\Map\Levels\LevelRenderer.cs" />
|
||||
<Compile Include="Source\Map\Levels\Ruins\RuinGenerator.cs" />
|
||||
|
||||
11
BarotraumaClient/Source/Characters/AI/AIController.cs
Normal file
11
BarotraumaClient/Source/Characters/AI/AIController.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class AIController : ISteerable
|
||||
{
|
||||
public virtual void DebugDraw(SpriteBatch spriteBatch) { }
|
||||
}
|
||||
}
|
||||
10
BarotraumaClient/Source/GameSession/GameMode.cs
Normal file
10
BarotraumaClient/Source/GameSession/GameMode.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class GameMode
|
||||
{
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ namespace Barotrauma
|
||||
{
|
||||
partial class CharacterInventory : Inventory
|
||||
{
|
||||
private static Texture2D icons;
|
||||
|
||||
public Vector2[] SlotPositions;
|
||||
|
||||
private GUIButton[] useOnSelfButton;
|
||||
|
||||
166
BarotraumaClient/Source/Map/Levels/CaveGenerator.cs
Normal file
166
BarotraumaClient/Source/Map/Levels/CaveGenerator.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Voronoi2;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Common;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.Factories;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
static partial class CaveGenerator
|
||||
{
|
||||
public static List<VertexPositionTexture> GenerateRenderVerticeList(List<Vector2[]> triangles)
|
||||
{
|
||||
var verticeList = new List<VertexPositionTexture>();
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
foreach (Vector2 vertex in triangles[i])
|
||||
{
|
||||
//shift the coordinates around a bit to make the texture repetition less obvious
|
||||
Vector2 uvCoords = new Vector2(
|
||||
vertex.X / 2000.0f + (float)Math.Sin(vertex.X / 500.0f) * 0.15f,
|
||||
vertex.Y / 2000.0f + (float)Math.Sin(vertex.Y / 700.0f) * 0.15f);
|
||||
|
||||
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 1.0f), uvCoords));
|
||||
}
|
||||
}
|
||||
|
||||
return verticeList;
|
||||
}
|
||||
|
||||
public static VertexPositionTexture[] GenerateWallShapes(List<VoronoiCell> cells)
|
||||
{
|
||||
float inwardThickness = 500.0f, outWardThickness = 30.0f;
|
||||
|
||||
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
|
||||
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
//if (cell.body == null) continue;
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
if (edge.cell1 != null && edge.cell1.body == null && edge.cell1.CellType != CellType.Empty) edge.cell1 = null;
|
||||
if (edge.cell2 != null && edge.cell2.body == null && edge.cell2.CellType != CellType.Empty) edge.cell2 = null;
|
||||
|
||||
CompareCCW compare = new CompareCCW(cell.Center);
|
||||
if (compare.Compare(edge.point1, edge.point2) == -1)
|
||||
{
|
||||
var temp = edge.point1;
|
||||
edge.point1 = edge.point2;
|
||||
edge.point2 = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
//if (cell.body == null) continue;
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
if (!edge.isSolid) continue;
|
||||
|
||||
GraphEdge leftEdge = cell.edges.Find(e => e != edge && (edge.point1 == e.point1 || edge.point1 == e.point2));
|
||||
GraphEdge rightEdge = cell.edges.Find(e => e != edge && (edge.point2 == e.point1 || edge.point2 == e.point2));
|
||||
|
||||
Vector2 leftNormal = Vector2.Zero, rightNormal = Vector2.Zero;
|
||||
|
||||
if (leftEdge == null)
|
||||
{
|
||||
leftNormal = GetEdgeNormal(edge, cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftNormal = (leftEdge.isSolid) ?
|
||||
Vector2.Normalize(GetEdgeNormal(leftEdge) + GetEdgeNormal(edge, cell)) :
|
||||
Vector2.Normalize(leftEdge.Center - edge.point1);
|
||||
}
|
||||
|
||||
|
||||
if (!MathUtils.IsValid(leftNormal))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid left normal");
|
||||
#endif
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
leftNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (rightEdge == null)
|
||||
{
|
||||
rightNormal = GetEdgeNormal(edge, cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
rightNormal = (rightEdge.isSolid) ?
|
||||
Vector2.Normalize(GetEdgeNormal(rightEdge) + GetEdgeNormal(edge, cell)) :
|
||||
Vector2.Normalize(rightEdge.Center - edge.point2);
|
||||
}
|
||||
|
||||
if (!MathUtils.IsValid(rightNormal))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid right normal");
|
||||
#endif
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
rightNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vector2[] verts = new Vector2[3];
|
||||
VertexPositionTexture[] vertPos = new VertexPositionTexture[3];
|
||||
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
verts[0] = edge.point1 - leftNormal * outWardThickness;
|
||||
verts[1] = edge.point2 - rightNormal * outWardThickness;
|
||||
verts[2] = edge.point1 + leftNormal * inwardThickness;
|
||||
|
||||
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), Vector2.Zero);
|
||||
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
|
||||
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(0, 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
verts[0] = edge.point1 + leftNormal * inwardThickness;
|
||||
verts[1] = edge.point2 - rightNormal * outWardThickness;
|
||||
verts[2] = edge.point2 + rightNormal * inwardThickness;
|
||||
|
||||
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), new Vector2(0.0f, 0.5f));
|
||||
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
|
||||
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(1.0f, 0.5f));
|
||||
}
|
||||
|
||||
var comparer = new CompareCCW((verts[0] + verts[1] + verts[2]) / 3.0f);
|
||||
Array.Sort(verts, vertPos, comparer);
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
verticeList.Add(vertPos[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return verticeList.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,12 @@ namespace Barotrauma
|
||||
{
|
||||
partial class PhysicsBody
|
||||
{
|
||||
private Texture2D bodyShapeTexture;
|
||||
public Texture2D BodyShapeTexture
|
||||
{
|
||||
get { return bodyShapeTexture; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null, float scale = 1.0f)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
@@ -88,5 +94,14 @@ namespace Barotrauma
|
||||
new Vector2(bodyShapeTexture.Width / 2, bodyShapeTexture.Height / 2),
|
||||
1.0f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
private void DisposeProjSpecific()
|
||||
{
|
||||
if (bodyShapeTexture != null)
|
||||
{
|
||||
bodyShapeTexture.Dispose();
|
||||
bodyShapeTexture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,16 +52,9 @@
|
||||
<ApplicationIcon>..\BarotraumaShared\Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework, Version=3.5.1.1679, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.XML" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -89,20 +82,30 @@
|
||||
<Compile Include="Source\Networking\GameServer.cs" />
|
||||
<Compile Include="Source\Networking\NetworkMember.cs" />
|
||||
<Compile Include="Source\Networking\Voting.cs" />
|
||||
<Compile Include="Source\Physics\PhysicsBody.cs" />
|
||||
<Compile Include="Source\PlayerInput.cs" />
|
||||
<Compile Include="Source\Program.cs" />
|
||||
<Compile Include="Source\Screens\NetLobbyScreen.cs" />
|
||||
<Compile Include="Source\Screens\UnimplementedScreen.cs" />
|
||||
<Compile Include="Source\Sprite\Sprite.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Color.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Graphics\SpriteEffects.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Input\KeyboardState.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Input\Keys.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Input\KeyState.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Point.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Quaternion.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Rectangle.cs" />
|
||||
<Compile Include="Source\Utils\MonogameTypes\Vector4.cs" />
|
||||
<Compile Include="Source\Utils\XnaToConsoleColor.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Farseer Physics Engine 3.5\Farseer Physics MonoGame.csproj">
|
||||
<Project>{0aad36e3-51a5-4a07-ab60-5c8a66bd38b7}</Project>
|
||||
<Name>Farseer Physics MonoGame</Name>
|
||||
<ProjectReference Include="..\Farseer Physics Engine 3.5\Farseer Physics.csproj">
|
||||
<Project>{a4610e4c-dd34-428b-babb-779ca0b5993a}</Project>
|
||||
<Name>Farseer Physics</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Hyper.ComponentModel\Hyper.ComponentModel.csproj">
|
||||
<Project>{3b8f9edb-6e5e-450c-abc2-ec49075d0b50}</Project>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Linq;
|
||||
//TODO: this class still does things that the server doesn't need, cleanup
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Items.Components;
|
||||
using System.Text;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Barotrauma.Networking;
|
||||
using Lidgren.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
using Lidgren.Network;
|
||||
using Barotrauma.Items.Components;
|
||||
|
||||
15
BarotraumaServer/Source/Physics/PhysicsBody.cs
Normal file
15
BarotraumaServer/Source/Physics/PhysicsBody.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class PhysicsBody
|
||||
{
|
||||
private void DisposeProjSpecific()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
1856
BarotraumaServer/Source/Utils/MonogameTypes/Color.cs
Normal file
1856
BarotraumaServer/Source/Utils/MonogameTypes/Color.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines sprite visual options for mirroring.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SpriteEffects
|
||||
{
|
||||
/// <summary>
|
||||
/// No options specified.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Render the sprite reversed along the X axis.
|
||||
/// </summary>
|
||||
FlipHorizontally = 1,
|
||||
/// <summary>
|
||||
/// Render the sprite reversed along the Y axis.
|
||||
/// </summary>
|
||||
FlipVertically = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce, " "reproduction, " "derivative works, " and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the state of a keyboard key.
|
||||
/// </summary>
|
||||
public enum KeyState
|
||||
{
|
||||
/// <summary>
|
||||
/// Key is released.
|
||||
/// </summary>
|
||||
Up,
|
||||
|
||||
/// <summary>
|
||||
/// Key is pressed.
|
||||
/// </summary>
|
||||
Down,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the state of keystrokes by a keyboard.
|
||||
/// </summary>
|
||||
public struct KeyboardState
|
||||
{
|
||||
// Used for the common situation where GetPressedKeys will return an empty array
|
||||
static Keys[] empty = new Keys[0];
|
||||
|
||||
#region Key Data
|
||||
|
||||
// Array of 256 bits:
|
||||
uint keys0, keys1, keys2, keys3, keys4, keys5, keys6, keys7;
|
||||
|
||||
bool InternalGetKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
|
||||
uint element;
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: element = keys0; break;
|
||||
case 1: element = keys1; break;
|
||||
case 2: element = keys2; break;
|
||||
case 3: element = keys3; break;
|
||||
case 4: element = keys4; break;
|
||||
case 5: element = keys5; break;
|
||||
case 6: element = keys6; break;
|
||||
case 7: element = keys7; break;
|
||||
default: element = 0; break;
|
||||
}
|
||||
|
||||
return (element & mask) != 0;
|
||||
}
|
||||
|
||||
void InternalSetKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: keys0 |= mask; break;
|
||||
case 1: keys1 |= mask; break;
|
||||
case 2: keys2 |= mask; break;
|
||||
case 3: keys3 |= mask; break;
|
||||
case 4: keys4 |= mask; break;
|
||||
case 5: keys5 |= mask; break;
|
||||
case 6: keys6 |= mask; break;
|
||||
case 7: keys7 |= mask; break;
|
||||
}
|
||||
}
|
||||
|
||||
void InternalClearKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: keys0 &= ~mask; break;
|
||||
case 1: keys1 &= ~mask; break;
|
||||
case 2: keys2 &= ~mask; break;
|
||||
case 3: keys3 &= ~mask; break;
|
||||
case 4: keys4 &= ~mask; break;
|
||||
case 5: keys5 &= ~mask; break;
|
||||
case 6: keys6 &= ~mask; break;
|
||||
case 7: keys7 &= ~mask; break;
|
||||
}
|
||||
}
|
||||
|
||||
void InternalClearAllKeys()
|
||||
{
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region XNA Interface
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the Caps Lock key.
|
||||
/// </summary>
|
||||
public bool CapsLock { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the Num Lock key.
|
||||
/// </summary>
|
||||
public bool NumLock { get; private set; }
|
||||
|
||||
internal KeyboardState(List<Keys> keys, bool capsLock = false, bool numLock = false) : this()
|
||||
{
|
||||
CapsLock = capsLock;
|
||||
NumLock = numLock;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="KeyboardState"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keys">List of keys to be flagged as pressed on initialization.</param>
|
||||
/// <param name="capsLock">Caps Lock state.</param>
|
||||
/// <param name="numLock">Num Lock state.</param>
|
||||
public KeyboardState(Keys[] keys, bool capsLock = false, bool numLock = false) : this()
|
||||
{
|
||||
CapsLock = capsLock;
|
||||
NumLock = numLock;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="KeyboardState"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keys">List of keys to be flagged as pressed on initialization.</param>
|
||||
public KeyboardState(params Keys[] keys) : this()
|
||||
{
|
||||
CapsLock = false;
|
||||
NumLock = false;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state of a specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>The state of the key.</returns>
|
||||
public KeyState this[Keys key]
|
||||
{
|
||||
get { return InternalGetKey(key) ? KeyState.Down : KeyState.Up; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether given key is currently being pressed.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>true if the key is pressed; false otherwise.</returns>
|
||||
public bool IsKeyDown(Keys key)
|
||||
{
|
||||
return InternalGetKey(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether given key is currently being not pressed.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>true if the key is not pressed; false otherwise.</returns>
|
||||
public bool IsKeyUp(Keys key)
|
||||
{
|
||||
return !InternalGetKey(key);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region GetPressedKeys()
|
||||
|
||||
private static uint CountBits(uint v)
|
||||
{
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
|
||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
|
||||
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
|
||||
}
|
||||
|
||||
private static int AddKeysToArray(uint keys, int offset, Keys[] pressedKeys, int index)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if ((keys & (1 << i)) != 0)
|
||||
pressedKeys[index++] = (Keys)(offset + i);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of values holding keys that are currently being pressed.
|
||||
/// </summary>
|
||||
/// <returns>The keys that are currently being pressed.</returns>
|
||||
public Keys[] GetPressedKeys()
|
||||
{
|
||||
uint count = CountBits(keys0) + CountBits(keys1) + CountBits(keys2) + CountBits(keys3)
|
||||
+ CountBits(keys4) + CountBits(keys5) + CountBits(keys6) + CountBits(keys7);
|
||||
if (count == 0)
|
||||
return empty;
|
||||
Keys[] keys = new Keys[count];
|
||||
|
||||
int index = 0;
|
||||
if (keys0 != 0) index = AddKeysToArray(keys0, 0 * 32, keys, index);
|
||||
if (keys1 != 0) index = AddKeysToArray(keys1, 1 * 32, keys, index);
|
||||
if (keys2 != 0) index = AddKeysToArray(keys2, 2 * 32, keys, index);
|
||||
if (keys3 != 0) index = AddKeysToArray(keys3, 3 * 32, keys, index);
|
||||
if (keys4 != 0) index = AddKeysToArray(keys4, 4 * 32, keys, index);
|
||||
if (keys5 != 0) index = AddKeysToArray(keys5, 5 * 32, keys, index);
|
||||
if (keys6 != 0) index = AddKeysToArray(keys6, 6 * 32, keys, index);
|
||||
if (keys7 != 0) index = AddKeysToArray(keys7, 7 * 32, keys, index);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Objet and Equality
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code for <see cref="KeyboardState"/> instance.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of the object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)(keys0 ^ keys1 ^ keys2 ^ keys3 ^ keys4 ^ keys5 ^ keys6 ^ keys7);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="KeyboardState"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="KeyboardState"/> instance to the left of the equality operator.</param>
|
||||
/// <param name="b"><see cref="KeyboardState"/> instance to the right of the equality operator.</param>
|
||||
/// <returns>true if the instances are equal; false otherwise.</returns>
|
||||
public static bool operator ==(KeyboardState a, KeyboardState b)
|
||||
{
|
||||
return a.keys0 == b.keys0
|
||||
&& a.keys1 == b.keys1
|
||||
&& a.keys2 == b.keys2
|
||||
&& a.keys3 == b.keys3
|
||||
&& a.keys4 == b.keys4
|
||||
&& a.keys5 == b.keys5
|
||||
&& a.keys6 == b.keys6
|
||||
&& a.keys7 == b.keys7;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="KeyboardState"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="KeyboardState"/> instance to the left of the inequality operator.</param>
|
||||
/// <param name="b"><see cref="KeyboardState"/> instance to the right of the inequality operator.</param>
|
||||
/// <returns>true if the instances are different; false otherwise.</returns>
|
||||
public static bool operator !=(KeyboardState a, KeyboardState b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="KeyboardState"/> to compare.</param>
|
||||
/// <returns>true if the provided <see cref="KeyboardState"/> instance is same with current; false otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is KeyboardState && this == (KeyboardState)obj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
653
BarotraumaServer/Source/Utils/MonogameTypes/Input/Keys.cs
Normal file
653
BarotraumaServer/Source/Utils/MonogameTypes/Input/Keys.cs
Normal file
@@ -0,0 +1,653 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the keys on a keyboard.
|
||||
/// </summary>
|
||||
public enum Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// BACKSPACE key.
|
||||
/// </summary>
|
||||
Back = 8,
|
||||
/// <summary>
|
||||
/// TAB key.
|
||||
/// </summary>
|
||||
Tab = 9,
|
||||
/// <summary>
|
||||
/// ENTER key.
|
||||
/// </summary>
|
||||
Enter = 13,
|
||||
/// <summary>
|
||||
/// CAPS LOCK key.
|
||||
/// </summary>
|
||||
CapsLock = 20,
|
||||
/// <summary>
|
||||
/// ESC key.
|
||||
/// </summary>
|
||||
Escape = 27,
|
||||
/// <summary>
|
||||
/// SPACEBAR key.
|
||||
/// </summary>
|
||||
Space = 32,
|
||||
/// <summary>
|
||||
/// PAGE UP key.
|
||||
/// </summary>
|
||||
PageUp = 33,
|
||||
/// <summary>
|
||||
/// PAGE DOWN key.
|
||||
/// </summary>
|
||||
PageDown = 34,
|
||||
/// <summary>
|
||||
/// END key.
|
||||
/// </summary>
|
||||
End = 35,
|
||||
/// <summary>
|
||||
/// HOME key.
|
||||
/// </summary>
|
||||
Home = 36,
|
||||
/// <summary>
|
||||
/// LEFT ARROW key.
|
||||
/// </summary>
|
||||
Left = 37,
|
||||
/// <summary>
|
||||
/// UP ARROW key.
|
||||
/// </summary>
|
||||
Up = 38,
|
||||
/// <summary>
|
||||
/// RIGHT ARROW key.
|
||||
/// </summary>
|
||||
Right = 39,
|
||||
/// <summary>
|
||||
/// DOWN ARROW key.
|
||||
/// </summary>
|
||||
Down = 40,
|
||||
/// <summary>
|
||||
/// SELECT key.
|
||||
/// </summary>
|
||||
Select = 41,
|
||||
/// <summary>
|
||||
/// PRINT key.
|
||||
/// </summary>
|
||||
Print = 42,
|
||||
/// <summary>
|
||||
/// EXECUTE key.
|
||||
/// </summary>
|
||||
Execute = 43,
|
||||
/// <summary>
|
||||
/// PRINT SCREEN key.
|
||||
/// </summary>
|
||||
PrintScreen = 44,
|
||||
/// <summary>
|
||||
/// INS key.
|
||||
/// </summary>
|
||||
Insert = 45,
|
||||
/// <summary>
|
||||
/// DEL key.
|
||||
/// </summary>
|
||||
Delete = 46,
|
||||
/// <summary>
|
||||
/// HELP key.
|
||||
/// </summary>
|
||||
Help = 47,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D0 = 48,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D1 = 49,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D2 = 50,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D3 = 51,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D4 = 52,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D5 = 53,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D6 = 54,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D7 = 55,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D8 = 56,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D9 = 57,
|
||||
/// <summary>
|
||||
/// A key.
|
||||
/// </summary>
|
||||
A = 65,
|
||||
/// <summary>
|
||||
/// B key.
|
||||
/// </summary>
|
||||
B = 66,
|
||||
/// <summary>
|
||||
/// C key.
|
||||
/// </summary>
|
||||
C = 67,
|
||||
/// <summary>
|
||||
/// D key.
|
||||
/// </summary>
|
||||
D = 68,
|
||||
/// <summary>
|
||||
/// E key.
|
||||
/// </summary>
|
||||
E = 69,
|
||||
/// <summary>
|
||||
/// F key.
|
||||
/// </summary>
|
||||
F = 70,
|
||||
/// <summary>
|
||||
/// G key.
|
||||
/// </summary>
|
||||
G = 71,
|
||||
/// <summary>
|
||||
/// H key.
|
||||
/// </summary>
|
||||
H = 72,
|
||||
/// <summary>
|
||||
/// I key.
|
||||
/// </summary>
|
||||
I = 73,
|
||||
/// <summary>
|
||||
/// J key.
|
||||
/// </summary>
|
||||
J = 74,
|
||||
/// <summary>
|
||||
/// K key.
|
||||
/// </summary>
|
||||
K = 75,
|
||||
/// <summary>
|
||||
/// L key.
|
||||
/// </summary>
|
||||
L = 76,
|
||||
/// <summary>
|
||||
/// M key.
|
||||
/// </summary>
|
||||
M = 77,
|
||||
/// <summary>
|
||||
/// N key.
|
||||
/// </summary>
|
||||
N = 78,
|
||||
/// <summary>
|
||||
/// O key.
|
||||
/// </summary>
|
||||
O = 79,
|
||||
/// <summary>
|
||||
/// P key.
|
||||
/// </summary>
|
||||
P = 80,
|
||||
/// <summary>
|
||||
/// Q key.
|
||||
/// </summary>
|
||||
Q = 81,
|
||||
/// <summary>
|
||||
/// R key.
|
||||
/// </summary>
|
||||
R = 82,
|
||||
/// <summary>
|
||||
/// S key.
|
||||
/// </summary>
|
||||
S = 83,
|
||||
/// <summary>
|
||||
/// T key.
|
||||
/// </summary>
|
||||
T = 84,
|
||||
/// <summary>
|
||||
/// U key.
|
||||
/// </summary>
|
||||
U = 85,
|
||||
/// <summary>
|
||||
/// V key.
|
||||
/// </summary>
|
||||
V = 86,
|
||||
/// <summary>
|
||||
/// W key.
|
||||
/// </summary>
|
||||
W = 87,
|
||||
/// <summary>
|
||||
/// X key.
|
||||
/// </summary>
|
||||
X = 88,
|
||||
/// <summary>
|
||||
/// Y key.
|
||||
/// </summary>
|
||||
Y = 89,
|
||||
/// <summary>
|
||||
/// Z key.
|
||||
/// </summary>
|
||||
Z = 90,
|
||||
/// <summary>
|
||||
/// Left Windows key.
|
||||
/// </summary>
|
||||
LeftWindows = 91,
|
||||
/// <summary>
|
||||
/// Right Windows key.
|
||||
/// </summary>
|
||||
RightWindows = 92,
|
||||
/// <summary>
|
||||
/// Applications key.
|
||||
/// </summary>
|
||||
Apps = 93,
|
||||
/// <summary>
|
||||
/// Computer Sleep key.
|
||||
/// </summary>
|
||||
Sleep = 95,
|
||||
/// <summary>
|
||||
/// Numeric keypad 0 key.
|
||||
/// </summary>
|
||||
NumPad0 = 96,
|
||||
/// <summary>
|
||||
/// Numeric keypad 1 key.
|
||||
/// </summary>
|
||||
NumPad1 = 97,
|
||||
/// <summary>
|
||||
/// Numeric keypad 2 key.
|
||||
/// </summary>
|
||||
NumPad2 = 98,
|
||||
/// <summary>
|
||||
/// Numeric keypad 3 key.
|
||||
/// </summary>
|
||||
NumPad3 = 99,
|
||||
/// <summary>
|
||||
/// Numeric keypad 4 key.
|
||||
/// </summary>
|
||||
NumPad4 = 100,
|
||||
/// <summary>
|
||||
/// Numeric keypad 5 key.
|
||||
/// </summary>
|
||||
NumPad5 = 101,
|
||||
/// <summary>
|
||||
/// Numeric keypad 6 key.
|
||||
/// </summary>
|
||||
NumPad6 = 102,
|
||||
/// <summary>
|
||||
/// Numeric keypad 7 key.
|
||||
/// </summary>
|
||||
NumPad7 = 103,
|
||||
/// <summary>
|
||||
/// Numeric keypad 8 key.
|
||||
/// </summary>
|
||||
NumPad8 = 104,
|
||||
/// <summary>
|
||||
/// Numeric keypad 9 key.
|
||||
/// </summary>
|
||||
NumPad9 = 105,
|
||||
/// <summary>
|
||||
/// Multiply key.
|
||||
/// </summary>
|
||||
Multiply = 106,
|
||||
/// <summary>
|
||||
/// Add key.
|
||||
/// </summary>
|
||||
Add = 107,
|
||||
/// <summary>
|
||||
/// Separator key.
|
||||
/// </summary>
|
||||
Separator = 108,
|
||||
/// <summary>
|
||||
/// Subtract key.
|
||||
/// </summary>
|
||||
Subtract = 109,
|
||||
/// <summary>
|
||||
/// Decimal key.
|
||||
/// </summary>
|
||||
Decimal = 110,
|
||||
/// <summary>
|
||||
/// Divide key.
|
||||
/// </summary>
|
||||
Divide = 111,
|
||||
/// <summary>
|
||||
/// F1 key.
|
||||
/// </summary>
|
||||
F1 = 112,
|
||||
/// <summary>
|
||||
/// F2 key.
|
||||
/// </summary>
|
||||
F2 = 113,
|
||||
/// <summary>
|
||||
/// F3 key.
|
||||
/// </summary>
|
||||
F3 = 114,
|
||||
/// <summary>
|
||||
/// F4 key.
|
||||
/// </summary>
|
||||
F4 = 115,
|
||||
/// <summary>
|
||||
/// F5 key.
|
||||
/// </summary>
|
||||
F5 = 116,
|
||||
/// <summary>
|
||||
/// F6 key.
|
||||
/// </summary>
|
||||
F6 = 117,
|
||||
/// <summary>
|
||||
/// F7 key.
|
||||
/// </summary>
|
||||
F7 = 118,
|
||||
/// <summary>
|
||||
/// F8 key.
|
||||
/// </summary>
|
||||
F8 = 119,
|
||||
/// <summary>
|
||||
/// F9 key.
|
||||
/// </summary>
|
||||
F9 = 120,
|
||||
/// <summary>
|
||||
/// F10 key.
|
||||
/// </summary>
|
||||
F10 = 121,
|
||||
/// <summary>
|
||||
/// F11 key.
|
||||
/// </summary>
|
||||
F11 = 122,
|
||||
/// <summary>
|
||||
/// F12 key.
|
||||
/// </summary>
|
||||
F12 = 123,
|
||||
/// <summary>
|
||||
/// F13 key.
|
||||
/// </summary>
|
||||
F13 = 124,
|
||||
/// <summary>
|
||||
/// F14 key.
|
||||
/// </summary>
|
||||
F14 = 125,
|
||||
/// <summary>
|
||||
/// F15 key.
|
||||
/// </summary>
|
||||
F15 = 126,
|
||||
/// <summary>
|
||||
/// F16 key.
|
||||
/// </summary>
|
||||
F16 = 127,
|
||||
/// <summary>
|
||||
/// F17 key.
|
||||
/// </summary>
|
||||
F17 = 128,
|
||||
/// <summary>
|
||||
/// F18 key.
|
||||
/// </summary>
|
||||
F18 = 129,
|
||||
/// <summary>
|
||||
/// F19 key.
|
||||
/// </summary>
|
||||
F19 = 130,
|
||||
/// <summary>
|
||||
/// F20 key.
|
||||
/// </summary>
|
||||
F20 = 131,
|
||||
/// <summary>
|
||||
/// F21 key.
|
||||
/// </summary>
|
||||
F21 = 132,
|
||||
/// <summary>
|
||||
/// F22 key.
|
||||
/// </summary>
|
||||
F22 = 133,
|
||||
/// <summary>
|
||||
/// F23 key.
|
||||
/// </summary>
|
||||
F23 = 134,
|
||||
/// <summary>
|
||||
/// F24 key.
|
||||
/// </summary>
|
||||
F24 = 135,
|
||||
/// <summary>
|
||||
/// NUM LOCK key.
|
||||
/// </summary>
|
||||
NumLock = 144,
|
||||
/// <summary>
|
||||
/// SCROLL LOCK key.
|
||||
/// </summary>
|
||||
Scroll = 145,
|
||||
/// <summary>
|
||||
/// Left SHIFT key.
|
||||
/// </summary>
|
||||
LeftShift = 160,
|
||||
/// <summary>
|
||||
/// Right SHIFT key.
|
||||
/// </summary>
|
||||
RightShift = 161,
|
||||
/// <summary>
|
||||
/// Left CONTROL key.
|
||||
/// </summary>
|
||||
LeftControl = 162,
|
||||
/// <summary>
|
||||
/// Right CONTROL key.
|
||||
/// </summary>
|
||||
RightControl = 163,
|
||||
/// <summary>
|
||||
/// Left ALT key.
|
||||
/// </summary>
|
||||
LeftAlt = 164,
|
||||
/// <summary>
|
||||
/// Right ALT key.
|
||||
/// </summary>
|
||||
RightAlt = 165,
|
||||
/// <summary>
|
||||
/// Browser Back key.
|
||||
/// </summary>
|
||||
BrowserBack = 166,
|
||||
/// <summary>
|
||||
/// Browser Forward key.
|
||||
/// </summary>
|
||||
BrowserForward = 167,
|
||||
/// <summary>
|
||||
/// Browser Refresh key.
|
||||
/// </summary>
|
||||
BrowserRefresh = 168,
|
||||
/// <summary>
|
||||
/// Browser Stop key.
|
||||
/// </summary>
|
||||
BrowserStop = 169,
|
||||
/// <summary>
|
||||
/// Browser Search key.
|
||||
/// </summary>
|
||||
BrowserSearch = 170,
|
||||
/// <summary>
|
||||
/// Browser Favorites key.
|
||||
/// </summary>
|
||||
BrowserFavorites = 171,
|
||||
/// <summary>
|
||||
/// Browser Start and Home key.
|
||||
/// </summary>
|
||||
BrowserHome = 172,
|
||||
/// <summary>
|
||||
/// Volume Mute key.
|
||||
/// </summary>
|
||||
VolumeMute = 173,
|
||||
/// <summary>
|
||||
/// Volume Down key.
|
||||
/// </summary>
|
||||
VolumeDown = 174,
|
||||
/// <summary>
|
||||
/// Volume Up key.
|
||||
/// </summary>
|
||||
VolumeUp = 175,
|
||||
/// <summary>
|
||||
/// Next Track key.
|
||||
/// </summary>
|
||||
MediaNextTrack = 176,
|
||||
/// <summary>
|
||||
/// Previous Track key.
|
||||
/// </summary>
|
||||
MediaPreviousTrack = 177,
|
||||
/// <summary>
|
||||
/// Stop Media key.
|
||||
/// </summary>
|
||||
MediaStop = 178,
|
||||
/// <summary>
|
||||
/// Play/Pause Media key.
|
||||
/// </summary>
|
||||
MediaPlayPause = 179,
|
||||
/// <summary>
|
||||
/// Start Mail key.
|
||||
/// </summary>
|
||||
LaunchMail = 180,
|
||||
/// <summary>
|
||||
/// Select Media key.
|
||||
/// </summary>
|
||||
SelectMedia = 181,
|
||||
/// <summary>
|
||||
/// Start Application 1 key.
|
||||
/// </summary>
|
||||
LaunchApplication1 = 182,
|
||||
/// <summary>
|
||||
/// Start Application 2 key.
|
||||
/// </summary>
|
||||
LaunchApplication2 = 183,
|
||||
/// <summary>
|
||||
/// The OEM Semicolon key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemSemicolon = 186,
|
||||
/// <summary>
|
||||
/// For any country/region, the '+' key.
|
||||
/// </summary>
|
||||
OemPlus = 187,
|
||||
/// <summary>
|
||||
/// For any country/region, the ',' key.
|
||||
/// </summary>
|
||||
OemComma = 188,
|
||||
/// <summary>
|
||||
/// For any country/region, the '-' key.
|
||||
/// </summary>
|
||||
OemMinus = 189,
|
||||
/// <summary>
|
||||
/// For any country/region, the '.' key.
|
||||
/// </summary>
|
||||
OemPeriod = 190,
|
||||
/// <summary>
|
||||
/// The OEM question mark key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemQuestion = 191,
|
||||
/// <summary>
|
||||
/// The OEM tilde key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemTilde = 192,
|
||||
/// <summary>
|
||||
/// The OEM open bracket key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemOpenBrackets = 219,
|
||||
/// <summary>
|
||||
/// The OEM pipe key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemPipe = 220,
|
||||
/// <summary>
|
||||
/// The OEM close bracket key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemCloseBrackets = 221,
|
||||
/// <summary>
|
||||
/// The OEM singled/double quote key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemQuotes = 222,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
Oem8 = 223,
|
||||
/// <summary>
|
||||
/// The OEM angle bracket or backslash key on the RT 102 key keyboard.
|
||||
/// </summary>
|
||||
OemBackslash = 226,
|
||||
/// <summary>
|
||||
/// IME PROCESS key.
|
||||
/// </summary>
|
||||
ProcessKey = 229,
|
||||
/// <summary>
|
||||
/// Attn key.
|
||||
/// </summary>
|
||||
Attn = 246,
|
||||
/// <summary>
|
||||
/// CrSel key.
|
||||
/// </summary>
|
||||
Crsel = 247,
|
||||
/// <summary>
|
||||
/// ExSel key.
|
||||
/// </summary>
|
||||
Exsel = 248,
|
||||
/// <summary>
|
||||
/// Erase EOF key.
|
||||
/// </summary>
|
||||
EraseEof = 249,
|
||||
/// <summary>
|
||||
/// Play key.
|
||||
/// </summary>
|
||||
Play = 250,
|
||||
/// <summary>
|
||||
/// Zoom key.
|
||||
/// </summary>
|
||||
Zoom = 251,
|
||||
/// <summary>
|
||||
/// PA1 key.
|
||||
/// </summary>
|
||||
Pa1 = 253,
|
||||
/// <summary>
|
||||
/// CLEAR key.
|
||||
/// </summary>
|
||||
OemClear = 254,
|
||||
/// <summary>
|
||||
/// Green ChatPad key.
|
||||
/// </summary>
|
||||
ChatPadGreen = 0xCA,
|
||||
/// <summary>
|
||||
/// Orange ChatPad key.
|
||||
/// </summary>
|
||||
ChatPadOrange = 0xCB,
|
||||
/// <summary>
|
||||
/// PAUSE key.
|
||||
/// </summary>
|
||||
Pause = 0x13,
|
||||
/// <summary>
|
||||
/// IME Convert key.
|
||||
/// </summary>
|
||||
ImeConvert = 0x1c,
|
||||
/// <summary>
|
||||
/// IME NoConvert key.
|
||||
/// </summary>
|
||||
ImeNoConvert = 0x1d,
|
||||
/// <summary>
|
||||
/// Kana key on Japanese keyboards.
|
||||
/// </summary>
|
||||
Kana = 0x15,
|
||||
/// <summary>
|
||||
/// Kanji key on Japanese keyboards.
|
||||
/// </summary>
|
||||
Kanji = 0x19,
|
||||
/// <summary>
|
||||
/// OEM Auto key.
|
||||
/// </summary>
|
||||
OemAuto = 0xf3,
|
||||
/// <summary>
|
||||
/// OEM Copy key.
|
||||
/// </summary>
|
||||
OemCopy = 0xf2,
|
||||
/// <summary>
|
||||
/// OEM Enlarge Window key.
|
||||
/// </summary>
|
||||
OemEnlW = 0xf4
|
||||
}
|
||||
}
|
||||
220
BarotraumaServer/Source/Utils/MonogameTypes/Point.cs
Normal file
220
BarotraumaServer/Source/Utils/MonogameTypes/Point.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-point.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Point : IEquatable<Point>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static readonly Point zeroPoint = new Point();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
public int Y;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Point"/> with coordinates 0, 0.
|
||||
/// </summary>
|
||||
public static Point Zero
|
||||
{
|
||||
get { return zeroPoint; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X.ToString(), " ",
|
||||
this.Y.ToString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y from two values.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate in 2d-space.</param>
|
||||
/// <param name="y">The y coordinate in 2d-space.</param>
|
||||
public Point(int x, int y)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y set to the same value.
|
||||
/// </summary>
|
||||
/// <param name="value">The x and y coordinates in 2d-space.</param>
|
||||
public Point(int value)
|
||||
{
|
||||
this.X = value;
|
||||
this.Y = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Adds two points.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the add sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the add sign.</param>
|
||||
/// <returns>Sum of the points.</returns>
|
||||
public static Point operator +(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X + value2.X, value1.Y + value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts a <see cref="Point"/> from a <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the sub sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the sub sign.</param>
|
||||
/// <returns>Result of the subtraction.</returns>
|
||||
public static Point operator -(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X - value2.X, value1.Y - value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies the components of two points by each other.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the mul sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the mul sign.</param>
|
||||
/// <returns>Result of the multiplication.</returns>
|
||||
public static Point operator *(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X * value2.X, value1.Y * value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Divides the components of a <see cref="Point"/> by the components of another <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">Source <see cref="Point"/> on the left of the div sign.</param>
|
||||
/// <param name="divisor">Divisor <see cref="Point"/> on the right of the div sign.</param>
|
||||
/// <returns>The result of dividing the points.</returns>
|
||||
public static Point operator /(Point source, Point divisor)
|
||||
{
|
||||
return new Point(source.X / divisor.X, source.Y / divisor.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Point a, Point b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Point a, Point b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Point) && Equals((Point)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Point"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Point other)
|
||||
{
|
||||
return ((X == other.X) && (Y == other.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Point"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Point"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Point"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Vector2"/> representation for this object.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Vector2"/> representation for this object.</returns>
|
||||
public Vector2 ToVector2()
|
||||
{
|
||||
return new Vector2(X, Y);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1170
BarotraumaServer/Source/Utils/MonogameTypes/Quaternion.cs
Normal file
1170
BarotraumaServer/Source/Utils/MonogameTypes/Quaternion.cs
Normal file
File diff suppressed because it is too large
Load Diff
524
BarotraumaServer/Source/Utils/MonogameTypes/Rectangle.cs
Normal file
524
BarotraumaServer/Source/Utils/MonogameTypes/Rectangle.cs
Normal file
@@ -0,0 +1,524 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-rectangle.
|
||||
/// </summary>
|
||||
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Rectangle : IEquatable<Rectangle>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static Rectangle emptyRectangle = new Rectangle();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Y;
|
||||
|
||||
/// <summary>
|
||||
/// The width of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Height;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Rectangle"/> with X=0, Y=0, Width=0, Height=0.
|
||||
/// </summary>
|
||||
public static Rectangle Empty
|
||||
{
|
||||
get { return emptyRectangle; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the left edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Left
|
||||
{
|
||||
get { return this.X; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the right edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Right
|
||||
{
|
||||
get { return (this.X + this.Width); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the top edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Top
|
||||
{
|
||||
get { return this.Y; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the bottom edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Bottom
|
||||
{
|
||||
get { return (this.Y + this.Height); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this <see cref="Rectangle"/> has a <see cref="Width"/> and
|
||||
/// <see cref="Height"/> of 0, and a <see cref="Location"/> of (0, 0).
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((((this.Width == 0) && (this.Height == 0)) && (this.X == 0)) && (this.Y == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The top-left coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X, this.Y);
|
||||
}
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The width-height coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.Width,this.Height);
|
||||
}
|
||||
set
|
||||
{
|
||||
Width = value.X;
|
||||
Height = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Point"/> located in the center of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <see cref="Width"/> or <see cref="Height"/> is an odd number,
|
||||
/// the center point will be rounded down.
|
||||
/// </remarks>
|
||||
public Point Center
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X + (this.Width / 2), this.Y + (this.Height / 2));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X, " ",
|
||||
this.Y, " ",
|
||||
this.Width, " ",
|
||||
this.Height
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// position, width, and height.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="y">The y coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="width">The width of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="height">The height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(int x, int y, int width, int height)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// location and size.
|
||||
/// </summary>
|
||||
/// <param name="location">The x and y coordinates of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="size">The width and height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(Point location,Point size)
|
||||
{
|
||||
this.X = location.X;
|
||||
this.Y = location.Y;
|
||||
this.Width = size.X;
|
||||
this.Height = size.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Rectangle a, Rectangle b)
|
||||
{
|
||||
return ((a.X == b.X) && (a.Y == b.Y) && (a.Width == b.Width) && (a.Height == b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Rectangle a, Rectangle b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(int x, int y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Point value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Point value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Vector2 value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Vector2 value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Rectangle value)
|
||||
{
|
||||
return ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Rectangle value,out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Rectangle) && this == ((Rectangle)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Rectangle"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Rectangle other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Rectangle"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
hash = hash * 23 + Width.GetHashCode();
|
||||
hash = hash * 23 + Height.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(int horizontalAmount, int verticalAmount)
|
||||
{
|
||||
X -= horizontalAmount;
|
||||
Y -= verticalAmount;
|
||||
Width += horizontalAmount * 2;
|
||||
Height += verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(float horizontalAmount, float verticalAmount)
|
||||
{
|
||||
X -= (int)horizontalAmount;
|
||||
Y -= (int)verticalAmount;
|
||||
Width += (int)horizontalAmount * 2;
|
||||
Height += (int)verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(Rectangle value)
|
||||
{
|
||||
return value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref Rectangle value, out bool result)
|
||||
{
|
||||
result = value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>Overlapping region of the two rectangles.</returns>
|
||||
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
Rectangle rectangle;
|
||||
Intersect(ref value1, ref value2, out rectangle);
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">Overlapping region of the two rectangles as an output parameter.</param>
|
||||
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
if (value1.Intersects(value2))
|
||||
{
|
||||
int right_side = Math.Min(value1.X + value1.Width, value2.X + value2.Width);
|
||||
int left_side = Math.Max(value1.X, value2.X);
|
||||
int top_side = Math.Max(value1.Y, value2.Y);
|
||||
int bottom_side = Math.Min(value1.Y + value1.Height, value2.Y + value2.Height);
|
||||
result = new Rectangle(left_side, top_side, right_side - left_side, bottom_side - top_side);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new Rectangle(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(int offsetX, int offsetY)
|
||||
{
|
||||
X += offsetX;
|
||||
Y += offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(float offsetX, float offsetY)
|
||||
{
|
||||
X += (int)offsetX;
|
||||
Y += (int)offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Point amount)
|
||||
{
|
||||
X += amount.X;
|
||||
Y += amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Vector2 amount)
|
||||
{
|
||||
X += (int)amount.X;
|
||||
Y += (int)amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Rectangle"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>] Width:[<see cref="Width"/>] Height:[<see cref="Height"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Rectangle"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + " Width:" + Width + " Height:" + Height + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>The union of the two rectangles.</returns>
|
||||
public static Rectangle Union(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
int x = Math.Min(value1.X, value2.X);
|
||||
int y = Math.Min(value1.Y, value2.Y);
|
||||
return new Rectangle(x, y,
|
||||
Math.Max(value1.Right, value2.Right) - x,
|
||||
Math.Max(value1.Bottom, value2.Bottom) - y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">The union of the two rectangles as an output parameter.</param>
|
||||
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
result.X = Math.Min(value1.X, value2.X);
|
||||
result.Y = Math.Min(value1.Y, value2.Y);
|
||||
result.Width = Math.Max(value1.Right, value2.Right) - result.X;
|
||||
result.Height = Math.Max(value1.Bottom, value2.Bottom) - result.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
1238
BarotraumaServer/Source/Utils/MonogameTypes/Vector4.cs
Normal file
1238
BarotraumaServer/Source/Utils/MonogameTypes/Vector4.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,8 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class AIController : ISteerable
|
||||
partial class AIController : ISteerable
|
||||
{
|
||||
|
||||
public enum AiState { None, Attack, GoTo, Escape }
|
||||
public enum SteeringState { Wander, Seek, Escape }
|
||||
|
||||
@@ -57,8 +56,6 @@ namespace Barotrauma
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public virtual void DebugDraw(SpriteBatch spriteBatch) { }
|
||||
|
||||
public virtual void OnAttacked(IDamageable attacker, float amount) { }
|
||||
|
||||
public virtual void SelectTarget(AITarget target) { }
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics.Joints;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Items.Components;
|
||||
using System.Text;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class GameMode
|
||||
partial class GameMode
|
||||
{
|
||||
public static List<GameModePreset> PresetList = new List<GameModePreset>();
|
||||
|
||||
@@ -55,10 +55,6 @@ namespace Barotrauma
|
||||
this.preset = preset;
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
startTime = DateTime.Now;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Barotrauma.Networking;
|
||||
using Lidgren.Network;
|
||||
using System.Collections.Generic;
|
||||
@@ -18,8 +17,6 @@ namespace Barotrauma
|
||||
|
||||
partial class CharacterInventory : Inventory
|
||||
{
|
||||
private static Texture2D icons;
|
||||
|
||||
private Character character;
|
||||
|
||||
public static InvSlotType[] limbSlots = new InvSlotType[] {
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint();
|
||||
hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition));
|
||||
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]);
|
||||
hulls[i].AddToGrid(subs[i]);
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint();
|
||||
hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition));
|
||||
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]);
|
||||
hulls[i].AddToGrid(subs[i]);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using FarseerPhysics.Dynamics.Contacts;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
@@ -281,11 +281,11 @@ namespace Barotrauma
|
||||
{
|
||||
if (grid.Submarine != submarine) continue;
|
||||
|
||||
rect.Location -= submarine.HiddenSubPosition.ToPoint();
|
||||
rect.Location -= MathUtils.ToPoint(submarine.HiddenSubPosition);
|
||||
|
||||
grid.InsertEntity(this);
|
||||
|
||||
rect.Location += submarine.HiddenSubPosition.ToPoint();
|
||||
rect.Location += MathUtils.ToPoint(submarine.HiddenSubPosition);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ using FarseerPhysics.Factories;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
static class CaveGenerator
|
||||
static partial class CaveGenerator
|
||||
{
|
||||
public static List<VoronoiCell> CarveCave(List<VoronoiCell> cells, Vector2 startPoint, out List<VoronoiCell> newCells)
|
||||
{
|
||||
@@ -360,10 +360,9 @@ namespace Barotrauma
|
||||
return pathCells;
|
||||
}
|
||||
|
||||
public static List<Body> GeneratePolygons(List<VoronoiCell> cells, out List<VertexPositionTexture> verticeList, bool setSolid=true)
|
||||
public static List<Body> GeneratePolygons(List<VoronoiCell> cells, out List<Vector2[]> renderTriangles, bool setSolid=true)
|
||||
{
|
||||
//TODO: consider separating body generation from render triangle generation
|
||||
verticeList = new List<VertexPositionTexture>();
|
||||
renderTriangles = null;
|
||||
var bodies = new List<Body>();
|
||||
|
||||
List<Vector2> tempVertices = new List<Vector2>();
|
||||
@@ -396,20 +395,8 @@ namespace Barotrauma
|
||||
continue;
|
||||
}
|
||||
|
||||
var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
foreach (Vector2 vertex in triangles[i])
|
||||
{
|
||||
//shift the coordinates around a bit to make the texture repetition less obvious
|
||||
Vector2 uvCoords = new Vector2(
|
||||
vertex.X / 2000.0f + (float)Math.Sin(vertex.X / 500.0f) * 0.15f,
|
||||
vertex.Y / 2000.0f + (float)Math.Sin(vertex.Y / 700.0f) * 0.15f);
|
||||
|
||||
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 1.0f), uvCoords));
|
||||
}
|
||||
}
|
||||
|
||||
renderTriangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
|
||||
|
||||
if (bodyPoints.Count < 2) continue;
|
||||
|
||||
if (bodyPoints.Count < 3)
|
||||
@@ -431,7 +418,7 @@ namespace Barotrauma
|
||||
|
||||
if (cell.CellType == CellType.Empty) continue;
|
||||
|
||||
triangles = MathUtils.TriangulateConvexHull(bodyPoints, ConvertUnits.ToSimUnits(cell.Center));
|
||||
var triangles = MathUtils.TriangulateConvexHull(bodyPoints, ConvertUnits.ToSimUnits(cell.Center));
|
||||
|
||||
Body cellBody = new Body(GameMain.World);
|
||||
|
||||
@@ -459,135 +446,6 @@ namespace Barotrauma
|
||||
return bodies;
|
||||
}
|
||||
|
||||
public static VertexPositionTexture[] GenerateWallShapes(List<VoronoiCell> cells)
|
||||
{
|
||||
float inwardThickness = 500.0f, outWardThickness = 30.0f;
|
||||
|
||||
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
|
||||
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
//if (cell.body == null) continue;
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
if (edge.cell1 != null && edge.cell1.body == null && edge.cell1.CellType != CellType.Empty) edge.cell1 = null;
|
||||
if (edge.cell2 != null && edge.cell2.body == null && edge.cell2.CellType != CellType.Empty) edge.cell2 = null;
|
||||
|
||||
CompareCCW compare = new CompareCCW(cell.Center);
|
||||
if (compare.Compare(edge.point1, edge.point2) == -1)
|
||||
{
|
||||
var temp = edge.point1;
|
||||
edge.point1 = edge.point2;
|
||||
edge.point2 = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
//if (cell.body == null) continue;
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
if (!edge.isSolid) continue;
|
||||
|
||||
GraphEdge leftEdge = cell.edges.Find(e => e != edge && (edge.point1 == e.point1 || edge.point1 == e.point2));
|
||||
GraphEdge rightEdge = cell.edges.Find(e => e != edge && (edge.point2 == e.point1 || edge.point2 == e.point2));
|
||||
|
||||
Vector2 leftNormal = Vector2.Zero, rightNormal = Vector2.Zero;
|
||||
|
||||
if (leftEdge == null)
|
||||
{
|
||||
leftNormal = GetEdgeNormal(edge, cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftNormal = (leftEdge.isSolid) ?
|
||||
Vector2.Normalize(GetEdgeNormal(leftEdge) + GetEdgeNormal(edge, cell)) :
|
||||
Vector2.Normalize(leftEdge.Center - edge.point1);
|
||||
}
|
||||
|
||||
|
||||
if (!MathUtils.IsValid(leftNormal))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid left normal");
|
||||
#endif
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
leftNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (rightEdge == null)
|
||||
{
|
||||
rightNormal = GetEdgeNormal(edge, cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
rightNormal = (rightEdge.isSolid) ?
|
||||
Vector2.Normalize(GetEdgeNormal(rightEdge) + GetEdgeNormal(edge, cell)) :
|
||||
Vector2.Normalize(rightEdge.Center - edge.point2);
|
||||
}
|
||||
|
||||
if (!MathUtils.IsValid(rightNormal))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Invalid right normal");
|
||||
#endif
|
||||
if (cell.body != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(cell.body);
|
||||
cell.body = null;
|
||||
}
|
||||
rightNormal = Vector2.UnitX;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vector2[] verts = new Vector2[3];
|
||||
VertexPositionTexture[] vertPos = new VertexPositionTexture[3];
|
||||
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
verts[0] = edge.point1 - leftNormal * outWardThickness;
|
||||
verts[1] = edge.point2 - rightNormal * outWardThickness;
|
||||
verts[2] = edge.point1 + leftNormal * inwardThickness;
|
||||
|
||||
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), Vector2.Zero);
|
||||
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
|
||||
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(0, 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
verts[0] = edge.point1 + leftNormal * inwardThickness;
|
||||
verts[1] = edge.point2 - rightNormal * outWardThickness;
|
||||
verts[2] = edge.point2 + rightNormal * inwardThickness;
|
||||
|
||||
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), new Vector2(0.0f, 0.5f));
|
||||
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
|
||||
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(1.0f, 0.5f));
|
||||
}
|
||||
|
||||
var comparer = new CompareCCW((verts[0] + verts[1] + verts[2]) / 3.0f);
|
||||
Array.Sort(verts, vertPos, comparer);
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
verticeList.Add(vertPos[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return verticeList.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find the index of the cell which the point is inside
|
||||
/// (actually finds the cell whose center is closest, but it's always the correct cell assuming the point is inside the borders of the diagram)
|
||||
|
||||
@@ -440,11 +440,12 @@ namespace Barotrauma
|
||||
|
||||
List<VoronoiCell> cellsWithBody = new List<VoronoiCell>(cells);
|
||||
|
||||
List<VertexPositionTexture> bodyVertices;
|
||||
bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out bodyVertices);
|
||||
List<Vector2[]> triangles;
|
||||
bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out triangles);
|
||||
|
||||
#if CLIENT
|
||||
|
||||
List<VertexPositionTexture> bodyVertices = CaveGenerator.GenerateRenderVerticeList(triangles);
|
||||
|
||||
renderer.SetBodyVertices(bodyVertices.ToArray());
|
||||
renderer.SetWallVertices(CaveGenerator.GenerateWallShapes(cells));
|
||||
|
||||
@@ -714,7 +715,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var ruin = new Ruin(closestPathCell, cells, new Rectangle((ruinPos - ruinSize * 0.5f).ToPoint(), ruinSize.ToPoint()));
|
||||
var ruin = new Ruin(closestPathCell, cells, new Rectangle(MathUtils.ToPoint(ruinPos - ruinSize * 0.5f), MathUtils.ToPoint(ruinSize)));
|
||||
ruins.Add(ruin);
|
||||
|
||||
ruin.RuinShapes.Sort((shape1, shape2) => shape2.DistanceFromEntrance.CompareTo(shape1.DistanceFromEntrance));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -157,7 +156,7 @@ namespace Barotrauma
|
||||
|
||||
linkedSub.loadSub = true;
|
||||
|
||||
linkedSub.rect.Location = pos.ToPoint();
|
||||
linkedSub.rect.Location = MathUtils.ToPoint(pos);
|
||||
}
|
||||
|
||||
linkedSub.filePath = ToolBox.GetAttributeString(element, "filepath", "");
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
//using Microsoft.Xna.Framework.Graphics;
|
||||
//using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.ObjectModel;
|
||||
using Barotrauma.Items.Components;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -152,7 +151,7 @@ namespace Barotrauma
|
||||
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||
newRect.Location -= MathUtils.ToPoint(Submarine.MainSub.Position);
|
||||
}
|
||||
|
||||
if (PlayerInput.LeftButtonReleased())
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Barotrauma
|
||||
//don't allow resizing width/height to zero
|
||||
if ((!resizeHorizontal || placeSize.X != 0.0f) && (!resizeVertical || placeSize.Y != 0.0f))
|
||||
{
|
||||
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||
newRect.Location -= MathUtils.ToPoint(Submarine.MainSub.Position);
|
||||
|
||||
var structure = new Structure(newRect, this, Submarine.MainSub);
|
||||
structure.Submarine = Submarine.MainSub;
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace Barotrauma
|
||||
|
||||
Rectangle dockedSubBorders = dockedSub.Borders;
|
||||
dockedSubBorders.Y -= dockedSubBorders.Height;
|
||||
dockedSubBorders.Location += diff.ToPoint();
|
||||
dockedSubBorders.Location += MathUtils.ToPoint(diff);
|
||||
|
||||
dockedBorders = Rectangle.Union(dockedBorders, dockedSubBorders);
|
||||
}
|
||||
@@ -740,7 +740,7 @@ namespace Barotrauma
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Microsoft.Xna.Framework.Point(0, sub.Borders.Height);
|
||||
subBorders.Location += MathUtils.ToPoint(sub.HiddenSubPosition) - new Microsoft.Xna.Framework.Point(0, sub.Borders.Height);
|
||||
|
||||
subBorders.Inflate(500.0f, 500.0f);
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Barotrauma
|
||||
if (Position.X < 0 || Position.X > Level.Loaded.Size.X)
|
||||
{
|
||||
Rectangle worldBorders = Borders;
|
||||
worldBorders.Location += Position.ToPoint();
|
||||
worldBorders.Location += MathUtils.ToPoint(Position);
|
||||
|
||||
//push the sub back below the upper "barrier" of the level
|
||||
if (worldBorders.Y > Level.Loaded.Size.Y)
|
||||
@@ -276,7 +276,7 @@ namespace Barotrauma
|
||||
private void DisplaceCharacters(Vector2 subTranslation)
|
||||
{
|
||||
Rectangle worldBorders = Borders;
|
||||
worldBorders.Location += ConvertUnits.ToDisplayUnits(Body.SimPosition).ToPoint();
|
||||
worldBorders.Location += MathUtils.ToPoint(ConvertUnits.ToDisplayUnits(Body.SimPosition));
|
||||
|
||||
Vector2 translateDir = Vector2.Normalize(subTranslation);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
//using Microsoft.Xna.Framework.Graphics;
|
||||
//using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.ObjectModel;
|
||||
using Barotrauma.Items.Components;
|
||||
using FarseerPhysics.Dynamics;
|
||||
@@ -181,7 +180,7 @@ namespace Barotrauma
|
||||
borders.Width += outsideWaypointDist * 2;
|
||||
borders.Height += outsideWaypointDist * 2;
|
||||
|
||||
borders.Location -= submarine.HiddenSubPosition.ToPoint();
|
||||
borders.Location -= MathUtils.ToPoint(submarine.HiddenSubPosition);
|
||||
|
||||
if (borders.Width <= outSideWaypointInterval*2)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
using Lidgren.Network;
|
||||
using Barotrauma.Items.Components;
|
||||
|
||||
@@ -248,12 +248,6 @@ namespace Barotrauma
|
||||
set { body.CollidesWith = value; }
|
||||
}
|
||||
|
||||
private Texture2D bodyShapeTexture;
|
||||
public Texture2D BodyShapeTexture
|
||||
{
|
||||
get { return bodyShapeTexture; }
|
||||
}
|
||||
|
||||
public PhysicsBody(XElement element, float scale = 1.0f)
|
||||
: this(element, Vector2.Zero, scale)
|
||||
{
|
||||
@@ -538,11 +532,7 @@ namespace Barotrauma
|
||||
list.Remove(this);
|
||||
GameMain.World.RemoveBody(body);
|
||||
|
||||
if (bodyShapeTexture != null)
|
||||
{
|
||||
bodyShapeTexture.Dispose();
|
||||
bodyShapeTexture = null;
|
||||
}
|
||||
DisposeProjSpecific();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Barotrauma
|
||||
return (float)Math.Atan2(vector.Y, vector.X);
|
||||
}
|
||||
|
||||
public static Point ToPoint(Vector2 vector)
|
||||
{
|
||||
return new Point((int)vector.X,(int)vector.Y);
|
||||
}
|
||||
|
||||
public static bool IsValid(float value)
|
||||
{
|
||||
return (!float.IsInfinity(value) && !float.IsNaN(value));
|
||||
|
||||
@@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Barotrauma", "Barotrauma",
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{DE36F45F-F09E-4719-B953-00D148F7722A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Farseer Physics", "Farseer Physics Engine 3.5\Farseer Physics.csproj", "{A4610E4C-DD34-428B-BABB-779CA0B5993A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
BarotraumaShared\BarotraumaShared.projitems*{008c0f83-e914-4966-9135-ea885059edd8}*SharedItemsImports = 4
|
||||
@@ -408,6 +410,60 @@ Global
|
||||
{85232B20-074D-4723-B0C6-91495391E448}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||
{85232B20-074D-4723-B0C6-91495391E448}.Windows8|x86.ActiveCfg = Release|x86
|
||||
{85232B20-074D-4723-B0C6-91495391E448}.Windows8|x86.Build.0 = Release|x86
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Android|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.iOS|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Linux|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.OSX|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.PSM|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows|x86.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|x86.ActiveCfg = Release|Any CPU
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A}.Windows8|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -422,5 +478,6 @@ Global
|
||||
{2E4773B7-961A-4328-9D77-9749F9071CA2} = {DE36F45F-F09E-4719-B953-00D148F7722A}
|
||||
{85232B20-074D-4723-B0C6-91495391E448} = {F35DF9BF-0BED-4FEF-A51C-DD83C531882F}
|
||||
{561357C2-DB28-4E01-B275-6BF545F70491} = {F35DF9BF-0BED-4FEF-A51C-DD83C531882F}
|
||||
{A4610E4C-DD34-428B-BABB-779CA0B5993A} = {DE36F45F-F09E-4719-B953-00D148F7722A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -72,6 +72,18 @@ namespace Microsoft.Xna.Framework
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int Clamp(int value, int min, int max)
|
||||
{
|
||||
// First we check to see if we're greater than the max
|
||||
value = (value > max) ? max : value;
|
||||
|
||||
// Then we check to see if we're less than the min.
|
||||
value = (value < min) ? min : value;
|
||||
|
||||
// There's no check to see if min > max.
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float Distance(float value1, float value2)
|
||||
{
|
||||
return Math.Abs(value1 - value2);
|
||||
|
||||
Reference in New Issue
Block a user