JohnnyTurbo

Unity Flow Field: Cell.cs

Aug 14th, 2020
1,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Cell
  4. {
  5.     public Vector3 worldPos;
  6.     public Vector2Int gridIndex;
  7.     public byte cost;
  8.     public ushort bestCost;
  9.     public GridDirection bestDirection;
  10.  
  11.     public Cell(Vector3 _worldPos, Vector2Int _gridIndex)
  12.     {
  13.         worldPos = _worldPos;
  14.         gridIndex = _gridIndex;
  15.         cost = 1;
  16.         bestCost = ushort.MaxValue;
  17.         bestDirection = GridDirection.None;
  18.     }
  19.  
  20.     public void IncreaseCost(int amnt)
  21.     {
  22.         if (cost == byte.MaxValue) { return; }
  23.         if (amnt + cost >= 255) { cost = byte.MaxValue; }
  24.         else { cost += (byte)amnt; }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment