Sector & Loadout Generation Fixes
Adjusted sector generation to improve sample elimination performance and better preserve density map Added unit tests for item shape rotation and fit functions + fixed those (required for correct loadout generation)! Fixed faction hostility by marking player ship Added faction to entity serialization Generating starting loadout for player ship
This commit is contained in:
parent
ebde23a64d
commit
351cb9f2af
23 changed files with 879 additions and 128 deletions
43
Assets/Scripts/Tests/ShapeTestScript.cs
Normal file
43
Assets/Scripts/Tests/ShapeTestScript.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using int2 = Unity.Mathematics.int2;
|
||||
|
||||
|
||||
public class ShapeTestScript
|
||||
{
|
||||
[Test]
|
||||
public void ShapeRotation()
|
||||
{
|
||||
// Use the Assert class to test conditions
|
||||
var verticalShape = new Shape(1, 2);
|
||||
foreach (var v in verticalShape.AllCoordinates) verticalShape[v] = true;
|
||||
|
||||
Assert.True(verticalShape.Rotate(int2.zero, ItemRotation.None).Equals(int2.zero), "verticalShape.Rotate(int2.zero, ItemRotation.None).Equals(int2.zero)");
|
||||
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.Reversed).Equals(int2.zero), "verticalShape.Rotate(int2(0,1), ItemRotation.Reversed).Equals(int2.zero)");
|
||||
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.CounterClockwise).Equals(int2.zero), "verticalShape.Rotate(int2(0,1), ItemRotation.CounterClockwise).Equals(int2.zero)");
|
||||
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.Clockwise).Equals(int2(1,0)), "verticalShape.Rotate(int2(0,1), ItemRotation.Clockwise).Equals(int2(1,0))");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShapeFitsWithin()
|
||||
{
|
||||
// Use the Assert class to test conditions
|
||||
var verticalShape = new Shape(1, 2);
|
||||
foreach (var v in verticalShape.AllCoordinates) verticalShape[v] = true;
|
||||
|
||||
Assert.True(verticalShape.FitsWithin(verticalShape, ItemRotation.None, out _), "verticalShape.FitsWithin(verticalShape, ItemRotation.None, out _)");
|
||||
|
||||
var horizontalShape = new Shape(2, 1);
|
||||
foreach (var v in horizontalShape.AllCoordinates) horizontalShape[v] = true;
|
||||
|
||||
Assert.True(horizontalShape.FitsWithin(verticalShape, ItemRotation.Clockwise, out _), "horizontalShape.FitsWithin(verticalShape, ItemRotation.Clockwise, out _)");
|
||||
|
||||
Assert.True(horizontalShape.FitsWithin(verticalShape, out var rotation, out _), "horizontalShape.FitsWithin(horizontalShape, out rotation, out _)");
|
||||
Assert.True(rotation == ItemRotation.Clockwise || rotation == ItemRotation.CounterClockwise, "rotation == ItemRotation.Clockwise || rotation == ItemRotation.CounterClockwise");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue