示例#1
0
        public override void OnMapOpenedClient()
        {
            int size = (int)GuiElement.scaled(32);

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

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

            if (otherTexture == null)
            {
                ImageSurface surface = new ImageSurface(Format.Argb32, size, size);
                Context      ctx     = new Context(surface);
                ctx.SetSourceRGBA(0, 0, 0, 0);
                ctx.Paint();
                capi.Gui.Icons.DrawMapPlayer(ctx, 0, 0, size, size, 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), size / 2, size / 2);
                ctx.Dispose();
                surface.Dispose();
            }



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

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


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

                if (capi.World.Config.GetBool("mapHideOtherPlayers", false) && player.PlayerUID != capi.World.Player.PlayerUID)
                {
                    continue;
                }


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

                MapComps[player] = cmp;
            }
        }
        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);
            }
        }
示例#3
0
 private void Event_PlayerSpawn(IClientPlayer byPlayer)
 {
     if (mapSink.IsOpened && !MapComps.ContainsKey(byPlayer))
     {
         EntityMapComponent cmp = new EntityMapComponent(capi, otherTexture, byPlayer.Entity);
         MapComps[byPlayer] = cmp;
         mapSink.AddMapData(cmp);
     }
 }
示例#4
0
        private void Event_PlayerDespawn(IClientPlayer byPlayer)
        {
            EntityMapComponent mp = null;

            if (MapComps.TryGetValue(byPlayer, out mp))
            {
                mp.Dispose();
                MapComps.Remove(byPlayer);
            }
        }
示例#5
0
        private void Event_PlayerSpawn(IClientPlayer byPlayer)
        {
            if (capi.World.Config.GetBool("mapHideOtherPlayers", false) && byPlayer.PlayerUID != capi.World.Player.PlayerUID)
            {
                return;
            }

            if (mapSink.IsOpened && !MapComps.ContainsKey(byPlayer))
            {
                EntityMapComponent cmp = new EntityMapComponent(capi, otherTexture, byPlayer.Entity);
                MapComps[byPlayer] = cmp;
            }
        }
示例#6
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);
            }
        }