Skip to content

Commit

Permalink
Started implementing the interfaces for accessing the data structure
Browse files Browse the repository at this point in the history
This will allow the fluid sim to properly work with the data structure and allow separate systems to interact with each other via the data structure
  • Loading branch information
AIP21 committed Apr 12, 2023
1 parent ffe037b commit 88528e3
Show file tree
Hide file tree
Showing 6 changed files with 569 additions and 502 deletions.
21 changes: 0 additions & 21 deletions Assets/DataStructure/Interfaces/IAccessDataStructure.cs

This file was deleted.

27 changes: 27 additions & 0 deletions Assets/DataStructure/Interfaces/IReadDataStructure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SimDataStructure
{
/**
<summary>
For a class to be able to read the data, it needs to implement the IReadDataStructure interface.
The implementing class can read data from only ONE grid level
</summary>
*/
public interface IReadDataStructure
{
readonly int readLevel; // The grid level to receive data from
readonly List<string> readDataNames; // The names of the data to receive

/**
<summary>
Called by the data structure at the beginning of every tick to send the requested list of data to the implementing class.
It is recommended for the implementing class to cache the received list of data for use only during the tick, to avoid memory bloat, but the received data list can also be cached for data deltas, etc.
</summary>
*/
void recieveData(List<AbstractGridData> sentData);
}
}
28 changes: 28 additions & 0 deletions Assets/DataStructure/Interfaces/IWriteDataStructure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SimDataStructure
{
/**
<summary>
For a class to be able to write data to the data structure, it needs to implement the IWriteDataStructure interface.
The implementing class can write data to ONLY one grid level
</summary>
*/
public interface IWriteDataStructure
{
readonly int writeLevel; // The grid level to write data to
readonly List<string> writeDataNames; // The names of the data you are writing to the data structure

/**
<summary>
Called by the data structure at the end of every tick to write data to the data structure.
This function should return a list of the data that the implementing class wants to write to the data structure.
The returned list of data MUST be the same length as the writeDataNames list and the index of each item in the returned list MUST correspond to its respective index in the writeDataNames list.
</summary>
*/
List<AbstractGridData> writeData();
}
}
31 changes: 31 additions & 0 deletions Assets/Managers/SystemsManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Managers {
public class SystemsManager : MonoBehaviour {
public static SystemsManager Instance { get; private set; }

public List<ITickableSystem> tickableSystems = new List<ITickableSystem>();

public void Awake() {
Instance = this;
}

public void FixedUpdate() {
// Tick all manager systems
for (int i = 0; i < tickableSystems.Count; i++) {
tickableSystems[i].BeginTick();
}

for (int i = 0; i < tickableSystems.Count; i++) {
tickableSystems[i].Tick();
}

for (int i = 0; i < tickableSystems.Count; i++) {
tickableSystems[i].EndTick();
}
}
}
}
Loading

0 comments on commit 88528e3

Please sign in to comment.