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");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Tests/ShapeTestScript.cs.meta
Normal file
11
Assets/Scripts/Tests/ShapeTestScript.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 931f464e9597e104a8c9b6fa0763fb57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/Tests/Tests.asmdef
Normal file
25
Assets/Scripts/Tests/Tests.asmdef
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Tests",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"Economy.Shared.Unity",
|
||||
"Unity.Mathematics"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Scripts/Tests/Tests.asmdef.meta
Normal file
7
Assets/Scripts/Tests/Tests.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92d0b2b5224d7474a9067650a2ea50d4
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue