no message

This commit is contained in:
PC-20230316NUNE\Administrator
2024-02-20 18:39:12 +08:00
parent 97b3671979
commit 2b467e56ad
1876 changed files with 440340 additions and 35266 deletions

View File

@@ -0,0 +1,81 @@
using System;
namespace HPJ.Simulation.Map
{
public class AgentMap
{
/// <summary>
/// Base map related to this map
/// </summary>
public Map Base { get; protected set; }
/// <summary>
/// Tile that descripe the agent ownership
/// </summary>
public ushort[,] Tiles { get; protected set; }
/// <summary>
/// Initializes the agent map based on the base map
/// </summary>
/// <param name="baseMap"></param>
public AgentMap(Map baseMap)
{
Base = baseMap;
Tiles = new ushort[baseMap.Settings.MapWidth, baseMap.Settings.MapHeight];
}
/// <summary>
/// Disowns this tile so other agents can claim it or to know its availible
/// </summary>
/// <param name="ownedTile"></param>
public void DisownTile(IntVector2 ownedTile, ushort ID)
{
if (ownedTile.x < 0 || ownedTile.y < 0 || ownedTile.x >= Base.Settings.MapWidth || ownedTile.y >= Base.Settings.MapHeight)
{
return;
}
if (Tiles[ownedTile.x, ownedTile.y] == ID)
{
Tiles[ownedTile.x, ownedTile.y] = 0;
}
}
/// <summary>
/// Attempts to claim a tile for a specified ID
/// </summary>
/// <param name="newTilePosition"></param>
/// <param name="ID"></param>
/// <returns></returns>
public bool ClaimTile(IntVector2 newTilePosition, ushort ID)
{
if (newTilePosition.x < 0 || newTilePosition.y < 0 || newTilePosition.x >= Base.Settings.MapWidth || newTilePosition.y >= Base.Settings.MapHeight)
{
return false;
}
if (Tiles[newTilePosition.x, newTilePosition.y] == 0)
{
Tiles[newTilePosition.x, newTilePosition.y] = ID;
return true;
}
return false;
}
internal bool IsBlocked(int x, int y, ushort CompareID)
{
return Tiles[x, y] != 0 && Tiles[x, y] != CompareID;
}
public bool ValidTileForAgent(ushort simNavigationAgentID, int x, int y)
{
if (Tiles[x, y] == 0 || Tiles[x, y] == simNavigationAgentID)
{
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d12e6518def9eb4698b61dd77af94a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,129 @@
using HPJ.Simulation.Enums;
using HPJ.Simulation.Utilities;
using System.Linq;
namespace HPJ.Simulation.Map
{
/// <summary>
/// A Flattenned version of a map that changes every tile type into a 1 or 0. Is it traverable or is it not
/// </summary>
[System.Serializable]
public class BytePointMap
{
private byte[,] _tiles;
/// <summary>
/// The Tiles for the Byte Map
/// </summary>
public byte[,] Tiles { get { return _tiles; } }
private int _width;
/// <summary>
/// The Width of the Byte Map
/// </summary>
public int Width { get { return _width; } }
private int _length;
/// <summary>
/// The Length of the Byte Map
/// </summary>
public int Length { get { return _length; } }
private bool _cornerCutting;
/// <summary>
/// Whether corner cuttins is enabled on this map
/// </summary>
public bool CornerCutting { get { return _cornerCutting; } set { _cornerCutting = value; } }
private string _traversableKey;
/// <summary>
/// The Key used to flatten the map
/// </summary>
public string TraversableKey { get { return _traversableKey; } }
private TileTypes[] _traversable;
/// <summary>
/// The Tiles that are traversable on this map
/// </summary>
public TileTypes[] Traversable { get { return _traversable; } }
public BytePointMap(byte[,] TileTypeMap, TileTypes[] TraversableTiles, int TileMapWidth, int TileMapLength, bool CornerCuttingEnabled)
{
_traversable = TraversableTiles;
_traversableKey = TraversableTiles.TilesToString();
_cornerCutting = CornerCuttingEnabled;
_tiles = new byte[TileMapWidth, TileMapLength];
_width = TileMapWidth;
_length = TileMapLength;
for (int x = 0; x < TileMapWidth; x++)
{
for (int y = 0; y < TileMapLength; y++)
{
if (_traversable.Contains((TileTypes)TileTypeMap[x, y]))
{
_tiles[x, y] = 100;
}
else
{
_tiles[x, y] = 0;
}
}
}
}
/// <summary>
/// Changes the tile of the byte map
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="newType"></param>
public void ChangeTile(int x, int y, TileTypes newType)
{
if (_traversable.Contains(newType))
{
_tiles[x, y] = 100;
}
else
{
_tiles[x, y] = 0;
}
}
/// <summary>
/// Changes the tile of the byte map
/// </summary>
/// <param name="TileIndex"></param>
/// <param name="newType"></param>
public void ChangeTile(IntVector2 TileIndex, TileTypes newType)
{
if (_traversable.Contains(newType))
{
_tiles[TileIndex.x, TileIndex.y] = 100;
}
else
{
_tiles[TileIndex.x, TileIndex.y] = 0;
}
}
/// <summary>
/// Gets the speed of the tile
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public byte GetTileSpeed(int x, int y)
{
if (x < 0 || x >= _width)
{
return 0;
}
if (y < 0 || y >= _length)
{
return 0;
}
return _tiles[x, y];
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a78ad3bb786105e4498376a108278248
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using HPJ.Simulation.Enums;
using System.Collections;
using System.Collections.Generic;
namespace HPJ.Simulation.Map
{
[System.Serializable]
public class ChangeMapJob
{
public List<(IntVector2, TileTypes)> TilesToBeChanged;
public ChangeMapJob(List<(IntVector2, TileTypes)> TilesChanged)
{
TilesToBeChanged = TilesChanged;
}
public ChangeMapJob()
{
TilesToBeChanged = new List<(IntVector2, TileTypes)>();
}
public void AddTileChange(IntVector2 TileIndex, TileTypes TypeChange)
{
TilesToBeChanged.Add((TileIndex, TypeChange));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4dee08e2c91f0874cb9ddeb7d3b8261f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76e9eb321b9adff43b8e51b251db8e1d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9694e0d5a80a3c4eb0b89141c221aff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
namespace HPJ.Simulation
{
public struct TileOwnershipClaim
{
public ushort OwnerID;
public IntVector2 RequestTile;
public TileOwnershipClaim(ushort ID, IntVector2 Tile)
{
OwnerID = ID;
RequestTile = Tile;
}
}
public struct DisownTileOwnership
{
public ushort OwnerID;
public IntVector2 RequestTile;
public DisownTileOwnership(ushort ID, IntVector2 Tile)
{
OwnerID = ID;
RequestTile = Tile;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6db62976e6c7e20499490631bbbc2382
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: