protected BaseClient([NotNull] ICommsNetworkState network) { if (network == null) { throw new ArgumentNullException("network"); } Log = Logs.Create(LogCategory.Network, GetType().Name); const int poolSize = 32; const int byteBufferSize = 1024; const int channelListSize = 8; var byteArrayPool = new ReadonlyLockedValue <Pool <byte[]> >(new Pool <byte[]>(poolSize, () => new byte[byteBufferSize])); var channelListPool = new ConcurrentPool <List <RemoteChannel> >(poolSize, () => new List <RemoteChannel>(channelListSize)); _sendQueue = new SendQueue <TPeer>(this, byteArrayPool); _serverNegotiator = new ConnectionNegotiator <TPeer>(_sendQueue, network.PlayerName, network.CodecSettings); _lossSimulator = new PacketDelaySimulator(); _events = new EventQueue(byteArrayPool, channelListPool); _peers = new SlaveClientCollection <TPeer>(_sendQueue, _serverNegotiator, _events, network.Rooms, network.PlayerName, network.CodecSettings); _peers.OnClientJoined += OnAddedClient; _peers.OnClientIntroducedP2P += OnMetClient; _voiceReceiver = new VoiceReceiver <TPeer>(_serverNegotiator, _peers, _events, network.Rooms, channelListPool); _voiceSender = new VoiceSender <TPeer>(_sendQueue, _serverNegotiator, _peers, _events, network.PlayerChannels, network.RoomChannels); _textReceiver = new TextReceiver <TPeer>(_events, network.Rooms, _peers); _textSender = new TextSender <TPeer>(_sendQueue, _serverNegotiator, _peers); }
private void RPC_SpawnPieceAndDestroy(long sender, long creatorID) { if (!m_nView.IsOwner()) { return; } GameObject actualPiece = Object.Instantiate(originalPiece.gameObject, gameObject.transform.position, gameObject.transform.rotation); // Register special effects if (creatorID == Player.m_localPlayer.GetPlayerID()) { CraftingStation craftingStation = actualPiece.GetComponentInChildren <CraftingStation>(); if (craftingStation) { Player.m_localPlayer.AddKnownStation(craftingStation); } PrivateArea privateArea = actualPiece.GetComponent <PrivateArea>(); if (privateArea) { privateArea.Setup(Game.instance.GetPlayerProfile().GetName()); } if (actualPiece.TryGetComponent(out Piece newPiece)) { newPiece.m_placeEffect.Create(actualPiece.transform.position, actualPiece.transform.rotation, actualPiece.transform, 1f); } // Count up player builds Game.instance.GetPlayerProfile().m_playerStats.m_builds++; } WearNTear wearntear = gameObject.GetComponent <WearNTear>(); if (wearntear) { wearntear.OnPlaced(); } TextReceiver textReceiver = gameObject.GetComponent <TextReceiver>(); if (textReceiver != null) { textReceiver.SetText(m_nView.GetZDO().GetString(zdoAdditionalInfo)); } actualPiece.GetComponent <Piece>().SetCreator(creatorID); #if DEBUG Jotunn.Logger.LogDebug("Plan spawn actual piece: " + actualPiece + " -> Destroying self"); #endif BlueprintManager.Instance.PlanPieceRemovedFromBlueprint(this); ZNetScene.instance.Destroy(this.gameObject); }
private static bool PlaceBlueprint(Player player, Piece piece) { Blueprint bp = Instance.m_blueprints[piece.m_name]; var transform = player.m_placementGhost.transform; var position = player.m_placementGhost.transform.position; var rotation = player.m_placementGhost.transform.rotation; bool placeDirect = ZInput.GetButton("Crouch"); if (placeDirect && !allowDirectBuildConfig.Value) { MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$msg_direct_build_disabled"); return(false); } if (ZInput.GetButton("AltPlace")) { Vector2 extent = bp.GetExtent(); FlattenTerrain.FlattenForBlueprint(transform, extent.x, extent.y, bp.m_pieceEntries); } uint cntEffects = 0u; uint maxEffects = 10u; GameObject blueprintPrefab = PrefabManager.Instance.GetPrefab(Blueprint.BlueprintPrefabName); GameObject blueprintObject = Object.Instantiate(blueprintPrefab, position, rotation); ZDO blueprintZDO = blueprintObject.GetComponent <ZNetView>().GetZDO(); blueprintZDO.Set(ZDOBlueprintName, bp.m_name); ZDOIDSet createdPlans = new ZDOIDSet(); for (int i = 0; i < bp.m_pieceEntries.Length; i++) { PieceEntry entry = bp.m_pieceEntries[i]; // Final position Vector3 entryPosition = position + transform.forward * entry.posZ + transform.right * entry.posX + new Vector3(0, entry.posY, 0); // Final rotation Quaternion entryQuat = new Quaternion(entry.rotX, entry.rotY, entry.rotZ, entry.rotW); entryQuat.eulerAngles += rotation.eulerAngles; // Get the prefab of the piece or the plan piece string prefabName = entry.name; if (!placeDirect) { prefabName += PlanPiecePrefab.PlannedSuffix; } GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if (!prefab) { Jotunn.Logger.LogWarning(entry.name + " not found, you are probably missing a dependency for blueprint " + bp.m_name + ", not placing @ " + entryPosition); continue; } // Instantiate a new object with the new prefab GameObject gameObject = Object.Instantiate(prefab, entryPosition, entryQuat); ZNetView zNetView = gameObject.GetComponent <ZNetView>(); if (!zNetView) { Jotunn.Logger.LogWarning("No ZNetView for " + gameObject + "!!??"); } else if (gameObject.TryGetComponent(out PlanPiece planPiece)) { planPiece.PartOfBlueprint(blueprintZDO.m_uid, entry); createdPlans.Add(planPiece.GetPlanPieceID()); } // Register special effects CraftingStation craftingStation = gameObject.GetComponentInChildren <CraftingStation>(); if (craftingStation) { player.AddKnownStation(craftingStation); } Piece newpiece = gameObject.GetComponent <Piece>(); if (newpiece) { newpiece.SetCreator(player.GetPlayerID()); } PrivateArea privateArea = gameObject.GetComponent <PrivateArea>(); if (privateArea) { privateArea.Setup(Game.instance.GetPlayerProfile().GetName()); } WearNTear wearntear = gameObject.GetComponent <WearNTear>(); if (wearntear) { wearntear.OnPlaced(); } TextReceiver textReceiver = gameObject.GetComponent <TextReceiver>(); if (textReceiver != null) { textReceiver.SetText(entry.additionalInfo); } // Limited build effects if (cntEffects < maxEffects) { newpiece.m_placeEffect.Create(gameObject.transform.position, rotation, gameObject.transform, 1f); player.AddNoise(50f); cntEffects++; } // Count up player builds Game.instance.GetPlayerProfile().m_playerStats.m_builds++; } blueprintZDO.Set(PlanPiece.zdoBlueprintPiece, createdPlans.ToZPackage().GetArray()); // Dont set the blueprint piece and clutter the world with it return(false); }
// Token: 0x06000644 RID: 1604 RVA: 0x0003544D File Offset: 0x0003364D public void RequestText(TextReceiver sign, string topic, int charLimit) { this.m_queuedSign = sign; this.Show(topic, sign.GetText(), charLimit); }
public override async void OnMessageReceived(RemoteMessage message) { base.OnMessageReceived(message); try { if (!message.Data.ContainsKey("Action")) { throw new InvalidOperationException(); } else if (message.Data["Action"] == "Wake") { #if DEBUG SendNotification("Wake", "Wake"); #endif var intent = new Intent(this, typeof(MessageCarrierService)); intent.PutExtra("Action", "Wake"); StartService(intent); } else if (message.Data["Action"] == "SendCarrier") { #if DEBUG SendNotification("SendCarrier", "SendCarrier"); #endif var intent = new Intent(this, typeof(MessageCarrierService)); intent.PutExtra("Action", "SendCarrier"); intent.PutExtra("DeviceId", message.Data["WakerDeviceId"]); Android.Util.Log.Debug("CARRIER_DEBUG", "1"); StartService(intent); } else if (message.Data["Action"] == "Payload") { #if DEBUG SendNotification("Payload", "Payload"); #endif var intent = new Intent(this, typeof(WaiterService)); intent.PutExtra("Data", message.Data["Data"]); StartService(intent); } else if ((message.Data["Action"] == "LaunchUrl") && (message.Data.ContainsKey("Url"))) { try { string url = message.Data["Url"]; LaunchHelper.LaunchUrl(this, url); } catch (Exception ex) { Log.Debug(TAG, ex.Message); ToastHelper.ShowToast(this, "Couldn't launch URL.", Android.Widget.ToastLength.Long); } } else if ((message.Data["Action"] == "FastClipboard") && (message.Data.ContainsKey("SenderName")) && (message.Data.ContainsKey("Text"))) { string senderName = message.Data["SenderName"]; string text = message.Data["Text"]; Guid guid = await TextReceiver.QuickTextReceivedAsync(senderName, text); await ClipboardHelper.CopyTextToClipboard(this, guid); } else if (message.Data["Action"] == "CloudClipboard") { if (message.Data.ContainsKey("Data")) { string text = message.Data["Data"]; var settings = new Settings(this); if (message.Data.ContainsKey("AccountId")) { if (CrossSecureStorage.Current.HasKey("RoamitAccountId")) { CrossSecureStorage.Current.DeleteKey("RoamitAccountId"); } CrossSecureStorage.Current.SetValue("RoamitAccountId", message.Data["AccountId"]); } if (settings.CloudClipboardReceiveMode == CloudClipboardReceiveMode.Automatic) { CloudClipboardNotifier.SetCloudClipboardValue(this, text); } else { settings.CloudClipboardText = text; CloudClipboardNotifier.SendCloudClipboardNotification(this, text); } } } else { throw new InvalidOperationException(); } } catch (InvalidOperationException) { SendNotification($"Action '{message.Data["Action"]}' not supported.", "Please make sure the app is updated to enjoy latest features."); } }
protected override async void OnActivated(IActivatedEventArgs e) { Debug.WriteLine("Activated."); Frame rootFrame = Window.Current.Content as Frame; bool isJustLaunched = (rootFrame == null); if (e is ToastNotificationActivatedEventArgs) { var toastActivationArgs = e as ToastNotificationActivatedEventArgs; // Parse the query string QueryString args = QueryString.Parse(toastActivationArgs.Argument); if (!args.Contains("action")) { LaunchRootFrameIfNecessary(ref rootFrame, true); return; } HistoryRow hr; switch (args["action"]) { case "cloudClipboard": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), "CLOUD_CLIPBOARD"); break; case "clipboardReceive": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), args["guid"]); break; case "fileProgress": LaunchRootFrameIfNecessary(ref rootFrame, false); if (rootFrame.Content is MainPage) { break; } rootFrame.Navigate(typeof(MainPage)); break; case "fileFinished": LaunchRootFrameIfNecessary(ref rootFrame, false); if (rootFrame.Content is MainPage) { break; } rootFrame.Navigate(typeof(MainPage), "history"); break; case "openFolder": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFolderFromPathAsync((hr.Data as ReceivedFileCollection).StoreRootPath); if (isJustLaunched) { Application.Current.Exit(); } break; case "openFolderSingleFile": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFolderFromPathAndSelectSingleItemAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name); if (isJustLaunched) { Application.Current.Exit(); } break; case "openSingleFile": hr = await GetHistoryItemGuid(Guid.Parse(args["guid"])); await LaunchOperations.LaunchFileFromPathAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name); if (isJustLaunched) { Application.Current.Exit(); } break; case "saveAsSingleFile": case "saveAs": LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ProgressPage)); var guid = Guid.Parse(args["guid"]); await ReceivedSaveAsHelper.SaveAs(guid); if ((isJustLaunched) || (DeviceInfo.FormFactorType != DeviceInfo.DeviceFormFactorType.Desktop)) { Application.Current.Exit(); } else { rootFrame.GoBack(); } break; default: LaunchRootFrameIfNecessary(ref rootFrame, true); break; } } else if (e.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs pEventArgs = e as ProtocolActivatedEventArgs; if ((pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake") || (pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake/")) { Debug.WriteLine("Wake request received"); Application.Current.Exit(); } else { string clipboardData = ParseFastClipboardUri(pEventArgs.Uri.AbsoluteUri); string remoteLaunchUriData = ParseRemoteLaunchUri(pEventArgs.Uri.AbsoluteUri); string localLaunchUriData = ParseLocalLaunchUri(pEventArgs.Uri.AbsoluteUri); string commServiceData = ParseCommunicationServiceData(pEventArgs.Uri.AbsoluteUri); bool isSettings = ParseSettings(pEventArgs.Uri.AbsoluteUri); string receiveDialogData = ParseReceive(pEventArgs.Uri.AbsoluteUri); if (isSettings) { if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); } rootFrame.Navigate(typeof(MainPage), "settings"); } else if (receiveDialogData.Length > 0) { if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); } rootFrame.Navigate(typeof(MainPage), "receiveDialog"); if (receiveDialogData.Length > 1) { var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(receiveDialogData.Substring(1).DecodeBase64()); await ParseMessage(data); } } else if (commServiceData.Length > 0) { var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(commServiceData.DecodeBase64()); await ParseMessage(data); } else if (clipboardData.Length > 0) { string[] parts = clipboardData.Split('?'); var guid = await TextReceiver.QuickTextReceivedAsync(parts[0].DecodeBase64(), parts[1].DecodeBase64()); LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(ClipboardReceive), guid.ToString()); } else if (remoteLaunchUriData.Length > 0) { #if !DEBUG App.Tracker.Send(HitBuilder.CreateCustomEvent("ExtensionCalled", "").Build()); #endif string type = ExternalContentHelper.SetUriData(new Uri(remoteLaunchUriData.DecodeBase64())); SendDataTemporaryStorage.IsSharingTarget = true; if (rootFrame == null) { LaunchRootFrameIfNecessary(ref rootFrame, false); rootFrame.Navigate(typeof(MainPage), new ShareTargetDetails { Type = type, }); } else { MainPage.Current.BeTheShareTarget(new ShareTargetDetails { Type = type, }); } } else if (localLaunchUriData.Length > 0) { try { //TODO: Log it in history await LaunchOperations.LaunchUrl(localLaunchUriData.DecodeBase64()); } catch { } if (rootFrame == null) { Application.Current.Exit(); } } else { LaunchRootFrameIfNecessary(ref rootFrame, true); } } } else { LaunchRootFrameIfNecessary(ref rootFrame, true); } base.OnActivated(e); }
/// <summary> /// Incept placing of the meta pieces. /// Cancels the real placement of the placeholder pieces. /// </summary> private bool BeforePlaceBlueprintPiece(On.Player.orig_PlacePiece orig, Player self, Piece piece) { // Client only if (!ZNet.instance.IsServerInstance()) { // Capture a new blueprint if (piece.name == "make_blueprint") { var circleProjector = self.m_placementGhost.GetComponent <CircleProjector>(); if (circleProjector != null) { Destroy(circleProjector); } var bpname = $"blueprint{Instance.m_blueprints.Count() + 1:000}"; Jotunn.Logger.LogInfo($"Capturing blueprint {bpname}"); if (Player.m_localPlayer.m_hoveringPiece != null) { var bp = new Blueprint(bpname); if (bp.Capture(Player.m_localPlayer.m_hoveringPiece.transform.position, Instance.selectionRadius, 1.0f)) { TextInput.instance.m_queuedSign = new Blueprint.BlueprintSaveGUI(bp); TextInput.instance.Show($"Save Blueprint ({bp.GetPieceCount()} pieces captured)", bpname, 50); } else { Jotunn.Logger.LogWarning($"Could not capture blueprint {bpname}"); } } else { Jotunn.Logger.LogInfo("Not hovering any piece"); } // Reset Camera offset Instance.cameraOffsetMake = 0f; // Don't place the piece and clutter the world with it return(false); } // Place a known blueprint if (Player.m_localPlayer.m_placementStatus == Player.PlacementStatus.Valid && piece.name.StartsWith("piece_blueprint")) { Blueprint bp = Instance.m_blueprints[piece.m_name]; var transform = self.m_placementGhost.transform; var position = self.m_placementGhost.transform.position; var rotation = self.m_placementGhost.transform.rotation; if (ZInput.GetButton("Crouch") && !ConfigUtil.Get <bool>("Blueprints", "allowPlacementWithoutMaterial")) { MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$plan_direct_build_disable"); return(false); } if (ZInput.GetButton("AltPlace")) { Vector2 extent = bp.GetExtent(); FlattenTerrain.FlattenForBlueprint(transform, extent.x, extent.y, bp.m_pieceEntries); } uint cntEffects = 0u; uint maxEffects = 10u; foreach (var entry in bp.m_pieceEntries) { // Final position Vector3 entryPosition = position + transform.forward * entry.posZ + transform.right * entry.posX + new Vector3(0, entry.posY, 0); // Final rotation Quaternion entryQuat = new Quaternion(entry.rotX, entry.rotY, entry.rotZ, entry.rotW); entryQuat.eulerAngles += rotation.eulerAngles; // Get the prefab of the piece or the plan piece string prefabName = entry.name; if (!ConfigUtil.Get <bool>("Blueprints", "allowPlacementWithoutMaterial") || !ZInput.GetButton("Crouch")) { prefabName += "_planned"; } GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName); if (!prefab) { Jotunn.Logger.LogError(entry.name + " not found?"); continue; } // Instantiate a new object with the new prefab GameObject gameObject = Instantiate(prefab, entryPosition, entryQuat); // Register special effects CraftingStation craftingStation = gameObject.GetComponentInChildren <CraftingStation>(); if (craftingStation) { self.AddKnownStation(craftingStation); } Piece newpiece = gameObject.GetComponent <Piece>(); if (newpiece != null) { newpiece.SetCreator(self.GetPlayerID()); } PrivateArea privateArea = gameObject.GetComponent <PrivateArea>(); if (privateArea != null) { privateArea.Setup(Game.instance.GetPlayerProfile().GetName()); } WearNTear wearntear = gameObject.GetComponent <WearNTear>(); if (wearntear != null) { wearntear.OnPlaced(); } TextReceiver textReceiver = gameObject.GetComponent <TextReceiver>(); if (textReceiver != null) { textReceiver.SetText(entry.additionalInfo); } // Limited build effects if (cntEffects < maxEffects) { newpiece.m_placeEffect.Create(gameObject.transform.position, rotation, gameObject.transform, 1f); self.AddNoise(50f); cntEffects++; } // Count up player builds Game.instance.GetPlayerProfile().m_playerStats.m_builds++; } // Reset Camera offset Instance.cameraOffsetPlace = 5f; // Dont set the blueprint piece and clutter the world with it return(false); } } return(orig(self, piece)); }