Route hull conductivity through checkpoint commits
This commit is contained in:
parent
21d2071f6e
commit
b152f7fceb
5 changed files with 76 additions and 9 deletions
|
|
@ -1442,6 +1442,30 @@ public class ActionGameManager : MonoBehaviour
|
|||
QueueRunCheckpoint("entity-shutdown-performance");
|
||||
}
|
||||
|
||||
public bool CommitHullConductivityToggle(Entity entity, int2 position, int axis)
|
||||
{
|
||||
if (entity?.HullConductivity == null ||
|
||||
position.x < 0 ||
|
||||
position.y < 0 ||
|
||||
position.x >= entity.HullConductivity.GetLength(0) ||
|
||||
position.y >= entity.HullConductivity.GetLength(1) ||
|
||||
axis < 0 ||
|
||||
axis > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var conductivity = entity.HullConductivity[position.x, position.y];
|
||||
if (axis == 0)
|
||||
conductivity.x = !conductivity.x;
|
||||
else
|
||||
conductivity.y = !conductivity.y;
|
||||
|
||||
entity.HullConductivity[position.x, position.y] = conductivity;
|
||||
QueueRunCheckpoint("hull-conductivity-toggle");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Input.Dispose();
|
||||
|
|
|
|||
|
|
@ -483,23 +483,23 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
// Debug.Log($"Clicked at pos {data.position}, normalized {point}");
|
||||
if (_displayedHullShape[int2(v.x - 1, v.y)] && point.x < ThermalToggleRegionSize)
|
||||
{
|
||||
entity.HullConductivity[v.x - 1, v.y].x = !entity.HullConductivity[v.x - 1, v.y].x;
|
||||
RefreshCells(new []{v,int2(v.x - 1, v.y)});
|
||||
if (GameManager.CommitHullConductivityToggle(entity, int2(v.x - 1, v.y), 0))
|
||||
RefreshCells(new []{v,int2(v.x - 1, v.y)});
|
||||
}
|
||||
if (_displayedHullShape[int2(v.x + 1, v.y)] && point.x > 1 - ThermalToggleRegionSize)
|
||||
{
|
||||
entity.HullConductivity[v.x, v.y].x = !entity.HullConductivity[v.x, v.y].x;
|
||||
RefreshCells(new []{v,int2(v.x + 1, v.y)});
|
||||
if (GameManager.CommitHullConductivityToggle(entity, int2(v.x, v.y), 0))
|
||||
RefreshCells(new []{v,int2(v.x + 1, v.y)});
|
||||
}
|
||||
if (_displayedHullShape[int2(v.x, v.y - 1)] && point.y < ThermalToggleRegionSize)
|
||||
{
|
||||
entity.HullConductivity[v.x, v.y - 1].y = !entity.HullConductivity[v.x, v.y - 1].y;
|
||||
RefreshCells(new []{v,int2(v.x, v.y - 1)});
|
||||
if (GameManager.CommitHullConductivityToggle(entity, int2(v.x, v.y - 1), 1))
|
||||
RefreshCells(new []{v,int2(v.x, v.y - 1)});
|
||||
}
|
||||
if (_displayedHullShape[int2(v.x, v.y + 1)] && point.y > 1 - ThermalToggleRegionSize)
|
||||
{
|
||||
entity.HullConductivity[v.x, v.y].y = !entity.HullConductivity[v.x, v.y].y;
|
||||
RefreshCells(new []{v,int2(v.x, v.y + 1)});
|
||||
if (GameManager.CommitHullConductivityToggle(entity, int2(v.x, v.y), 1))
|
||||
RefreshCells(new []{v,int2(v.x, v.y + 1)});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue