[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 OpenTK;
using System.Runtime.Versioning; using System.Runtime.Versioning;
#if !XAMCORE_4_0 && !MONOMAC && !__MACCATALYST__ #if !NET && !MONOMAC && !__MACCATALYST__
namespace GameplayKit { namespace GameplayKit {
public partial class GKQuadTree { public partial class GKQuadTree {
#if !NET
[Obsolete ("Use the constructor with the same signature.")] [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) public static GKQuadTree QuadTreeWithMinPosition (Vector2 min, Vector2 max, float minCellSize)
{ {
return new GKQuadTree (min, max, 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.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).")] [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) public virtual bool RemoveData (NSObject data)
{ {
return false; return false;
@ -41,12 +27,7 @@ namespace GameplayKit {
} }
public partial class GKQuadTreeNode { public partial class GKQuadTreeNode {
#if !NET
[Obsolete ("A valid instance of this type cannot be directly created.")] [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 () public GKQuadTreeNode ()
{ {
} }

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

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

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

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

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

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

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

@ -44,24 +44,43 @@ namespace MonoTouchFixtures.GamePlayKit
public void RotationTest () public void RotationTest ()
{ {
using (var obj = new GKAgent3D ()) { 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, var initial = new Matrix3 (0, 0, 1,
0, 1, 0, 0, 1, 0,
1, 0, 0); 1, 0, 0);
#endif
Asserts.AreEqual (initial, obj.Rotation, "Rotation"); Asserts.AreEqual (initial, obj.Rotation, "Rotation");
#if !NET
Asserts.AreEqual ((MatrixFloat3x3) initial, obj.Rotation3x3, "Rotation3x3"); Asserts.AreEqual ((MatrixFloat3x3) initial, obj.Rotation3x3, "Rotation3x3");
#endif
#if !NET
var mat = new Matrix3 (1, 2, 3, var mat = new Matrix3 (1, 2, 3,
4, 5, 6, 4, 5, 6,
7, 8, 9); 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; obj.Rotation = mat;
Asserts.AreEqual (mat, obj.Rotation, "Rotation after setter"); Asserts.AreEqual (mat, obj.Rotation, "Rotation after setter");
var transposed3x3 = MatrixFloat3x3.Transpose ((MatrixFloat3x3) mat); var transposed3x3 = MatrixFloat3x3.Transpose ((MatrixFloat3x3) mat);
Asserts.AreEqual (transposed3x3, obj.Rotation3x3, "Rotation3x3 after setter"); Asserts.AreEqual (transposed3x3, obj.Rotation3x3, "Rotation3x3 after setter");
Asserts.AreEqual (transposed3x3, CFunctions.GetMatrixFloat3x3 (obj, "rotation"), "Rotation3x3 after setter native"); 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; obj.Rotation3x3 = mat3x3;
Asserts.AreEqual (mat3x3, obj.Rotation3x3, "Rotation3x3 after setter 3x3"); Asserts.AreEqual (mat3x3, obj.Rotation3x3, "Rotation3x3 after setter 3x3");
#endif
Asserts.AreEqual (mat3x3, CFunctions.GetMatrixFloat3x3 (obj, "rotation"), "Rotation3x3 after setter native 3x3"); 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]; var tile = maze[i * 10 + j];
switch ((TileType)tile) { switch ((TileType)tile) {
case TileType.Wall: case TileType.Wall:
#if NET
walls.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
walls.Add (graph.GetNodeAt (new Vector2i (i, j))); walls.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break; break;
case TileType.Portal: case TileType.Portal:
#if NET
spawnPoints.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j))); spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break; break;
case TileType.Start: case TileType.Start:
#if NET
startPosition = graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j));
#else
startPosition = graph.GetNodeAt (new Vector2i (i, j)); startPosition = graph.GetNodeAt (new Vector2i (i, j));
#endif
break; break;
default: default:
break; break;
@ -104,13 +116,25 @@ namespace MonoTouchFixtures.GamePlayKit {
var tile = maze[i * 10 + j]; var tile = maze[i * 10 + j];
switch ((TileType)tile) { switch ((TileType)tile) {
case TileType.Wall: case TileType.Wall:
#if NET
walls.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
walls.Add (graph.GetNodeAt (new Vector2i (i, j))); walls.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break; break;
case TileType.Portal: case TileType.Portal:
#if NET
spawnPoints.Add (graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j)));
#else
spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j))); spawnPoints.Add (graph.GetNodeAt (new Vector2i (i, j)));
#endif
break; break;
case TileType.Start: case TileType.Start:
#if NET
startPosition = graph.GetNodeAt<GKGridGraphNode> (new Vector2i (i, j));
#else
startPosition = graph.GetNodeAt (new Vector2i (i, j)); startPosition = graph.GetNodeAt (new Vector2i (i, j));
#endif
break; break;
default: default:
break; break;