/// <summary> /// Copies 1 or more files from the connected mobile device to a folder on the desktop. /// </summary> /// <param name="rapi"></param> /// <param name="srcFile"></param> /// <param name="destFile"></param> /// <returns></returns> public static bool CopyFilesFromDevice(RAPI rapi, string srcPath, string fileFilter, string destPath) { string srcFile = ""; try { srcPath = Tools.EnsureFullPath(srcPath); destPath = Tools.EnsureFullPath(destPath); FileList filesToCopy = GetFolderContents(rapi, srcPath, fileFilter); if (filesToCopy != null) { foreach (FileInformation fileInfo in filesToCopy) { srcFile = fileInfo.FileName; string destFile = destPath + srcFile; srcFile = srcPath + srcFile; CopyFileFromDevice(rapi, srcFile, destFile); } } } catch (Exception e) { Debug.WriteLine("Couldn't copy mobile file: " + srcFile); Debug.WriteLine("Error Message: " + e.Message); return(false); } return(true); }
public string GetHelpMessage(TgMessage RawMessage, string MessageType) { string finalHelpMsg; string groupHelp = "/soamenable - 启用一个功能\n" + "/soamdisable - 禁用一个功能\n" + "/soamstatus - 查看当前群组开启了的功能\n" + "/bkick - 将一个已在封禁列表中的用户从群组中移除出去"; string privateHelp = ""; string sharedHelp = "/banstat - 看看自己有没有被 Ban"; switch (MessageType) { case "group": case "supergroup": finalHelpMsg = groupHelp + "\n" + sharedHelp; break; case "private": finalHelpMsg = privateHelp + "\n" + sharedHelp; break; default: finalHelpMsg = sharedHelp; break; } if (RAPI.getIsBotAdmin(RawMessage.from.id)) { finalHelpMsg += "\n管理员指令: /ban /unban /getspamstr /addspamstr /delspamstr /getspampoints"; } return(finalHelpMsg); }
/// <summary> /// Every mobile device has 1 or more places where data & programs can be stored. At the very least this includes /// main memory, but it can potentially have 1 or more removable storage cards and 1 or more built-in storage areas. /// This method examines the device to see what's currently available. /// </summary> /// <param name="rapi"></param> /// <param name="forDisplay"></param> // This parameter simply determines how Main Memory will be stored in the return arraylist /// <returns>An array of the storage locations available.</returns> public static ArrayList GetStorageLocations(RAPI rapi, bool forDisplay) { // This procedure utilizes the fact that the RAPIFileAttributes enum contains these values: // 16 - Directory // 256 - Temporary const int tempDir = 272; ArrayList locationList = new ArrayList(); // Initialize the array we're going to pass back if (forDisplay) { locationList.Add("Main Memory"); } else { locationList.Add("\\"); } // Now from the root directory, see what else is present. FileList folderList = rapi.EnumFiles("\\*.*"); foreach (FileInformation folderInfo in folderList) { string folder = folderInfo.FileName; if ((folderInfo.FileAttributes & tempDir) == tempDir) // Only add those items that are both Directories { locationList.Add(folder); // and "Temporary" - ie. storage card & built-in storage. } } return(locationList); }
private IEnumerator InstantiateAssets() { while (RAPI.GetLocalPlayer() == null) { yield return(new WaitForEndOfFrame()); } var cameraPrefab = asset.LoadAsset <GameObject>("Minimap Camera"); camera = Instantiate(cameraPrefab, RAPI.GetLocalPlayer().transform).GetComponent <Camera>(); cameraPrefab.GetComponent <Camera>().targetTexture = null; CopyComponent(Camera.main.GetComponent <WaterCamera>(), camera.gameObject); CopyComponent(Camera.main.GetComponent <WaterCameraIME>(), camera.gameObject); camera.gameObject.AddComponent <MinimapCameraMover>(); var canvasPrefab = asset.LoadAsset <GameObject>("_MinimapCanvas"); canvas = Instantiate(canvasPrefab, GameObject.Find("Canvases").transform); traverse = Traverse.Create(GameObject.Find("_CanvasGame_New").GetComponent <CanvasHelper>()).Field <Canvas[]>("canvases"); canvases = traverse.Value; if (originalSize == -1) { originalSize = canvases.Length; } Array.Resize(ref canvases, originalSize + 1); canvases[canvases.Length - 1] = canvas.GetComponent <Canvas>(); traverse.Value = canvases; zoomText = canvas.transform.FindChildRecursively("ZoomText").GetComponent <TextMeshProUGUI>(); var script = canvas.AddComponent <MinimapRotator>(); script.Camera = camera.transform; script.Compass = canvas.transform.FindChildRecursively("Compass") as RectTransform; Debug.Log("[<color=#DBBF63>Minimap</color>] has been loaded!"); }
private bool SharedCommands(TgMessage RawMessage, string JsonMessage, string Command) { switch (Command) { case "/getid": string info = "Send from:\n" + RawMessage.GetSendUser().GetUserTextInfo(); if (RawMessage.GetForwardedFromUser() != null) { info += "\n\nForwarded from (User):\n" + RawMessage.GetForwardedFromUser().GetUserTextInfo(); } if (RawMessage.GetForwardedFromChat() != null) { info += "\n\nForwarded from (Channel):\n" + RawMessage.GetForwardedFromChat().GetChatTextInfo(); } if (RawMessage.GetReplyMessage() != null) { info += "\n\nReply to: \n" + RawMessage.GetReplyMessage().GetSendUser().GetUserTextInfo(); } TgApi.getDefaultApiConnection().sendMessage(RawMessage.GetMessageChatInfo().id, info, RawMessage.message_id); return(true); case "/help": TgApi.getDefaultApiConnection().sendMessage( RawMessage.GetMessageChatInfo().id, RAPI.getHelpContent(RawMessage), RawMessage.message_id ); return(true); default: break; } return(false); }
public static void ZoomMinimapIn() { if (RAPI.IsCurrentSceneGame()) { ChangeZoom(Mathf.Max(1, Instance.camera.orthographicSize - ZoomFunction(Instance.camera.orthographicSize))); } }
public static void ZoomMinimapOut() { if (RAPI.IsCurrentSceneGame()) { ChangeZoom(Instance.camera.orthographicSize + ZoomFunction(Instance.camera.orthographicSize)); } }
public static void ZoomMinimap(string[] args) { if (RAPI.IsCurrentSceneGame()) { ChangeZoom(float.Parse(args[0])); } }
internal static string getHelpMessage(List<PluginObject> plugins, TgMessage RawMessage, string MessageType) { if (RAPI.getIsDebugEnv()) Console.WriteLine("Message Caller : PluginsCaller -> getHelpMessage"); string msg = ""; foreach (PluginObject pl in plugins) { string pluginhelpmsg = null; try { pluginhelpmsg = pl.getHelpContent(RawMessage, MessageType); } catch (NotImplementedException) { } catch (Exception e) { RAPI.GetExceptionListener().OnException(e); } if (pluginhelpmsg != null || pluginhelpmsg != "") msg += "Plugin: " + pl.PluginName + "\n" + pluginhelpmsg + "\n\n"; } return msg; }
public void Update() { if (CanvasHelper.ActiveMenu != MenuType.None) { return; } var ply = RAPI.getLocalPlayer(); if (SceneManager.GetActiveScene().name != network.gameSceneName || ply == null) { return; } var localPlayerTPS = ply.currentModel.thirdPersonSettings; if (!localPlayerTPS.ThirdPersonState) { return; } localPlayerTPS.lerpCameraMovementBackSpeed = 9999; localPlayerTPS.lerpCameraMovementSpeed = 9999; localPlayerTPS.lerpCameraRotationSpeed = 9999; ThirdPerson TP = ply.gameObject.GetComponentInChildren <ThirdPerson>(); Vector3 vec = (Vector3)Traverse.Create(TP).Field("localCameraRotation").GetValue(); vec += new Vector3(Input.GetAxis("Mouse Y"), -Input.GetAxis("Mouse X"), 0f); vec += new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0f) * gameSettings.controls.MouseSensitivity; Traverse.Create(TP).Field("localCameraRotation").SetValue(vec); }
// This new version, using the revised data structure, fixed the problem with the WM5.0 devices. public static CEOSVERSIONINFO GetOSInfo(RAPI rapi) { CEOSVERSIONINFO verInfo = new CEOSVERSIONINFO(); CeGetVersionEx(ref verInfo); return(verInfo); }
private static void Postfix(Tank __instance, Network_Player player, float amount, Item_Base itemType = null) { if (__instance.GetComponent(typeof(Network_Player)) == RAPI.GetLocalPlayer()) { ComponentManager <GlassHoneyUse> .Value.OnModifyTank(player, amount, itemType); } }
private void ConnectTest_Click(object sender, EventArgs e) { try { rapi = new RAPI(); rapi.Connect(); if (rapi.DevicePresent) { MessageBox.Show("Соединение с КПК установлено"); } while (!rapi.DevicePresent) { MessageBox.Show("Пожалуйста подсоедините КПК используя ActiveSync.", "No Device Present"); rapi.Connect(); } } catch (Exception ex) { MessageBox.Show("Ошибка подключения" + " - " + ex.Message, "Connection Error"); Application.Exit(); } }
public MainForm() { InitializeComponent(); // create our global RAPI object this.rapi = new RAPI(); // wire in some ActiveSync events this.rapi.ActiveSync.Active += new ActiveHandler(ActiveSync_Active); this.rapi.ActiveSync.Disconnect += new DisconnectHandler(ActiveSync_Disconnect); this.rapi.ActiveSync.Listen += new ListenHandler(ActiveSync_Listen); this.rapi.ActiveSync.Answer += new AnswerHandler(ActiveSync_Answer); textUpdate = new EventHandler(TextMarshaler); enableUpdate = new EventHandler(EnabledMarshaler); using (UserTableAdapter symbolAdapter = new UserTableAdapter()) { using (SqlConnection connection = symbolAdapter.Connection) { if (connection.DataSource == "(local)") { this.textBoxServerName.Text = connection.WorkstationId; } else { this.textBoxServerName.Text = connection.DataSource; } } } }
private static void sprintSpeed(string[] args) { if (Raft_Network.InMenuScene) { Debug.Log(Error + "Is In Lobby"); return; } if (args.Length < 1) { Debug.Log(Error + "Unknown Speed"); return; } var value = float.Parse(args[0], CultureInfo.InvariantCulture); int Speedint = 1; if (!int.TryParse(args[0], out Speedint)) { Debug.Log(Error + "Invalid Speed"); return; } if (Speedint > 25f) { Debug.Log(Error + "Max Speed = 25"); return; } if (Speedint < 5f) { Debug.Log(Error + "Minimum Speed = 5"); return; } RAPI.GetLocalPlayer().PersonController.sprintSpeed = defaultSpeed * Speedint; }
public void Update() { if (Input.GetKeyDown(KeyCode.LeftAlt)) { Debug.Log(CanvasHelper.ActiveMenu); Debug.Log("LeftAlt pressed and menu not open"); currentPlayers.Clear(); var players = FindObjectsOfType <Network_Player>(); var localPlayer = RAPI.GetLocalPlayer(); foreach (var player in players) { if (player != localPlayer) { currentPlayers.Add(player); } } Network_Player thisPlayer = RAPI.GetLocalPlayer(); if (thisPlayer != null) { PlayerPing(thisPlayer); } } }
private static void Postfix(PlayerStats __instance, Item_Base edibleItem) { if (__instance.GetComponent(typeof(Network_Player)) == RAPI.GetLocalPlayer()) { ComponentManager <GlassHoneyUse> .Value.OnConsumeItem(edibleItem); } }
public string GetChatTextInfoMarkdown() { string ChatInfo = "ID: `" + id + "`"; ChatInfo += "\nType: `" + type + "`"; if (first_name != null) { ChatInfo += "\nFirst name: `" + RAPI.escapeMarkdown(first_name) + "`"; } if (title != null) { ChatInfo += "\nLast name: `" + RAPI.escapeMarkdown(title) + "`"; } if (title != null) { ChatInfo += "\nTitle: `" + RAPI.escapeMarkdown(title) + "`"; } if (username != null) { ChatInfo += "\nUsername : @" + RAPI.escapeMarkdown(username); } if (all_members_are_administrators) { ChatInfo += "\nAll members are admin: `true`"; } return(ChatInfo); }
private static void godmodeisreal(string[] args) { if (Raft_Network.InMenuScene) { Debug.Log(Error + "Is In Lobby"); return; } godmode = !godmode; if (godmode) { while (RAPI.GetLocalPlayer().Stats.stat_hunger.Normal.Value < 100 || RAPI.GetLocalPlayer().Stats.stat_thirst.Normal.Value < 100 || RAPI.GetLocalPlayer().Stats.stat_health.Value < 100 || RAPI.GetLocalPlayer().Stats.stat_oxygen.GetOxygenLostPerSecond() > 0f) { RAPI.GetLocalPlayer().Stats.stat_hunger.Normal.Value = 100; RAPI.GetLocalPlayer().Stats.stat_health.Value = 100; RAPI.GetLocalPlayer().Stats.stat_thirst.Normal.Value = 100; RAPI.GetLocalPlayer().Stats.stat_oxygen.Value = 100; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 0f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 0f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(0f); GameModeValueManager.GetCurrentGameModeValue().playerSpecificVariables.damageTakenMultiplier = 0f; } GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 0f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 0f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(0f); GameModeValueManager.GetCurrentGameModeValue().playerSpecificVariables.damageTakenMultiplier = 0f; } else { GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.foodDecrementRateMultiplier = 1f; GameModeValueManager.GetCurrentGameModeValue().nourishmentVariables.thirstDecrementRateMultiplier = 1f; RAPI.GetLocalPlayer().Stats.stat_oxygen.SetOxygenLostPerSecond(1f); GameModeValueManager.GetCurrentGameModeValue().playerSpecificVariables.damageTakenMultiplier = 1f; } }
public MainForm() { InitializeComponent(); string application = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; this._appDir = Path.GetDirectoryName(application) + "\\"; // create our global RAPI object this.rapi = new RAPI(); // wire in some ActiveSync events this.rapi.ActiveSync.Active += new ActiveHandler(ActiveSync_Active); this.rapi.ActiveSync.Disconnect += new DisconnectHandler(ActiveSync_Disconnect); this.rapi.ActiveSync.Listen += new ListenHandler(ActiveSync_Listen); this.rapi.ActiveSync.Answer += new AnswerHandler(ActiveSync_Answer); textUpdate = new EventHandler(TextMarshaler); enableUpdate = new EventHandler(EnabledMarshaler); using (UserTableAdapter symbolAdapter = new UserTableAdapter()) { using (SqlConnection connection = symbolAdapter.Connection) { if (connection.DataSource == "(local)") { this.textBoxServerName.Text = connection.WorkstationId; } else { this.textBoxServerName.Text = connection.DataSource; } } } }
private void Start() { newItem = ScriptableObject.CreateInstance <ModItem>().Create("WindTurbine", ItemType.Inventory); newItem.setInventorySettings("Wind Turbine", "A wind turbine which can be repurposed in several ways.", null, "Item/" + newItem.name, 5); RAPI.addItem(newItem); RConsole.Log("firstmod loaded!"); }
internal string getHelpContent(TgMessage RawMessage, string MessageType) { if (helpObjects == null) { return(""); } string helpmsg = ""; foreach (CallablePlugin plugin in helpObjects) { try { if (RAPI.getIsDebugEnv()) { Console.WriteLine("Message Caller : GetHelpMessage"); } object helpobj = plugin.callPlugin("GetHelpMessage", new object[] { RawMessage, MessageType }); if (helpobj != null) { helpmsg += (string)helpobj; } } catch (NotImplementedException) { } } return(helpmsg); }
internal bool addOP(TgMessage RawMessage) { string UID_Value = RawMessage.text.Replace("/addop", "").Replace(" ", ""); if (UID_Value.Length < 5) { TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "使用方法 : /addop UID", RawMessage.message_id); return(false); } string json = File.ReadAllText("config.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["op_list"].Add(Convert.ToInt32(UID_Value)); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText("config.json", output); TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "新增成功!", RawMessage.message_id); RAPI.reloadConfig(); return(true); }
/// <summary> /// Called when the mod is loaded. /// </summary> private void Start() { if (Get != null) { DestroyImmediate(Get); CUtil.LogW("Mod has been loaded twice. Destroying old mod instance."); } Get = this; LoadConfig(); mi_harmony = new Harmony(APP_IDENT); mi_harmony.PatchAll(Assembly.GetExecutingAssembly()); mi_settings = ComponentManager <Settings> .Value; if (RAPI.IsCurrentSceneGame()) { LoadLights(); //mod was reloaded from game } LoadLightData(); CUtil.Log("LanternShadows v. " + VERSION + " loaded."); }
bool CreateRadioItem() { if (radio != null) { return(false); } radio = ItemManager.GetItemByIndex(ITEM_ID); if (radio != null) { Error($"{ITEM_DISPLAYNAME} item already created."); return(false); } var originalRadio = ItemManager.GetItemByName("Placeable_Radio"); if (originalRadio == null) { Error("Cannot find original radio item."); return(false); } radio = Object.Instantiate(originalRadio); radio.name = ITEM_NAME; var traverse = Traverse.Create(radio); traverse.Property("UniqueName").SetValue(ITEM_NAME); traverse.Property("UniqueIndex").SetValue(ITEM_ID); traverse.Field("settings_Inventory").Property("DisplayName").SetValue(ITEM_DISPLAYNAME); traverse.Field("settings_Inventory").Property("Description").SetValue(ITEM_DESCRIPTION); RAPI.RegisterItem(radio); Info($"{ITEM_DISPLAYNAME} item created."); return(true); }
IEnumerator OnModLoad() { if (notifyLoad != null) { notifyLoad.Close(); } if (notify == null) { notify = FindObjectOfType <HNotify>(); } yield return(notifyLoad = notify.AddNotification( HNotify.NotificationType.spinning, $"Loading {MOD_NAME}")); var request = AssetBundle.LoadFromMemoryAsync( GetEmbeddedFileBytes("oldworldradio.assets")); yield return(request); assetBundle = request.assetBundle; Info($"Assets loaded to {assetBundle.name}"); var assetNames = new List <string>(assetBundle.GetAllAssetNames()); audioClips = assetNames.FindAll(a => a.EndsWith(".ogg")); player = RAPI.GetLocalPlayer(); CreateRadioItem(); CreateAudioSource(); GiveRadioToPlayer(); SetBroadcastState(true); notifyLoad.Close(); notifyLoad = null; yield return(true); }
// Note: This is called from 'DataXfer.AskToInstall' public void DisplayDeviceInfo(RAPI rapi, CEOSVERSIONINFO verInfo) { string txt; txt = verInfo.dwPlatformId.ToString(); if (txt.IndexOf("PLATFORM") != -1) { txt = txt.Substring(txt.IndexOf("PLATFORM") + 8); if (txt.IndexOf("_") != -1) { txt = txt.Substring(txt.IndexOf("_") + 1); } } labelPlatform.Text = txt; txt = verInfo.dwMajorVersion + "." + verInfo.dwMinorVersion + "." + verInfo.dwBuildNumber; labelOSVersion.Text = txt; SYSTEM_INFO sysInfo = new SYSTEM_INFO(); rapi.GetDeviceSystemInfo(out sysInfo); txt = sysInfo.dwProcessorType.ToString(); if (txt.IndexOf("PROCESSOR") != -1) { txt = txt.Substring(txt.IndexOf("PROCESSOR") + 9); if (txt.IndexOf("_") != -1) { txt = txt.Substring(txt.IndexOf("_") + 1); } } labelProcessor.Text = txt; }
public static SYSTEM_INFO GetSystemInfo(RAPI rapi) { SYSTEM_INFO sysInfo = new SYSTEM_INFO(); rapi.GetDeviceSystemInfo(out sysInfo); return(sysInfo); }
public override void WorldEvent_WorldLoaded() { base.WorldEvent_WorldLoaded(); player = RAPI.GetLocalPlayer(); CreateAudioSource(); GiveRadioToPlayer(); SetBroadcastState(true); }
public static SYSTEM_POWER_STATUS_EX GetPowerInfo(RAPI rapi) { SYSTEM_POWER_STATUS_EX status = new SYSTEM_POWER_STATUS_EX(); rapi.GetDeviceSystemPowerStatus(out status); return(status); }