OSDN Git Service

d22f32891e8d58049fe178f49c113226000190e9
[automap/automap.git] / Automap / Data / EntitiesOfInterest.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.IO;
5 using System.Linq;
6
7 using Vintagestory.API.Common.Entities;
8 using Vintagestory.API.MathTools;
9 using Vintagestory.API.Client;
10
11 using ProtoBuf;
12
13 using Newtonsoft.Json;
14
15 namespace Automap
16 {
17         /// <summary>
18         /// Basically the same as a POI but for an entity
19         /// </summary>
20         [ProtoContract]
21         public struct EntityOfInterest
22         {
23
24                 [DisplayName(0, "Name")]
25                 [ProtoMember(1)]
26                 public string Name;
27                 
28                 [DisplayName(2, "Notes")]
29                 [ProtoMember(2)]
30                 public string Notes;
31
32                 [DisplayName(1, "Loc.")]
33                 public string PrettyLocation;
34
35                 [ProtoMember(3)]
36                 public BlockPos Location;
37
38                 [DisplayName(3, "Time")]
39                 [ProtoMember(4)]
40                 public DateTime Timestamp;
41
42                 [DisplayName(4, "ID")]
43                 [ProtoMember(5)]
44                 public long EntityId;
45
46
47         }
48
49         /// <summary>
50         /// Entities of interest.
51         /// </summary>
52         /// <remarks>Tracked by ID - these never leave.</remarks>
53         public class EntitiesOfInterest : KeyedCollection<long, EntityOfInterest>
54         {
55                 protected override long GetKeyForItem(EntityOfInterest item)
56                         => item.EntityId;
57
58                 internal void AddReplace(EntityOfInterest entity)
59                 {
60                         if (Contains(entity.EntityId))
61                                 Remove(entity.EntityId);
62
63                         Add(entity);
64                 }
65
66         }
67 }
68