Skip to content

Commit

Permalink
Get loading to work mostly properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ender-titan1 committed Sep 29, 2023
1 parent e391456 commit 42ad335
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/microbe_stage/MapElementVisibility.cs
Expand Up @@ -6,15 +6,15 @@ public enum MapElementVisibility
/// <summary>
/// Invisible to the player
/// </summary>
Undiscovered,
Undiscovered = 0,

/// <summary>
/// Visible to the player but details hidden
/// </summary>
Unexplored,
Unexplored = 1,

/// <summary>
/// Visible to the player and details shown
/// </summary>
Explored,
Explored = 2,
}
12 changes: 7 additions & 5 deletions src/microbe_stage/Patch.cs
Expand Up @@ -47,17 +47,19 @@ public Patch(LocalizedString name, int id, Biome biomeTemplate, BiomeType biomeT
}

public Patch(LocalizedString name, int id, Biome biomeTemplate, BiomeType biomeType, PatchSnapshot currentSnapshot)
: this(name, id, biomeTemplate, currentSnapshot)
: this(name, id, biomeTemplate, MapElementVisibility.Explored, currentSnapshot)
{
BiomeType = biomeType;
}

[JsonConstructor]
public Patch(LocalizedString name, int id, Biome biomeTemplate, PatchSnapshot currentSnapshot)
public Patch(LocalizedString name, int id, Biome biomeTemplate, MapElementVisibility visibilityState, PatchSnapshot currentSnapshot)
{
Name = name;
ID = id;
BiomeTemplate = biomeTemplate;
VisibilityState = visibilityState;
GD.Print(VisibilityState);
this.currentSnapshot = currentSnapshot;

sunlight = SimulationParameters.Instance.GetCompound("sunlight");
Expand All @@ -75,6 +77,9 @@ public Patch(LocalizedString name, int id, Biome biomeTemplate, PatchSnapshot cu
[JsonProperty]
public LocalizedString Name { get; private set; }

[JsonProperty]
public MapElementVisibility VisibilityState { get; private set; }

/// <summary>
/// The region this patch belongs to. This has nullability suppression here to solve the circular dependency with
/// <see cref="PatchRegion.Patches"/>
Expand Down Expand Up @@ -115,9 +120,6 @@ public bool Explored
}
}

[JsonProperty]
public MapElementVisibility VisibilityState { get; private set; }

[JsonIgnore]
public bool Discovered => VisibilityState != MapElementVisibility.Undiscovered;

Expand Down
9 changes: 5 additions & 4 deletions src/microbe_stage/PatchRegion.cs
Expand Up @@ -21,13 +21,14 @@ public PatchRegion(int id, string name, RegionType regionType, Vector2 screenCoo
}

[JsonConstructor]
public PatchRegion(int id, string name, RegionType type, Vector2 screenCoordinates,
public PatchRegion(int id, string name, RegionType type, Vector2 screenCoordinates, MapElementVisibility visibilityState,
float height, float width)
{
ID = id;
Name = name;
Type = type;
ScreenCoordinates = screenCoordinates;
VisibilityState = visibilityState;
Height = height;
Width = width;
}
Expand All @@ -40,6 +41,9 @@ public enum RegionType
Predefined = 3,
}

[JsonProperty]
public MapElementVisibility VisibilityState { get; set; }

[JsonProperty]
public RegionType Type { get; }

Expand All @@ -58,9 +62,6 @@ public enum RegionType
[JsonProperty]
public float Width { get; set; }

[JsonProperty]
public MapElementVisibility VisibilityState { get; set; }

[JsonIgnore]
public bool Explored => VisibilityState == MapElementVisibility.Explored;

Expand Down

1 comment on commit 42ad335

@hhyyrylainen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VisibilityState should be after Type property as that's the order they are in the JSON constructor.

Please sign in to comment.