示例#1
0
 private void OnServerInitialized()
 {
     foreach (var player in BasePlayer.activePlayerList)
     {
         TrackedPlayers.Add(player.userID, new AFKPlayer(player));
     }
     InitializeTimer();
 }
示例#2
0
        /// <summary>
        /// Handles setup of the role, including spawn location, inventory and registering event handlers.
        /// </summary>
        /// <param name="player">The <see cref="Player"/> to add the role to.</param>
        public virtual void AddRole(Player player)
        {
            Log.Debug($"{Name}: Adding role to {player.Nickname}.", CustomRoles.Instance.Config.Debug);
            if (Role != RoleType.None)
            {
                player.SetRole(Role, SpawnReason.ForceClass, true);
            }

            Timing.CallDelayed(1.5f, () =>
            {
                Vector3 pos = GetSpawnPosition();

                // If the spawn pos isn't 0,0,0, We add vector3.up * 1.5 here to ensure they do not spawn inside the ground and get stuck.
                if (pos != Vector3.zero)
                {
                    player.Position = pos + (Vector3.up * 1.5f);
                }

                if (!KeepInventoryOnSpawn)
                {
                    Log.Debug($"{Name}: Clearing {player.Nickname}'s inventory.", CustomRoles.Instance.Config.Debug);
                    player.ClearInventory();
                }

                foreach (string itemName in Inventory)
                {
                    Log.Debug($"{Name}: Adding {itemName} to inventory.", CustomRoles.Instance.Config.Debug);
                    TryAddItem(player, itemName);
                }

                Log.Debug($"{Name}: Setting health values.", CustomRoles.Instance.Config.Debug);
                player.Health    = MaxHealth;
                player.MaxHealth = MaxHealth;
            });

            Log.Debug($"{Name}: Setting player info", CustomRoles.Instance.Config.Debug);
            player.CustomInfo = $"{Name} (Custom Role)";
            foreach (CustomAbility ability in CustomAbilities)
            {
                ability.AddAbility(player);
            }
            ShowMessage(player);
            RoleAdded(player);
            TrackedPlayers.Add(player);
        }
示例#3
0
 private void OnPlayerInit(BasePlayer player) => TrackedPlayers.Add(player.userID, new AFKPlayer(player));