(Probabyl bad for performance)
Solution using actor as tiles for fragment of infected space. Self-spreading infecting 4 tiles around itself
[Start]
1. Create Base actor (first building) - source of infection
2. Add infected tiles around base
3. Adding infection tiles add its coordinates to the list
[Infection step]
4. For each coordisnate in the list check 4 tiles around it to see if there are not infected tiles.
5. If there is not-infected tile around current coordinate create infected tile actor.
6. After checking set of coordinate rmeove it form the list
0- not infect
1 - base
2 - infected
Start:
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 0
Add infected tilesa around base
0 1 2 3 4 5
-------------
0 0 0 0 0 0 |0
0 0 2 0 0 0 |1
0 2 1 2 0 0 |2
0 0 2 0 0 0 | 3
Edge List : (2,1); (1,2); (3,2); (2,3) //List contains tiles on the edge of infeciton
[Infection step]
3 - newly infected tiles
0 1 2 3 4 5
-------------
0 0 3 0 0 0 |0
0 3 2 3 0 0 |1
3 2 1 2 3 0 |2
0 3 2 3 0 0 | 3
Create New Edge list = empty list
For coordinate #0 in Edge list
Check if 1,1 infected - no then create infected tile at position and add coordinates to New Edge list
Check if 2,0 infected - no then create infected tile at position and add coordinates to New Edge list
Check if 3,1 infected - no then create infected tile at position and add coordinates to New Edge list
Check if 2,2 infected - yes do nothing
Repeat for all elements in Edge list:
Edge list = New edge list
Edge list after first infection step: (1,1); (2;0);(3,1); (0,2); (4,2); (1,3); (4,3)
For enchanced effect change animation of tiles based tiles in neighbour hood.