using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
+
using HarmonyLib;
+
using Vintagestory.API.Client;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
KeepTrackOfMerchant
);
+ public static BlockDesignator Wildbeehives =
+ new BlockDesignator(
+ new AssetLocation("game", "wildbeehive"),
+ Color.Honeydew,
+ EnumBlockMaterial.Other,
+ NoteWildbeehive,
+ false
+ );
+
+ public static BlockDesignator PineResinLeaks =
+ new BlockDesignator(
+ new AssetLocation("game", "log-resin"),
+ Color.DarkOrange,
+ EnumBlockMaterial.Wood,
+ NotePineResinLeak,
+ false
+ );
+
+
+
/// <summary>
/// Not just blocks, but block-entities as well!
/// </summary>
DefaultDesignators.PostSigns,
DefaultDesignators.Translocators,
DefaultDesignators.Teleporters,
+ DefaultDesignators.Wildbeehives,
+ DefaultDesignators.PineResinLeaks,
};
}
}
}
}
+ internal static Encoding SaferUnicodeEncoding = Encoding.GetEncoding(Encoding.UTF8.WebName,
+ new EncoderReplacementFallback(@" "),
+ new DecoderReplacementFallback(@" "));
+
#endregion
internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
{
-#if DEBUG
+ #if DEBUG
clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
-#endif
+ #endif
//sign Text into a POI field...
BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
if (signEntity != null && !String.IsNullOrEmpty(signEntity.text)) {
+ var textTemp = SaferUnicodeEncoding.GetBytes(signEntity.text);
+
poi.AddReplace(
new PointOfInterest {
Name = "Sign",
PrettyLocation = posn.PrettyCoords(clientAPI),
Location = posn.Copy( ),
- Notes = signEntity.text,
+ Notes = SaferUnicodeEncoding.GetString(textTemp).Normalize(),
Timestamp = DateTime.UtcNow,
}
);
if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0) {
+ var textTemp = SaferUnicodeEncoding.GetBytes(string.Join(",", signEntity.textByCardinalDirection));
+
poi.AddReplace(
new PointOfInterest {
Name = "Signpost",
PrettyLocation = posn.PrettyCoords(clientAPI),
Location = posn.Copy( ),
- Notes = string.Join(",", signEntity.textByCardinalDirection),
+ Notes = SaferUnicodeEncoding.GetString(textTemp).Normalize(),
Timestamp = DateTime.UtcNow,
}
);
internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
{
-#if DEBUG
+ #if DEBUG
clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!");
-#endif
+ #endif
//Where to? and from!
BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator;
if (te != null) {
//FIXME: Delayed rescan ?
StringBuilder textTarget = new StringBuilder( );
- //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
+
textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
- textTarget.Append(te.Activated ? "Online, " : "Offline, ");
+ textTarget.Append(te.Activated ? "Online, " : "Offline, ");//Property hardcoded TRUE ?!
textTarget.Append(" Target: [ ");
textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
}
}
+ internal static void NoteWildbeehive(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
+ {
+ #if DEBUG
+ clientAPI.Logger.VerboseDebug("Wild bee hive Designator Invoked!");
+ #endif
+
+ BlockEntityBeehive bees = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityBeehive;
+
+ if (bees != null) {
+ EnumHivePopSize hiveSize = AccessTools.FieldRefAccess<BlockEntityBeehive, EnumHivePopSize>(bees, @"hivePopSize");
+
+ StringBuilder textTarget = new StringBuilder( );
+ textTarget.AppendLine($" Population: {(hiveSize != null? hiveSize.ToString() : "?")} ");
+
+ poi.AddReplace(
+ new PointOfInterest {
+ Name = "Wildbeehive",
+ PrettyLocation = posn.PrettyCoords(clientAPI),
+ Location = posn.Copy( ),
+ Notes = textTarget.ToString( ),
+ Timestamp = DateTime.UtcNow,
+ }
+ );
+ }
+ }
+
+ internal static void NotePineResinLeak(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
+ {
+ #if DEBUG
+ clientAPI.Logger.VerboseDebug("Resin leaking Pine tree Designator Invoked!");
+ #endif
+ //Note:Due to how Block-Entities are handled...only Harvested resin is tracked....
+ poi.AddReplace(
+ new PointOfInterest {
+ Name = "PineResin",
+ PrettyLocation = posn.PrettyCoords(clientAPI),
+ Location = posn.Copy( ),
+ Notes = String.Empty,
+ Timestamp = DateTime.UtcNow,
+ }
+ );
+ }
+
#endregion
}
}