Ejemplo n.º 1
0
        private void OnEntityMounted(ComputerStation computerStation, BasePlayer player)
        {
            if (computerStation.controlBookmarks.IsEmpty())
            {
                return;
            }

            var bookmarkModifications = new Dictionary <string, uint>();

            foreach (var entry in computerStation.controlBookmarks)
            {
                var bookmarkName   = entry.Key;
                var cachedEntityId = entry.Value;

                BaseEntity entityWithRCIdentifier;
                var        controllable = FindControllable(bookmarkName, cachedEntityId, out entityWithRCIdentifier);
                if (controllable == null && entityWithRCIdentifier != null)
                {
                    bookmarkModifications[bookmarkName] = entityWithRCIdentifier.net.ID;
                }
            }

            // Performing modifications outside of the above foreach to avoid InvalidOperationException errors.
            foreach (var entry in bookmarkModifications)
            {
                computerStation.controlBookmarks[entry.Key] = entry.Value;
            }
        }
Ejemplo n.º 2
0
        private void OnEntityMounted(ComputerStation computerStation, BasePlayer player)
        {
            if (!HasPermission(player))
            {
                return;
            }

            player.GetOrAddComponent <CameraMover>();
        }
Ejemplo n.º 3
0
        private void OnBookmarkControlEnd(ComputerStation station, BasePlayer player, Drone drone)
        {
            var component = drone.gameObject.GetComponent <DroneNetworkGroupUpdater>();

            if (component != null)
            {
                UnityEngine.Object.Destroy(component);
            }
        }
Ejemplo n.º 4
0
            private CCTV_RC GetControlledCctv(ComputerStation computerStation)
            {
                if (computerStation == null || computerStation.IsDestroyed)
                {
                    return(null);
                }

                return(computerStation.currentlyControllingEnt.Get(serverside: true) as CCTV_RC);
            }
Ejemplo n.º 5
0
        private void OnEntityKill(ComputerStation computerStation)
        {
            BasePlayer player = computerStation.GetMounted();

            if (player == null)
            {
                return;
            }

            UI.RemoveUI(player);
        }
Ejemplo n.º 6
0
            private void Awake()
            {
                _player = GetComponent <BasePlayer>();

                if (_player == null)
                {
                    Destroy(this);
                    return;
                }

                _computerStation = _player.GetMounted() as ComputerStation;
            }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone)
        {
            // Delay in case Drone Hover is going to keep it in the controlled state.
            NextTick(() =>
            {
                if (drone == null || drone.IsBeingControlled)
                {
                    return;
                }

                MaybeStopAnimating(drone);
            });
        }
Ejemplo n.º 9
0
        private void OnBookmarkControlStarted(ComputerStation station, BasePlayer player, string bookmarkName, Drone drone)
        {
            var searchLight = GetDroneSearchLight(drone);

            if (searchLight == null)
            {
                return;
            }

            if (permission.UserHasPermission(player.UserIDString, PermissionMoveLight))
            {
                drone.GetOrAddComponent <SearchLightUpdater>().Controller = player;
            }
        }
Ejemplo n.º 10
0
        private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone)
        {
            if (drone == null)
            {
                return;
            }

            var searchLightUpdater = drone.GetOrAddComponent <SearchLightUpdater>();

            if (searchLightUpdater != null)
            {
                UnityEngine.Object.Destroy(searchLightUpdater);
            }
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
0
        private void OnBookmarkControl(ComputerStation station, BasePlayer player, string bookmarkName, Drone drone)
        {
            // Without a delay, we can't know whether another plugin blocked the entity from being controlled.
            NextTick(() =>
            {
                if (station == null || station.currentlyControllingEnt.uid != drone.net.ID || station._mounted != player)
                {
                    return;
                }

                // Check if there's already a component for some unknown reason, just in case.
                var component = drone.gameObject.GetComponent <DroneNetworkGroupUpdater>();
                if (component == null)
                {
                    component = drone.gameObject.AddComponent <DroneNetworkGroupUpdater>();
                }

                component.Controller = player;
            });
        }
Ejemplo n.º 13
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);
                    }
                });
            });
        }
Ejemplo n.º 14
0
        private void OnEntityDismounted(ComputerStation computerStation, BasePlayer player)
        {
            player.GetComponent <CameraMover>()?.Destroy();

            UI.RemoveUI(player);
        }
Ejemplo n.º 15
0
        void AddCamera(BasePlayer basePlayer, ComputerStation station, string str)
        {
#if DEBUG
            Puts($"Trying to add camera {str}");
#endif
            uint                d = 0;
            BaseNetworkable     baseNetworkable;
            IRemoteControllable component;
            foreach (IRemoteControllable allControllable in RemoteControlEntity.allControllables)
            {
                var curr = allControllable.GetIdentifier();
                if (allControllable == null)
                {
#if DEBUG
                    Puts($"  skipping null camera {curr}");
#endif
                    continue;
                }
                if (curr != str)
                {
                    continue;
                }

                if (allControllable.GetEnt() != null)
                {
                    d = allControllable.GetEnt().net.ID;
                    baseNetworkable = BaseNetworkable.serverEntities.Find(d);

                    if (baseNetworkable == null)
                    {
#if DEBUG
                        Puts("  baseNetworkable null");
#endif
                        return;
                    }
                    component = baseNetworkable.GetComponent <IRemoteControllable>();
                    if (component == null)
                    {
#if DEBUG
                        Puts("  component null");
#endif
                        return;
                    }
                    if (str == component.GetIdentifier())
                    {
#if DEBUG
                        Puts("  adding to station...");
#endif
                        station.controlBookmarks.Add(str, d);
                    }
                    station.SendControlBookmarks(basePlayer);
                    return;
                }
                else
                {
#if DEBUG
                    Puts("Computer station added bookmark with missing ent, likely a static CCTV (wipe the server)");
#endif
                    return;
                }
            }
#if DEBUG
            Puts($"  {str} cannot be controlled.  Check power!");
#endif
        }
Ejemplo n.º 16
0
 private static Drone GetControlledDrone(ComputerStation computerStation) =>
 computerStation.currentlyControllingEnt.Get(serverside: true) as Drone;
Ejemplo n.º 17
0
 private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone)
 {
     EndLooting(player);
     UI.Destroy(player);
 }
Ejemplo n.º 18
0
 private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone)
 {
     OnDroneControlEnded(drone, player);
 }
Ejemplo n.º 19
0
 private void OnBookmarkControlEnd(ComputerStation station, BasePlayer player, CCTV_RC cctvRc)
 {
     UI.RemoveUI(player);
 }
Ejemplo n.º 20
0
 private void OnBookmarkControlStarted(ComputerStation computerStation, BasePlayer player, string bookmarkName, Drone drone)
 {
     MaybeFlipDrone(player, drone);
 }