OSDN Git Service

Pre-PR: Point Metadata persistence, GUI work
[automap/automap.git] / Automap / Data / PointOfInterest.cs
1 using System;
2 using System.Collections.ObjectModel;
3
4 using Vintagestory.API.Common;
5 using Vintagestory.API.MathTools;
6
7 using ProtoBuf;
8
9 namespace Automap
10 {
11         /// <summary>
12         /// Actual Physical Point in space - that is interesting.
13         /// </summary>
14         [ProtoContract]
15         public struct PointOfInterest
16         {
17                 [ProtoMember(1)]
18                 public string Name;
19
20                 [ProtoMember(2)]
21                 public string Notes;
22
23                 [ProtoMember(3)]
24                 public BlockPos Location;
25
26                 [ProtoMember(4)]
27                 public DateTime Timestamp;
28         }
29
30         public class PointsOfInterest : KeyedCollection<BlockPos, PointOfInterest>
31         {
32                 protected override BlockPos GetKeyForItem(PointOfInterest item)
33                         => item.Location;
34
35                 internal void AddReplace(PointOfInterest poi)
36                 {
37                         if (Contains(poi.Location))
38                                 Remove(poi.Location);
39
40                         Add(poi);
41                 }
42         }
43
44 }
45