OSDN Git Service

indentation
[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
9 namespace Automap
10 {
11     /// <summary>
12     /// Entities of interest.
13     /// </summary>
14     /// <remarks>Tracked by ID - these never leave.</remarks>
15     public class EntitiesOfInterest
16     {
17         private Dictionary<long, PointOfInterest> entitySet = new Dictionary<long, PointOfInterest>(50);
18
19
20         internal void Upsert(Entity something, string message = @"")
21         {
22             if (entitySet.ContainsKey(something.EntityId))
23             {
24                 var movingPOI = entitySet[something.EntityId];
25                 movingPOI.Location = something.Pos.AsBlockPos.Copy();
26                 movingPOI.Timestamp = DateTimeOffset.UtcNow;
27             }
28             else
29             {
30                 PointOfInterest newPOI = new PointOfInterest();
31                 newPOI.EntityId = something.EntityId;
32                 newPOI.Location = something.Pos.AsBlockPos.Copy();
33                 newPOI.Timestamp = DateTimeOffset.UtcNow;
34                 newPOI.Notes = message;
35                 entitySet.Add(something.EntityId, newPOI);
36             }
37
38         }
39
40
41         public List<PointOfInterest> PointsList
42         {
43             get
44             {
45                 return entitySet.Values.ToList();
46             }
47         }
48
49     }
50 }
51