using System; using System.Collections.Generic; using System.Drawing; using System.Text; using Vintagestory.API.Client; using Vintagestory.API.Common; using Vintagestory.API.Common.Entities; using Vintagestory.API.MathTools; using Vintagestory.GameContent; namespace Automap { public static class DefaultDesignators { public static BlockDesignator Roads = new BlockDesignator( new AssetLocation("game", "stonepath"), Color.Yellow, EnumBlockMaterial.Gravel ); public static BlockDesignator GroundSigns = new BlockDesignator( new AssetLocation("game", "sign-ground"), Color.Teal, EnumBlockMaterial.Wood, DecodeSign ); public static BlockDesignator WallSigns = new BlockDesignator( new AssetLocation("game", "sign-wall"), Color.Teal, EnumBlockMaterial.Wood, DecodeSign ); public static BlockDesignator PostSigns = new BlockDesignator( new AssetLocation("game", "signpost"), Color.Teal, EnumBlockMaterial.Wood, DecodePostSign ); public static BlockDesignator Translocators = new BlockDesignator( new AssetLocation("game", "statictranslocator-normal"), Color.SteelBlue, EnumBlockMaterial.Metal, DecodeTranslocator ); public static EntityDesignator Traders = new EntityDesignator( new AssetLocation("game", "humanoid-trader"), Color.LightGoldenrodYellow, EnumEntityState.Active, KeepTrackOfMerchant ); /// /// Not just blocks, but block-entities as well! /// /// The block designators. public static List DefaultBlockDesignators() { return new List{ DefaultDesignators.Roads, DefaultDesignators.GroundSigns, DefaultDesignators.WallSigns, DefaultDesignators.PostSigns, DefaultDesignators.Translocators, }; } public static List DefaultEntityDesignators() { return new List{ DefaultDesignators.Traders, }; } internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block) { #if DEBUG clientAPI.Logger.VerboseDebug("Sign Designator Invoked!"); #endif //sign Text into a POI field... BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign; if (signEntity != null && !String.IsNullOrEmpty(signEntity.text)) { poi.AddReplace( new PointOfInterest { Location = posn.Copy(), Notes = signEntity.text, Timestamp = DateTimeOffset.UtcNow, } ); } } internal static void DecodePostSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block) { #if DEBUG clientAPI.Logger.VerboseDebug("Post-sign Designator Invoked!"); #endif //sign post Text into a POI field... BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost; if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0) { poi.AddReplace( new PointOfInterest { Location = posn.Copy(), Notes = string.Join(",", signEntity.textByCardinalDirection), Timestamp = DateTimeOffset.UtcNow, } ); } } internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity) { //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn); var traderJoe = entity as EntityTrader; var message = $"{entity.GetName()} Alive: {traderJoe.Alive}"; if (traderJoe.TradeProps != null) { message += $" - Gears: {traderJoe.TradeProps.Money}, "; } poi.AddReplace(new EntityOfInterest { Location = posn.Copy(), Notes = message, Timestamp = DateTimeOffset.UtcNow, EntityId = entity.EntityId }); } internal static void DecodeTranslocator(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block) { clientAPI.Logger.VerboseDebug("TRANSLOCATOR Designator Invoked!"); //Where to? and from! BlockEntityStaticTranslocator te = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntityStaticTranslocator; if (te != null) { StringBuilder textTarget = new StringBuilder(); //translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget); textTarget.Append(te.Activated ? "Online " : "offline "); textTarget.Append(" Dest.: "); textTarget.Append(te.TargetLocation != null ? te.TargetLocation.PrettyCoords(clientAPI) : "???");//Or ABS coords? poi.AddReplace( new PointOfInterest { Location = posn.Copy(), Notes = textTarget.ToString(), Timestamp = DateTimeOffset.UtcNow, } ); } } } }