예제 #1
0
 public ProspectorOverlayLayer(ICoreAPI api, IWorldMapManager mapSink) : base(api, mapSink)
 {
     _worldMapManager = mapSink;
     _chunksize       = api.World.BlockAccessor.ChunkSize;
     _messages        = api.LoadOrCreateDataFile <ProspectorMessages>(Filename);
     _triggerword     = Lang.GetUnformatted("propick-reading-title")?.Split().FirstOrDefault();
     _cleanupRegex    = new Regex("<.*?>", RegexOptions.Compiled);
     if (api.Side == EnumAppSide.Client)
     {
         _clientApi = (ICoreClientAPI)api;
         _clientApi.Event.ChatMessage += OnChatMessage;
     }
 }
예제 #2
0
        public ProspectorOverlayLayer(ICoreAPI api, IWorldMapManager mapSink) : base(api, mapSink)
        {
            _worldMapManager = mapSink;
            _chunksize       = api.World.BlockAccessor.ChunkSize;
            _messages        = api.LoadOrCreateDataFile <ProspectorMessages>(Filename);
            _triggerwords    = LangUtils.GetAllLanguageStringsOfKey("propick-reading-title").Select(x => x.Split().FirstOrDefault()).Where(x => !string.IsNullOrEmpty(x)).ToArray();
            _cleanupRegex    = new Regex("<.*?>", RegexOptions.Compiled);

            var modSystem = this.api.ModLoader.GetModSystem <ProspectorInfoModSystem>();

            _config = modSystem.Config;

            if (api.Side == EnumAppSide.Client)
            {
                _clientApi = (ICoreClientAPI)api;
                _clientApi.Event.ChatMessage            += OnChatMessage;
                _clientApi.Event.AfterActiveSlotChanged += Event_AfterActiveSlotChanged;
                _clientApi.Event.PlayerJoin             += (p) =>
                {
                    if (p == _clientApi?.World.Player)
                    {
                        var invMan = p?.InventoryManager?.GetHotbarInventory();
                        invMan.SlotModified += Event_SlotModified;
                    }
                };
                _clientApi.Event.PlayerLeave += (p) =>
                {
                    if (p == _clientApi?.World.Player)
                    {
                        var invMan = p?.InventoryManager?.GetHotbarInventory();
                        invMan.SlotModified -= Event_SlotModified;
                    }
                };

                _clientApi.RegisterCommand("pi", "ProspectorInfo main command. Allows you to toggle the visibility of the chunk texture overlay.", "", OnPiCommand);

                _colorTexture?.Dispose();
                _colorTexture = GenerateOverlayTexture();
            }
        }