Esempio n. 1
0
        /// <summary>
        /// Changes the map this player is on to another map
        /// </summary>
        /// <param name="map">The map to send this player to.</param>
        public void ChangeMap(HcMap map)
        {
            // -- Annouce
            Chat.SendGlobalChat($"§SPlayer {Name} changed to map '{map.MapProvider.MapName}'", 0); // -- TODO: Move this into an event handler.
            DespawnEntities();

            // -- Cleanup events
            CurrentMap.BlockChanged -= MapBlockChange;
            CurrentMap.MapChatSent  -= MapChatReceived;

            // -- Remove this entity from all other clients on that map
            Entity.Despawn();

            // -- Send the new map
            CurrentMap = map;

            _client.SendHandshake(CurrentRank.ClientOp);
            MapSend(CurrentMap.GetChunks());
            CurrentMap.BlockChanged += MapBlockChange; // -- sub to block changes
            CurrentMap.MapChatSent  += MapChatReceived;

            // -- setup our entity
            Entity.CurrentMap = map;
            Entity.Location   = CurrentMap.GetSpawn();
            Entity.ClientId   = (sbyte)CurrentMap.GetEntityId();
            Entity.Spawn(); // -- spawn us for other people


            lock (Entity.AllEntities) { // -- Spawn all other entities on this client.
                foreach (Entity e in Entity.AllEntities)
                {
                    if (e.CurrentMap != CurrentMap || e.Name == Name)
                    {
                        continue;
                    }

                    SpawnEntity(e);
                }
            }

            Entity.HandleMove(); // -- make sure initial position is set.
        }
Esempio n. 2
0
 public Physics(int mapSize, HcMap map)
 {
     _physicsBitmask = new byte[(mapSize / 8) + 1];
     _Map            = map;
 }