Ejemplo n.º 1
0
 object CanNetworkTo(BaseNetworkable entity, BasePlayer player)
 {
     if (entity.GetType() == typeof(BasePlayer)) //Trying to network one player to another player
     {
         BasePlayer targetPlayer = (BasePlayer)entity;
         if (customData.ContainsKey(targetPlayer.userID))
         {
             PlayerCulling culling = customData[player.userID].playerCull;
             //Write(string.Format("testing ShouldNetwork: {1} --> {0} : {2}", player.displayName, targetPlayer.displayName, culling.ShouldShow(targetPlayer).ToString()));
             return(true);
             //return culling.ShouldShow(targetPlayer);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
    public void Update()
    {
        if (player == null)
        {
            JakePlugin.Write("PlayerNull, returning");
            return;
        }

        //JakePlugin.Write(player.displayName, ", items in group:", groupPlayerList.Count);
        //JakePlugin.Write(player.userID, ", players to check:", playersToCheck.Count);

        /*
         * for (int i = 0; i < groupPlayerList.Count; i++)
         * {*/
        for (int i = 0; i < JakePlugin.fakePlayers.Count; i++)
        {
            //PlayerCulling targetPlayerCulling = JakePlugin.customData[groupPlayerList[i].userid].playerCull;
            PlayerCulling targetPlayerCulling = JakePlugin.customData[JakePlugin.fakePlayers[i].userID].playerCull;
            BasePlayer    playerToCheck       = targetPlayerCulling.player;
            if (playerToCheck == player)
            {
                continue;
            }
            if (JakePlugin.customData.ContainsKey(playerToCheck.userID))
            {
                if (targetPlayerCulling.playersToCheck.Contains(player))
                {
                    if (playersToCheck.Contains(playerToCheck))
                    {
                        playersToCheck.Remove(playerToCheck);
                        //JakePlugin.Write("ERROR: Players set to check eachother");
                    }
                    continue;
                }
                else
                {
                    playersToCheck.Add(playerToCheck);
                }

                if (!nextTimeToCheck.ContainsKey(playerToCheck))
                {
                    nextTimeToCheck.Add(playerToCheck, Time.realtimeSinceStartup + PlayerCulling.timeStep);
                }

                if (nextTimeToCheck[playerToCheck] >= Time.realtimeSinceStartup)
                {
                    continue;
                }

                //JakePlugin.Write(string.Format("{0}: Players to check: {1}", player.displayName, playersToCheck.Count));

                targetPlayerCulling.playersToCheck.Add(player);
                float num        = Vector3.Distance(player.eyes.position, playerToCheck.transform.position);
                bool  shouldShow = false;
                if (playerToCheck.IsSleeping() && num > PlayerCulling.maxSleeperDist)
                {
                    JakePlugin.Write("Player sleeping: won't show");
                    shouldShow = false;
                }
                else if (num > PlayerCulling.maxPlayerDist)
                {
                    JakePlugin.Write("Player above max distance: won't show");
                    shouldShow = false;
                }
                else if (num <= PlayerCulling.minCullDist)
                {
                    JakePlugin.Write(playerToCheck.displayName, player.displayName);
                    JakePlugin.Write("Player below min distance: will show");
                    shouldShow = true;
                }
                else if (IsAimingAt(player, playerToCheck, 0.99f))
                {
                    shouldShow = true;
                }
                else if (IsAimingAt(playerToCheck, player, 0.99f))
                {
                    shouldShow = true;
                }
                else
                {
                    Vector3 normalized = (player.eyes.position - player.eyes.position).normalized;
                    float   num2       = Vector3.Dot(player.eyes.HeadForward(), normalized);
                    shouldShow = (num2 >= 0f && AnyPartVisible(player, playerToCheck));
                    //JakePlugin.Write("Playercull Update:", shouldShow);
                }
                PlayerCulling targetCulling = JakePlugin.customData[playerToCheck.userID].playerCull;
                if (shouldShow)
                {
                    nextTimeToCheck[playerToCheck] = Time.realtimeSinceStartup + PlayerCulling.timeVisableAfterSeen;
                    targetCulling.visiblePlayerList.Add(player);
                    visiblePlayerList.Add(playerToCheck);
                }
                else
                {
                    if (playerToCheck.IsSleeping())
                    {
                        nextTimeToCheck[playerToCheck] = Time.realtimeSinceStartup + PlayerCulling.timeToUpdateSleepers;
                    }
                    targetCulling.visiblePlayerList.Remove(player);
                    visiblePlayerList.Remove(playerToCheck);
                }
            }
        }
    }
Ejemplo n.º 3
0
 public CustomPlayerData(BasePlayer player)
 {
     tickData   = new TickData(player);
     playerCull = new PlayerCulling(player);
 }