/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; // Map coordinates from [0.0,1.0] coordinates to UI-relative coordinates double xUI = x * Constants.InteractionRegionWidth; double yUI = y * Constants.InteractionRegionHeight; var uiElement = this.PerformHitTest(xUI, yUI); if (uiElement != null) { interactionInfo.IsPressTarget = true; // If UI framework uses strings as button IDs, use string hash code as ID interactionInfo.PressTargetControlId = uiElement.Id.GetHashCode(); // Designate center of button to be the press attraction point //// TODO: Create your own logic to assign press attraction points if center //// TODO: is not always the desired attraction point. interactionInfo.PressAttractionPointX = ((uiElement.Left + uiElement.Right) / 2.0) / Constants.InteractionRegionWidth; interactionInfo.PressAttractionPointY = ((uiElement.Top + uiElement.Bottom) / 2.0) / Constants.InteractionRegionHeight; } return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = true; return info; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = true, IsGripTarget = true }; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo result = new InteractionInfo(); result.IsGripTarget = true; result.IsPressTarget = true; result.PressAttractionPointX = 0.5; result.PressAttractionPointY = 0.5; result.PressTargetControlId = 1; return result; }
public InteractionInfo GetInteractionInfoAtLocation( int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo(); interactionInfo.IsGripTarget = true; interactionInfo.IsPressTarget = true; interactionInfo.PressAttractionPointX = 0.5; interactionInfo.PressAttractionPointY = 0.5; interactionInfo.PressTargetControlId = 1; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = false; info.IsPressTarget = false; info.PressTargetControlId = 2; info.PressAttractionPointX = x; info.PressAttractionPointY = y; return info; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, PressAttractionPointX = 0.5, PressAttractionPointY = 0.5, PressTargetControlId = 0 }; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var result = new InteractionInfo(); result.IsGripTarget = true; result.IsPressTarget = true; result.PressAttractionPointX = 0.5; result.PressAttractionPointY = 0.5; result.PressTargetControlId = 1; return(result); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = false; info.IsPressTarget = false; info.PressTargetControlId = 2; info.PressAttractionPointX = x; info.PressAttractionPointY = y; return(info); }
public static async Task <List <ISystemData> > GetRealtimeData(string requestType, string dataType, string campaignId, string startDate, string endDate, string maxResults, int?interval) { SiteRealtimeRequest.Singleton.InitialRequest(SiteRealtimeResource.SiteRealtimeDataClient, User.UserToken.Access_Token); // input parameter InteractionInfo interactionInfo = new InteractionInfo { StartHour = "0:00:00", EndHour = "23:59:59", StartIndex = "0", MaxResults = maxResults }; // input parameter string siteId = campaignId; // input parameter //string requestType = "Current";//[Current Daily InteractionSummary InteractionDetail InteractionEvent] //string dataType = "Summary";//[Summary(for current and daily and interaction) Detail Source Province City Ads Page Event Organic Keyword Hour(for interaction)] try { List <ISystemData> responseData; switch (requestType) { case "online": responseData = await SiteRealtimeRequest.Singleton.GetRealtimeData(siteId, dataType, interval); break; case "statistics": responseData = await SiteRealtimeRequest.Singleton.GetRealtimeData(siteId, dataType, interval); break; case "transform": responseData = await SiteRealtimeRequest.Singleton.GetInteractionData(siteId, dataType, interactionInfo); break; default: responseData = new List <ISystemData>(); break; } return(responseData); } catch (Exception ex) { return(new List <ISystemData>()); } }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, PressAttractionPointX = 0.5, PressAttractionPointY = 0.5, PressTargetControlId = 0 }; return(interactionInfo); }
public InteractionInfo GetInteractionInfoAtLocation( int skeletonTrackingId, InteractionHandType handType, double x, double y) { var result = new InteractionInfo { IsGripTarget = true, IsPressTarget = false, }; return(result); }
/// <summary> /// Overwrites completely the method 'GetInteractionProposal' from the WorkInteractionController /// </summary> /// <param name="__instance">Instance of the WorkInteractionController</param> /// <param name="human">Original HumanAI argument</param> /// <param name="__result">The result of the method</param> /// <returns>False to prevent the original method from executing</returns> public static bool Prefix(WorkInteractionController __instance, HumanAI human, ref InteractionInfo __result) { instance = __instance; __result = null; //This bit is copy/pasted from the original method. It checks if the 'human' is a colonist and can actually work if (human.IsLockedUp() || !human.WillWorkAutomatically() || human.IsLazy() || human.faction.GetFactionType() != FactionType.Colony || human.controlMode == ControlMode.Combat) { return(false); } //Don't override manual interactions InteractionInfo currentInteraction = human.GetCurrentInteractionInfo(); if (currentInteraction != null && !currentInteraction.issuedByAI) { return(false); } //Init the human in case it's new AbsoluteProfessionPrioritiesMod.Instance.InitColonist(human); //Creates a dictionary of all of the colonist's active professions, grouped by priorities (number of stars) Dictionary <int, List <ProfessionType> > profs = human.professionManager.professions.Values.Where( x => x.priority > 0).GroupBy(x => x.priority).ToDictionary( x => x.Key, x => x.Select(y => y.type).ToList()); foreach (var priority in profs.Keys.OrderByDescending(x => x)) { foreach (var profession in profs[priority].OrderBy(x => UnityEngine.Random.Range(0f, 1f))) { if (!AbsoluteProfessionPrioritiesMod.Instance.ColonistsData[human.GetID()].ContainsKey(profession)) { continue; } foreach (var info in GetNextInteraction(__instance, human, profession)) { if (info != null) { __result = info; return(false); } } } } return(false); }
public InteractionInfo GetInteractionInfoAtLocation( int s, InteractionHandType h, double x, double y ) { var r = new InteractionInfo(); r.IsGripTarget = true; r.IsPressTarget = true; r.PressAttractionPointX = 0.5; r.PressAttractionPointY = 0.5; r.PressTargetControlId = 1; return(r); }
public string TagInteraction(InteractionInfo interaction) { string tag = TagUriPath(interaction.RequestPath?.ToLower()); var stateChars = interaction.ProviderState.ToCharArray(); tag += ":" + interaction.RequestMethod.Method.ToLower() + ":"; foreach (char c in stateChars) { if (char.IsDigit(c) || char.IsLetter(c)) { tag += c; } } return(tag); }
public static void Postfix(NeedsInteractionController __instance, HumanAI human, ref InteractionInfo __result) { if ((human.IsLazy() || human.uncontrollableReasons.Count > 0) && !human.IsFullyHealthy() && !human.IsLockedUp()) { Interactable interactable = null; OwnershipModule module = human.GetOwnedStuff(OwnershipCategory.Bed); if (module != null && module.parent.GetInteractable().GetPossibleInteractions(human, true, false).Contains(Interaction.Sleep) && human.humanNavigation.IsInteractableProbablyReachable(module.parent.GetID())) { interactable = module.parent.GetInteractable(); } if (interactable != null && interactable.IsValid()) { __result = new InteractionInfo(Interaction.SleepUntilHealthy, interactable, null, true, 120, true, true); } } }
public void RecordInteraction(string metricName, int initiatingPlayer, float?xPos, float?yPos, string actionData) { if (currentRoundActions == null) { return; } InteractionInfo info = new InteractionInfo(); info.metricName = metricName; info.initiatingPlayer = initiatingPlayer; info.actionXPos = xPos; info.actionYPos = yPos; info.actionSpecificData = actionData; info.actionTime = (float)(DateTime.Now - sessionStart).TotalSeconds; //Debug.Log(string.Format("Recording interaction - Name: \"{0}\" Player: {1} Time: {2} XPos: {3} YPos: {4} Data: {5}", // metricName, initiatingPlayer, info.actionTime, xPos, yPos, actionData)); currentRoundActions.Add(info); }
/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; if (this.interactionIsEnabled && (this.clientRpcChannel != null)) { var result = this.clientRpcChannel.CallFunction <InteractionStreamHitTestInfo>("getInteractionInfoAtLocation", skeletonTrackingId, handType.ToString(), x, y); if (result.Success) { interactionInfo.IsGripTarget = result.Result.isGripTarget; interactionInfo.IsPressTarget = result.Result.isPressTarget; var elementId = result.Result.pressTargetControlId; interactionInfo.PressTargetControlId = (elementId != null) ? elementId.GetHashCode() : 0; interactionInfo.PressAttractionPointX = result.Result.pressAttractionPointX; interactionInfo.PressAttractionPointY = result.Result.pressAttractionPointY; } } return(interactionInfo); }
/// <summary> /// Get a list of position of top Block that match the type T. Usefull when wanted to destroy plants or tree debris /// </summary> public static List <Vector3i> GetTopBlockPositionAroundPoint <T>(User user, Vector3i position, int range) where T : Block { try { List <Vector3i> blockLists = new List <Vector3i>(); for (int i = -range; i < range; i++) { for (int j = -range; j < range; j++) { if (i == 0 && j == 0) { continue; } Vector3i positionAbove = World.GetTopPos(new Vector2i(position.x + i, position.z + j)) + Vector3i.Up; Block blockAbove = World.GetBlockProbablyTop(positionAbove); if (blockAbove is T) { if (positionAbove != position && Vector3i.Distance(positionAbove, position) < range) { InteractionInfo info = new InteractionInfo(); info.Method = InteractionMethod.Right; info.BlockPosition = positionAbove; InteractionContext context = info.MakeContext(user.Player); if (AuthManager.IsAuthorized(context)) { blockLists.Add(positionAbove); } } } } } return(blockLists); } catch (Exception) { return(null); } }
public void UpdateChargeList() { //Destroy all childrens foreach (InteractionInfo iI in interactionInfos) { Destroy(iI.interactionVector.transform.gameObject); } interactionInfos = null; //Repopulate childrens parentChildCount = this.transform.parent.childCount; //chargeList = new Transform[parentChildCount]; interactionInfos = new InteractionInfo[parentChildCount - 1]; int interactionVectorIndex = 0; for (int j = 0; j < parentChildCount; j++) { Transform charge1Transform = this.transform; Transform charge2Transform = this.transform.parent.GetChild(j); if (this.transform != charge2Transform) { interactionInfos[interactionVectorIndex] = new InteractionInfo(); interactionInfos[interactionVectorIndex].q1 = Charge; //charge1.gameObject.GetComponent<ChargeController>().charge; interactionInfos[interactionVectorIndex].q2 = charge2Transform.gameObject.GetComponent <ChargeController>().Charge; interactionInfos[interactionVectorIndex].charge1Transform = charge1Transform; interactionInfos[interactionVectorIndex].charge2Transform = charge2Transform; interactionInfos[interactionVectorIndex].arrowColor = spriteColor; interactionInfos[interactionVectorIndex].interactionVector = Instantiate(vectorPrefab, Vector3.zero, Quaternion.identity, charge2Transform.Find("CoulombForceVectors")).GetComponent <VectorController>(); //Debug.Log(interactionVectorIndex); interactionVectorIndex++; } } }
public async Task <List <ISystemData> > GetInteractionData(string siteId, string dataType, InteractionInfo interactionInfo) { var systemData = new List <ISystemData>(); switch (dataType) { case "summary": systemData = await GetInteractionSummaryData(siteId, dataType); break; case "hour": systemData = await GetInteractionSummaryData(siteId, dataType); break; case "detail": systemData = await GetInteractionDetailData(siteId, interactionInfo); break; case "event": systemData = await GetInteractionEventData(siteId, interactionInfo); break; } return(systemData); }
/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; if (this.interactionIsEnabled && (this.clientRpcChannel != null)) { var result = this.clientRpcChannel.CallFunction<InteractionStreamHitTestInfo>("getInteractionInfoAtLocation", skeletonTrackingId, handType.ToString(), x, y); if (result.Success) { interactionInfo.IsGripTarget = result.Result.isGripTarget; interactionInfo.IsPressTarget = result.Result.isPressTarget; var elementId = result.Result.pressTargetControlId; interactionInfo.PressTargetControlId = (elementId != null) ? elementId.GetHashCode() : 0; interactionInfo.PressAttractionPointX = result.Result.pressAttractionPointX; interactionInfo.PressAttractionPointY = result.Result.pressAttractionPointY; } } return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, }; var hitTestPosition = InteractionZoneDefinition.InteractionZoneToElement(x, y, this.InteractionRootElement); Func <HandPointer, bool> isTargetCapturedElement = handPointer => (handPointer.TrackingId == skeletonTrackingId) && (handPointer.HandType == EnumHelper.ConvertHandType(handType)) && (handPointer.Captured != null); var targetHandPointer = this.publicHandPointers.FirstOrDefault(isTargetCapturedElement); var targetElement = targetHandPointer != null ? targetHandPointer.Captured : this.HitTest(hitTestPosition); if (targetElement != null) { // Walk up the tree and try to find a grip target and/or a press target for (DependencyObject search = targetElement; search != null && search != this.InteractionRootElement && (!interactionInfo.IsGripTarget || !interactionInfo.IsPressTarget); search = VisualTreeHelper.GetParent(search)) { var searchElement = search as FrameworkElement; if (searchElement == null) { // We need ActualWidth and Height which comes // with FrameworkElement continue; } if (!interactionInfo.IsPressTarget) { bool isPressTarget = KinectRegion.GetIsPressTarget(searchElement); if (isPressTarget) { // We found a press target. if (interactionInfo.PressTargetControlId == 0) { interactionInfo.PressTargetControlId = searchElement.GetHashCode(); } interactionInfo.IsPressTarget = true; // Apply the margin to the press target point Point pressTargetPoint = ApplyControlPressPointMargin(KinectRegion.GetPressTargetPoint(searchElement)); // Convert from interaction zone space into actual control coordinates var elementPressTargetPoint = InteractionZoneDefinition.InteractionZoneToElement( pressTargetPoint.X, pressTargetPoint.Y, searchElement); // Get it into the space of the KinectRegion var regionPressTargetPoint = searchElement.TranslatePoint(elementPressTargetPoint, this.InteractionRootElement); // Now put it into the interaction zone space but now relative to the KinectRegion var interactionPressTargetPoint = InteractionZoneDefinition.ElementToInteractionZone( regionPressTargetPoint.X, regionPressTargetPoint.Y, this.InteractionRootElement); interactionInfo.PressAttractionPointX = interactionPressTargetPoint.X; interactionInfo.PressAttractionPointY = interactionPressTargetPoint.Y; } } if (!interactionInfo.IsGripTarget) { bool isGripTarget = KinectRegion.GetIsGripTarget(searchElement); if (isGripTarget) { // We found a grip target. interactionInfo.IsGripTarget = true; } } } } return(interactionInfo); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, }; var hitTestPosition = InteractionZoneDefinition.InteractionZoneToElement(x, y, this.InteractionRootElement); Func<HandPointer, bool> isTargetCapturedElement = handPointer => (handPointer.TrackingId == skeletonTrackingId) && (handPointer.HandType == EnumHelper.ConvertHandType(handType)) && (handPointer.Captured != null); var targetHandPointer = this.publicHandPointers.FirstOrDefault(isTargetCapturedElement); var targetElement = targetHandPointer != null ? targetHandPointer.Captured : this.HitTest(hitTestPosition); if (targetElement != null) { // Walk up the tree and try to find a grip target and/or a press target for (DependencyObject search = targetElement; search != null && search != this.InteractionRootElement && (!interactionInfo.IsGripTarget || !interactionInfo.IsPressTarget); search = VisualTreeHelper.GetParent(search)) { var searchElement = search as FrameworkElement; if (searchElement == null) { // We need ActualWidth and Height which comes // with FrameworkElement continue; } if (!interactionInfo.IsPressTarget) { bool isPressTarget = KinectRegion.GetIsPressTarget(searchElement); if (isPressTarget) { // We found a press target. if (interactionInfo.PressTargetControlId == 0) { interactionInfo.PressTargetControlId = searchElement.GetHashCode(); } interactionInfo.IsPressTarget = true; // Apply the margin to the press target point Point pressTargetPoint = ApplyControlPressPointMargin(KinectRegion.GetPressTargetPoint(searchElement)); // Convert from interaction zone space into actual control coordinates var elementPressTargetPoint = InteractionZoneDefinition.InteractionZoneToElement( pressTargetPoint.X, pressTargetPoint.Y, searchElement); // Get it into the space of the KinectRegion var regionPressTargetPoint = searchElement.TranslatePoint(elementPressTargetPoint, this.InteractionRootElement); // Now put it into the interaction zone space but now relative to the KinectRegion var interactionPressTargetPoint = InteractionZoneDefinition.ElementToInteractionZone( regionPressTargetPoint.X, regionPressTargetPoint.Y, this.InteractionRootElement); interactionInfo.PressAttractionPointX = interactionPressTargetPoint.X; interactionInfo.PressAttractionPointY = interactionPressTargetPoint.Y; } } if (!interactionInfo.IsGripTarget) { bool isGripTarget = KinectRegion.GetIsGripTarget(searchElement); if (isGripTarget) { // We found a grip target. interactionInfo.IsGripTarget = true; } } } } return interactionInfo; }
private async Task <List <ISystemData> > GetInteractionEventData(string siteId, InteractionInfo interactionInfo) { var resource = string.Format(SiteRealtimeResource.SiteRealtimeInteractionEventRequest, siteId); var request = new RestRequest(resource, Method.GET); if (accessToken != null) { request.AddParameter("access_token", accessToken); } if (interactionInfo != null) { request.AddParameter("start-hour", interactionInfo.StartHour); request.AddParameter("end-hour", interactionInfo.EndHour); request.AddParameter("start-index", interactionInfo.StartIndex); request.AddParameter("max-results", interactionInfo.MaxResults); } var response = await client.ExecuteGetTaskAsync <List <string> >(request); if (!IsStatusCodeOK(response.StatusCode)) { return(null); } var systemData = GetInteractionEventData(response.Data[0]); await InteractionDataRequest.Singleton.CompleteData(systemData); //return response.Data; return(systemData); }
public static void Postfix(NeedsInteractionController __instance, HumanAI human, ref InteractionInfo __result) { if (__result != null && ( (__result.interaction == Interaction.Sleep && human.energy >= 0.15f) || (__result.interaction == Interaction.SleepOnGround && human.energy > 0))) { __result = null; } }
public string TagEndpoint(InteractionInfo interaction) { return(TagUriPath(interaction.RequestPath?.ToLower())); }
public void SaveXML(string filename) { // saves the current set of interactions and lists to file InteractionInfo sInfo = new InteractionInfo(); sInfo.Interactions = Interactions; sInfo.InteractionLists = InteractionLists; Serializer<InteractionInfo> iSerializer = new Serializer<InteractionInfo>(); iSerializer.Save(filename, sInfo); }