Пример #1
0
        public override void OnMapOpenedClient()
        {
            int chunksize = api.World.BlockAccessor.ChunkSize;

            if (ownTexture == null)
            {
                ImageSurface surface = new ImageSurface(Format.Argb32, 32, 32);
                Context      ctx     = new Context(surface);
                ctx.SetSourceRGBA(0, 0, 0, 0);
                ctx.Paint();
                capi.Gui.Icons.DrawMapPlayer(ctx, 0, 0, 32, 32, new double[] { 0, 0, 0, 1 }, new double[] { 1, 1, 1, 1 });

                ownTexture = new LoadedTexture(capi, capi.Gui.LoadCairoTexture(surface, false), 16, 16);
                ctx.Dispose();
                surface.Dispose();
            }

            if (otherTexture == null)
            {
                ImageSurface surface = new ImageSurface(Format.Argb32, 32, 32);
                Context      ctx     = new Context(surface);
                ctx.SetSourceRGBA(0, 0, 0, 0);
                ctx.Paint();
                capi.Gui.Icons.DrawMapPlayer(ctx, 0, 0, 32, 32, new double[] { 0.3, 0.3, 0.3, 1 }, new double[] { 0.7, 0.7, 0.7, 1 });
                otherTexture = new LoadedTexture(capi, capi.Gui.LoadCairoTexture(surface, false), 16, 16);
                ctx.Dispose();
                surface.Dispose();
            }



            foreach (IPlayer player in capi.World.AllOnlinePlayers)
            {
                EntityMapComponent cmp = null;

                if (MapComps.TryGetValue(player, out cmp))
                {
                    cmp?.Dispose();
                    MapComps.Remove(player);
                }

                if (cmp != null)
                {
                    mapSink.RemoveMapData(cmp);
                }


                if (player.Entity == null)
                {
                    capi.World.Logger.Warning("Can't add player {0} to world map, missing entity :<", player.PlayerUID);
                    continue;
                }

                cmp = new EntityMapComponent(capi, player == capi.World.Player ? ownTexture : otherTexture, player.Entity);

                MapComps[player] = cmp;
                mapSink.AddMapData(cmp);
            }
        }
Пример #2
0
        private void Event_PlayerDespawn(IClientPlayer byPlayer)
        {
            EntityMapComponent mp = null;

            if (MapComps.TryGetValue(byPlayer, out mp))
            {
                mp.Dispose();
                MapComps.Remove(byPlayer);
            }
        }
Пример #3
0
        private void Event_PlayerDespawn(IClientPlayer byPlayer)
        {
            EntityMapComponent mp = null;

            if (MapComps.TryGetValue(byPlayer, out mp))
            {
                if (mapSink.IsOpened)
                {
                    mapSink.RemoveMapData(mp);
                }
                mp.Dispose();
                MapComps.Remove(byPlayer);
            }
        }