コード例 #1
0
 public void GatherStaticCameras()
 {
     if (Rust.Application.isLoadingSave)
     {
         Invoke(GatherStaticCameras, 1f);
     }
     else
     {
         if (!isStatic || !(autoGatherRadius > 0f))
         {
             return;
         }
         List <BaseEntity> obj = Facepunch.Pool.GetList <BaseEntity>();
         Vis.Entities(base.transform.position, autoGatherRadius, obj, 256, QueryTriggerInteraction.Ignore);
         foreach (BaseEntity item in obj)
         {
             IRemoteControllable component = item.GetComponent <IRemoteControllable>();
             if (component != null)
             {
                 CCTV_RC component2 = item.GetComponent <CCTV_RC>();
                 if ((!component2 || component2.IsStatic()) && !controlBookmarks.ContainsKey(component.GetIdentifier()))
                 {
                     ForceAddBookmark(component.GetIdentifier());
                 }
             }
         }
         Facepunch.Pool.FreeList(ref obj);
     }
 }
コード例 #2
0
    public void ForceAddBookmark(string identifier)
    {
        if (controlBookmarks.Count >= 128 || !IsValidIdentifier(identifier))
        {
            return;
        }
        foreach (KeyValuePair <string, uint> controlBookmark in controlBookmarks)
        {
            if (controlBookmark.Key == identifier)
            {
                return;
            }
        }
        uint num  = 0u;
        bool flag = false;

        foreach (IRemoteControllable allControllable in RemoteControlEntity.allControllables)
        {
            if (allControllable != null && allControllable.GetIdentifier() == identifier)
            {
                if (!(allControllable.GetEnt() == null))
                {
                    num  = allControllable.GetEnt().net.ID;
                    flag = true;
                    break;
                }
                Debug.LogWarning("Computer station added bookmark with missing ent, likely a static CCTV (wipe the server)");
            }
        }
        if (!flag)
        {
            return;
        }
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num);

        if (baseNetworkable == null)
        {
            return;
        }
        IRemoteControllable component = baseNetworkable.GetComponent <IRemoteControllable>();

        if (component != null)
        {
            string identifier2 = component.GetIdentifier();
            if (identifier == identifier2)
            {
                controlBookmarks.Add(identifier, num);
            }
        }
    }
コード例 #3
0
    public void BeginControllingBookmark(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!IsPlayerAdmin(player))
        {
            return;
        }
        string text = msg.read.String();

        if (!IsValidIdentifier(text) || !controlBookmarks.ContainsKey(text))
        {
            return;
        }
        uint            uid             = controlBookmarks[text];
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(uid);

        if (baseNetworkable == null)
        {
            return;
        }
        IRemoteControllable component = baseNetworkable.GetComponent <IRemoteControllable>();

        if (component.CanControl() && !(component.GetIdentifier() != text) && Interface.CallHook("OnBookmarkControl", this, player, text, component) == null)
        {
            BaseEntity baseEntity = currentlyControllingEnt.Get(true);
            if ((bool)baseEntity)
            {
                IRemoteControllable component2 = baseEntity.GetComponent <IRemoteControllable>();
                component2?.StopControl();
                Interface.CallHook("OnBookmarkControlEnded", this, player, component2);
            }
            player.net.SwitchSecondaryGroup(baseNetworkable.net.group);
            currentlyControllingEnt.uid = baseNetworkable.net.ID;
            SendNetworkUpdateImmediate();
            SendControlBookmarks(player);
            component.InitializeControl(player);
            InvokeRepeating(ControlCheck, 0f, 0f);
            Interface.CallHook("OnBookmarkControlStarted", this, player, text, component);
        }
    }
コード例 #4
0
    public void ControlCheck()
    {
        bool       flag       = false;
        BaseEntity baseEntity = currentlyControllingEnt.Get(base.isServer);

        if ((bool)baseEntity)
        {
            IRemoteControllable component = baseEntity.GetComponent <IRemoteControllable>();
            if (component != null && component.CanControl())
            {
                flag = true;
                if (_mounted != null)
                {
                    _mounted.net.SwitchSecondaryGroup(baseEntity.net.group);
                }
            }
        }
        if (!flag)
        {
            StopControl(_mounted);
        }
    }
コード例 #5
0
        private void OnBookmarkControl(ComputerStation computerStation, BasePlayer player, string bookmarkName, IRemoteControllable entity)
        {
            var previousDrone = GetControlledDrone(computerStation);

            // Must delay since the drone hasn't stopped being controlled yet.
            NextTick(() =>
            {
                // Delay again in case Drone Hover is going to keep it in the controlled state.
                NextTick(() =>
                {
                    if (previousDrone != null && !previousDrone.IsBeingControlled)
                    {
                        MaybeStopAnimating(previousDrone);
                    }

                    var nextDrone = entity as Drone;
                    if (nextDrone != null)
                    {
                        StartAnimatingIfNotAlready(nextDrone);
                    }
                });
            });
        }
コード例 #6
0
    public void AddBookmark(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!IsPlayerAdmin(player) || isStatic)
        {
            return;
        }
        if (UnityEngine.Time.realtimeSinceStartup < nextAddTime)
        {
            player.ChatMessage("Slow down...");
            return;
        }
        if (controlBookmarks.Count >= 128)
        {
            player.ChatMessage("Too many bookmarks, delete some");
            return;
        }
        nextAddTime = UnityEngine.Time.realtimeSinceStartup + 1f;
        string text = msg.read.String();

        if (!IsValidIdentifier(text))
        {
            return;
        }
        foreach (KeyValuePair <string, uint> controlBookmark in controlBookmarks)
        {
            if (controlBookmark.Key == text)
            {
                return;
            }
        }
        uint num  = 0u;
        bool flag = false;

        foreach (IRemoteControllable allControllable in RemoteControlEntity.allControllables)
        {
            if (allControllable != null && allControllable.GetIdentifier() == text)
            {
                if (!(allControllable.GetEnt() == null))
                {
                    num  = allControllable.GetEnt().net.ID;
                    flag = true;
                    break;
                }
                Debug.LogWarning("Computer station added bookmark with missing ent, likely a static CCTV (wipe the server)");
            }
        }
        if (!flag)
        {
            return;
        }
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num);

        if (baseNetworkable == null)
        {
            return;
        }
        IRemoteControllable component = baseNetworkable.GetComponent <IRemoteControllable>();

        if (component != null && Interface.CallHook("OnBookmarkAdd", this, player, text) == null)
        {
            string identifier = component.GetIdentifier();
            if (text == identifier)
            {
                controlBookmarks.Add(text, num);
            }
            SendControlBookmarks(player);
        }
    }
コード例 #7
0
ファイル: MovableCCTV.cs プロジェクト: bazz3l/MovableCCTV
        private void OnBookmarkControl(ComputerStation computerStation, BasePlayer player, string bookmarkName, IRemoteControllable entity)
        {
            UI.RemoveUI(player);

            CCTV_RC cctvRc = entity as CCTV_RC;

            if (cctvRc == null || cctvRc.IsStatic())
            {
                return;
            }

            if (!HasPermission(player))
            {
                return;
            }

            UI.CreateUI(player, Lang("Description", player.UserIDString));
        }
コード例 #8
0
        private void OnBookmarkControlStarted(ComputerStation computerStation, BasePlayer player, string bookmarkName, IRemoteControllable entity)
        {
            EndLooting(player);
            UI.Destroy(player);

            var drone = entity as Drone;

            if (drone != null && GetDroneStorage(drone) != null)
            {
                UI.Create(player);
            }
        }