Ejemplo n.º 1
0
        static bool GotoLevel(Player p, Level lvl)
        {
            if (p.level == lvl)
            {
                p.Message("You are already in {0}%S.", lvl.ColoredName); return(false);
            }

            bool canJoin = lvl.CanJoin(p);

            OnJoiningLevelEvent.Call(p, lvl, ref canJoin);
            if (!canJoin)
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level prev = p.level;

            p.level = lvl;

            p.SendRawMap(prev, lvl);
            PostSentMap(p, prev, lvl, true);
            p.Loading = false;
            return(true);
        }
Ejemplo n.º 2
0
        public override void Load(bool startup)
        {
            command = new CmdCustomModel();
            Command.Register(command);

            OnPlayerConnectEvent.Register(OnPlayerConnect, Priority.Low);
            OnPlayerDisconnectEvent.Register(OnPlayerDisconnect, Priority.Low);
            OnJoiningLevelEvent.Register(OnJoiningLevel, Priority.Low);
            OnJoinedLevelEvent.Register(OnJoinedLevel, Priority.Low);
            OnSendingModelEvent.Register(OnSendingModel, Priority.Low);
            OnPlayerCommandEvent.Register(OnPlayerCommand, Priority.Low);
            // OnEntitySpawnedEvent.Register(OnEntitySpawned, Priority.Low);

            Directory.CreateDirectory(PublicModelsDirectory);
            Directory.CreateDirectory(PersonalModelsDirectory);

            int numModels         = CreateMissingCCModels(false);
            int numPersonalModels = CreateMissingCCModels(true);

            Logger.Log(
                LogType.SystemActivity,
                "CustomModels Loaded with {0} Models and {1} Personal Models",
                numModels,
                numPersonalModels
                );

            // initialize because of a late plugin load
            foreach (Player p in PlayerInfo.Online.Items)
            {
                SentCustomModels.TryAdd(p.name, new HashSet <string>(StringComparer.OrdinalIgnoreCase));
                ModelNameToIdForPlayer.TryAdd(p.name, new ConcurrentDictionary <string, byte>(StringComparer.OrdinalIgnoreCase));
            }
        }
Ejemplo n.º 3
0
        public override void Unload(bool shutdown)
        {
            SentCustomModels.Clear();
            ModelNameToIdForPlayer.Clear();

            OnPlayerConnectEvent.Unregister(OnPlayerConnect);
            OnPlayerDisconnectEvent.Unregister(OnPlayerDisconnect);
            OnJoiningLevelEvent.Unregister(OnJoiningLevel);
            OnJoinedLevelEvent.Unregister(OnJoinedLevel);
            OnSendingModelEvent.Unregister(OnSendingModel);
            OnPlayerCommandEvent.Unregister(OnPlayerCommand);
            // OnEntitySpawnedEvent.Unregister(OnEntitySpawned);

            if (command != null)
            {
                Command.Unregister(command);
                command = null;
            }
        }