[GameplayKit] Adopt XAMCORE_4_0 changes in .NET. (#13972)

This commit is contained in:
Rolf Bjarne Kvinge 2022-01-31 17:51:08 +01:00 коммит произвёл GitHub
Родитель 8405fcf3b8
Коммит 6674e83bec
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 55 добавлений и 31 удалений

Просмотреть файл

@ -6,34 +6,20 @@ using ObjCRuntime;
using OpenTK;
using System.Runtime.Versioning;
#if !XAMCORE_4_0 && !MONOMAC && !__MACCATALYST__
#if !NET && !MONOMAC && !__MACCATALYST__
namespace GameplayKit {
public partial class GKQuadTree {
#if !NET
[Obsolete ("Use the constructor with the same signature.")]
#else
[Obsolete ("Use the constructor with the same signature.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public static GKQuadTree QuadTreeWithMinPosition (Vector2 min, Vector2 max, float minCellSize)
{
return new GKQuadTree (min, max, minCellSize);
}
#if !NET
[Deprecated (PlatformName.iOS, 10,0, message: "Empty stub (always return 'false') as this API is now rejected).")]
[Deprecated (PlatformName.TvOS, 10,0, message: "Empty stub (always return 'false') as this API is now rejected).")]
#else
[UnsupportedOSPlatform ("ios10.0")]
[UnsupportedOSPlatform ("tvos10.0")]
#if IOS
[Obsolete ("Starting with ios10.0 empty stub (always return 'false') as this API is now rejected).", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif TVOS
[Obsolete ("Starting with tvos10.0 empty stub (always return 'false') as this API is now rejected).", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#endif
public virtual bool RemoveData (NSObject data)
{
return false;
@ -41,12 +27,7 @@ namespace GameplayKit {
}
public partial class GKQuadTreeNode {
#if !NET
[Obsolete ("A valid instance of this type cannot be directly created.")]
#else
[Obsolete ("A valid instance of this type cannot be directly created.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public GKQuadTreeNode ()
{
}

Просмотреть файл

@ -14,7 +14,7 @@ using Vector2i = global::OpenTK.Vector2i;
namespace GameplayKit {
public partial class GKGridGraph {
#if !XAMCORE_4_0
#if !NET
public virtual GKGridGraphNode GetNodeAt (Vector2i position)
{
return GetNodeAt<GKGridGraphNode> (position);

Просмотреть файл

@ -18,11 +18,11 @@ using NativeHandle = System.IntPtr;
namespace GameplayKit {
public partial class GKObstacleGraph {
public
#if !XAMCORE_4_0
virtual
#if !NET
public virtual GKGraphNode2D [] GetNodes (GKPolygonObstacle obstacle)
#else
public GKGraphNode2D [] GetNodes (GKPolygonObstacle obstacle)
#endif
GKGraphNode2D [] GetNodes (GKPolygonObstacle obstacle)
{
return NSArray.ArrayFromHandle<GKGraphNode2D> (_GetNodes (obstacle));
}

Просмотреть файл

@ -138,7 +138,7 @@ namespace GameplayKit {
[Export ("rightHanded")]
bool RightHanded { get; set; }
#if !XAMCORE_4_0
#if !NET
[Obsolete ("Use 'Rotation3x3' instead.")]
[Export ("rotation", ArgumentSemantic.Assign)]
Matrix3 Rotation {
@ -150,7 +150,7 @@ namespace GameplayKit {
#endif
[Export ("rotation", ArgumentSemantic.Assign)]
#if XAMCORE_4_0
#if NET
MatrixFloat3x3 Rotation {
#else
[Sealed]
@ -853,7 +853,7 @@ namespace GameplayKit {
Vector2i GridPosition {
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")]
get;
#if !XAMCORE_4_0
#if !NET
[NotImplemented]
set;
#endif
@ -1478,7 +1478,7 @@ namespace GameplayKit {
[Export ("displaceXWithNoise:yWithNoise:zWithNoise:")]
void Displace (GKNoise xDisplacementNoise, GKNoise yDisplacementNoise, GKNoise zDisplacementNoise);
#if !XAMCORE_4_0
#if !NET
[Obsolete ("Use 'GKNoise.Displace' instead.")]
[Wrap ("Displace (xDisplacementNoise, yDisplacementNoise, zDisplacementNoise)", isVirtual: true)]
void DisplaceX (GKNoise xDisplacementNoise, GKNoise yDisplacementNoise, GKNoise zDisplacementNoise);
@ -1950,7 +1950,7 @@ namespace GameplayKit {
[Export ("removeElement:withNode:")]
bool RemoveElement (NSObject data, GKQuadTreeNode node);
#if !XAMCORE_4_0 && !MONOMAC // This API is removed in Xcode 8
#if !NET && !MONOMAC // This API is removed in Xcode 8
[Deprecated (PlatformName.iOS, 10, 0)]
[Deprecated (PlatformName.TvOS, 10, 0)]

Просмотреть файл

@ -44,24 +44,43 @@ namespace MonoTouchFixtures.GamePlayKit
public void RotationTest ()
{
using (var obj = new GKAgent3D ()) {
#if NET
var initial = new MatrixFloat3x3 (0, 0, 1,
0, 1, 0,
1, 0, 0);
#else
var initial = new Matrix3 (0, 0, 1,
0, 1, 0,
1, 0, 0);
#endif
Asserts.AreEqual (initial, obj.Rotation, "Rotation");
#if !NET
Asserts.AreEqual ((MatrixFloat3x3) initial, obj.Rotation3x3, "Rotation3x3");
#endif
#if !NET
var mat = new Matrix3 (1, 2, 3,
4, 5, 6,
7, 8, 9);
var mat3x3 = (MatrixFloat3x3) mat;
#endif
var mat3x3 = new MatrixFloat3x3 (1, 2, 3,
4, 5, 6,
7, 8, 9);;
#if !NET
obj.Rotation = mat;
Asserts.AreEqual (mat, obj.Rotation, "Rotation after setter");
var transposed3x3 = MatrixFloat3x3.Transpose ((MatrixFloat3x3) mat);
Asserts.AreEqual (transposed3x3, obj.Rotation3x3, "Rotation3x3 after setter");
Asserts.AreEqual (transposed3x3, CFunctions.GetMatrixFloat3x3 (obj, "rotation"), "Rotation3x3 after setter native");
#endif
#if NET
obj.Rotation = mat3x3;
Asserts.AreEqual (mat3x3, obj.Rotation, "Rotation3x3 after setter 3x3");
#else
obj.Rotation3x3 = mat3x3;
Asserts.AreEqual (mat3x3, obj.Rotation3x3, "Rotation3x3 after setter 3x3");
#endif
Asserts.AreEqual (mat3x3, CFunctions.GetMatrixFloat3x3 (obj, "rotation"), "Rotation3x3 after setter native 3x3");
}
}

Просмотреть файл

@ -61,13 +61,25 @@ namespace MonoTouchFixtures.GamePlayKit {
var tile = maze[i * 10 + j];
switch ((TileType)tile) {
case TileType.Wall:
#if NET
walls.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
walls.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break;
case TileType.Portal:
#if NET
spawnPoints.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break;
case TileType.Start:
#if NET
startPosition = graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j));
#else
startPosition = graph.GetNodeAt (new Vector2i (i, j));
#endif
break;
default:
break;
@ -104,13 +116,25 @@ namespace MonoTouchFixtures.GamePlayKit {
var tile = maze[i * 10 + j];
switch ((TileType)tile) {
case TileType.Wall:
#if NET
walls.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
walls.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break;
case TileType.Portal:
#if NET
spawnPoints.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break;
case TileType.Start:
#if NET
startPosition = graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j));
#else
startPosition = graph.GetNodeAt (new Vector2i (i, j));
#endif
break;
default:
break;