OSDN Git Service

W.I.P. #5 Point of Interest designators now better
[automap/automap.git] / Automap / Designators / DefaultDesignators.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Drawing;
4
5 using Vintagestory.API.Client;
6 using Vintagestory.API.Common;
7 using Vintagestory.API.MathTools;
8 using Vintagestory.GameContent;
9
10 namespace Automap
11 {
12         public static class DefaultDesignators
13         {
14                 public static Designator Roads =
15                          new Designator(
16                                 new AssetLocation("game", "stonepath"),
17                                 Color.Yellow,
18                                 EnumBlockMaterial.Gravel
19                         );
20
21                 public static Designator GroundSigns =
22                          new Designator(
23                                 new AssetLocation("game", "sign-ground"),
24                                 Color.Teal,
25                                 EnumBlockMaterial.Wood,
26                                 DecodeSign
27                         );
28
29                 public static Designator WallSigns =
30                          new Designator(
31                                 new AssetLocation("game", "sign-wall"),
32                                 Color.Teal,
33                                 EnumBlockMaterial.Wood,
34                                 DecodeSign
35                         );
36
37                 public static Designator PostSigns =
38                          new Designator(
39                                 new AssetLocation("game", "signpost"),
40                                 Color.Teal,
41                                 EnumBlockMaterial.Wood,
42                                 DecodePostSign
43                         );
44
45                 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
46                 {
47                 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
48                 //sign Text into a POI field...
49                 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
50                 
51                 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text))
52                 {
53                 
54                 poi.AddReplace(
55                                         new PointOfInterest {
56                                                 Location = posn.Copy( ),
57                                                 Notes = signEntity.text,
58                                                 Timestamp = DateTimeOffset.UtcNow,
59                                         }
60                                         );
61                 
62                 }
63
64                 }
65
66
67                 internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
68                 {
69                 clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!");
70                 //sign post Text into a POI field...
71                 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
72
73                 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0 ) {
74
75                 poi.AddReplace(
76                                         new PointOfInterest {
77                                                 Location = posn.Copy( ),
78                                                 Notes = string.Join(",", signEntity.textByCardinalDirection),
79                                                 Timestamp = DateTimeOffset.UtcNow,
80                                         }
81                                         );
82
83                 }
84                 }
85
86
87
88         }
89 }
90