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; } }
private void OnEntityMounted(ComputerStation computerStation, BasePlayer player) { if (!HasPermission(player)) { return; } player.GetOrAddComponent <CameraMover>(); }
private void OnBookmarkControlEnd(ComputerStation station, BasePlayer player, Drone drone) { var component = drone.gameObject.GetComponent <DroneNetworkGroupUpdater>(); if (component != null) { UnityEngine.Object.Destroy(component); } }
private CCTV_RC GetControlledCctv(ComputerStation computerStation) { if (computerStation == null || computerStation.IsDestroyed) { return(null); } return(computerStation.currentlyControllingEnt.Get(serverside: true) as CCTV_RC); }
private void OnEntityKill(ComputerStation computerStation) { BasePlayer player = computerStation.GetMounted(); if (player == null) { return; } UI.RemoveUI(player); }
private void Awake() { _player = GetComponent <BasePlayer>(); if (_player == null) { Destroy(this); return; } _computerStation = _player.GetMounted() as ComputerStation; }
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); } }
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); }); }
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; } }
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); } }
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)); }
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; }); }
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); } }); }); }
private void OnEntityDismounted(ComputerStation computerStation, BasePlayer player) { player.GetComponent <CameraMover>()?.Destroy(); UI.RemoveUI(player); }
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 }
private static Drone GetControlledDrone(ComputerStation computerStation) => computerStation.currentlyControllingEnt.Get(serverside: true) as Drone;
private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone) { EndLooting(player); UI.Destroy(player); }
private void OnBookmarkControlEnded(ComputerStation station, BasePlayer player, Drone drone) { OnDroneControlEnded(drone, player); }
private void OnBookmarkControlEnd(ComputerStation station, BasePlayer player, CCTV_RC cctvRc) { UI.RemoveUI(player); }
private void OnBookmarkControlStarted(ComputerStation computerStation, BasePlayer player, string bookmarkName, Drone drone) { MaybeFlipDrone(player, drone); }