OSDN Git Service

Pre-PR: Point Metadata persistence, GUI work
[automap/automap.git] / Automap / Data / EntitiesOfInterest.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4
5 using System.Linq;
6
7 using Vintagestory.API.Common.Entities;
8 using Vintagestory.API.MathTools;
9
10 using ProtoBuf;
11
12 namespace Automap
13 {
14         /// <summary>
15         /// Actual Physical Point in space - that is interesting.
16         /// </summary>
17         [ProtoContract]
18         public struct EntityOfInterest
19         {
20                 [ProtoMember(1)]
21                 public string Name;
22
23                 [ProtoMember(2)]
24                 public string Notes;
25
26                 [ProtoMember(3)]
27                 public BlockPos Location;
28
29                 [ProtoMember(4)]
30                 public DateTime Timestamp;
31
32                 [ProtoMember(5)]
33                 public long EntityId;
34         }
35
36         /// <summary>
37         /// Entities of interest.
38         /// </summary>
39         /// <remarks>Tracked by ID - these never leave.</remarks>
40         public class EntitiesOfInterest : KeyedCollection<long, EntityOfInterest>
41         {
42
43                 internal void AddReplace(EntityOfInterest entity)
44                 {
45                         if (Contains(entity.EntityId))
46                                 Remove(entity.EntityId);
47
48                         Add(entity);
49                 }
50
51                 protected override long GetKeyForItem(EntityOfInterest item)
52                         => item.EntityId;
53         }
54 }
55