OSDN Git Service

Pre-RC0: added Name to POI Metadata.js, Pass 2.5
[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                 [ProtoMember(3)]
34                 public BlockPos Location;
35
36                 [DisplayName(3, "Time")]
37                 [ProtoMember(4)]
38                 public DateTime Timestamp;
39
40                 [DisplayName(4, "ID")]
41                 [ProtoMember(5)]
42                 public long EntityId;
43
44
45         }
46
47         /// <summary>
48         /// Entities of interest.
49         /// </summary>
50         /// <remarks>Tracked by ID - these never leave.</remarks>
51         public class EntitiesOfInterest : KeyedCollection<long, EntityOfInterest>
52         {
53                 protected override long GetKeyForItem(EntityOfInterest item)
54                         => item.EntityId;
55
56                 internal void AddReplace(EntityOfInterest entity)
57                 {
58                         if (Contains(entity.EntityId))
59                                 Remove(entity.EntityId);
60
61                         Add(entity);
62                 }
63
64         }
65 }
66