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); } }
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); } }