Skip to content

Commit

Permalink
Merge pull request #132 from Permafrost-Game/hotfix-zone-gameobject-s…
Browse files Browse the repository at this point in the history
…aving-fix

Fixed bug with GameObjectManager
  • Loading branch information
JR-Morgan authored Mar 3, 2020
2 parents a563ecd + 3272b8f commit bb4f1a3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions TeamProject/GlobalWarmingGame/GameObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public static string ZoneFilePath()

public static void SaveZone()
{
if (serialization)
if (!serialization)
{
zoneMap[zonePos] = gameObjects.ToList();
}
else
{
Console.WriteLine("Saving to " + ZoneFilePath());
Serializer.Serialize(ZoneFilePath(), gameObjects);
Expand All @@ -107,16 +111,25 @@ private static void SetZone(Vector2 position, List<Colonist> colonists = null)
if (colonists != null)
foreach (Colonist colonist in colonists)
Add(colonist);


if (!serialization)
{
if (zoneMap.ContainsKey(zonePos))
{
gameObjects = zoneMap[zonePos];
if (colonists != null)
foreach (Colonist colonist in colonists)
Add(colonist);
Updatables = Filter<IUpdatable>();
Drawables = Filter<IDrawable>();
Interactables = Filter<IInteractable>();
}
else
{
zoneMap.Add(zonePos, gameObjects);

ZoneGenerator.SpawnGameObjects(seed, zonePos);
zoneMap.Add(zonePos, gameObjects);

if (position == Vector2.Zero)
Add((Colonist)InteractablesFactory.MakeInteractable(Interactable.Colonist, position: ZoneMap.Size * ZoneMap.Tiles[0, 0].Size / 2));
Expand Down

0 comments on commit bb4f1a3

Please sign in to comment.