void RemoveInteractor(Interactor interactor) { var staleTopics = new HashSet<string>(); ISet<string> topics; if (_publisherToTopicMap.TryGetValue(interactor, out topics)) { foreach (var topic in topics) { ISet<Interactor> publishers; if (_topicToPublisherMap.TryGetValue(topic, out publishers) && publishers.Contains(interactor)) { publishers.Remove(interactor); if (publishers.Count == 0) { _topicToPublisherMap.Remove(topic); staleTopics.Add(topic); } } } _publisherToTopicMap.Remove(interactor); } _messageBus.StalePublishers.OnNext(SourceMessage.Create<IEnumerable<string>>(interactor, staleTopics)); }
void Forward(Message message, Interactor sender) { switch (message.MessageType) { case MessageType.SubscriptionRequest: { var subscriptionRequest = (SubscriptionRequest)message; _messageBus.SubscriptionRequests.OnNext(SourceMessage.Create(sender, subscriptionRequest)); _messageBus.ForwardedSubscriptionRequests.OnNext(new ForwardedSubscriptionRequest(sender.Id, subscriptionRequest.Topic, subscriptionRequest.IsAdd)); } break; case MessageType.MulticastData: _messageBus.PublishedMulticastDataMessages.OnNext(SourceMessage.Create(sender, (MulticastData)message)); break; case MessageType.UnicastData: _messageBus.PublishedUnicastDataMessages.OnNext(SourceMessage.Create(sender, (UnicastData)message)); break; case MessageType.NotificationRequest: _messageBus.NotificationRequests.OnNext(SourceMessage.Create(sender, (NotificationRequest)message)); break; default: throw new ArgumentException("invalid message type"); } }
bool Accept(IObserver<Interactor> observer) { Log.Info("Accept new connection"); try { var newSocket = _listener.Accept(); var interactor = new Interactor(newSocket, _nextInteractorId++, _bufferManager); _interactors.Add(newSocket, interactor); Log.DebugFormat("Accepted {0}", interactor); observer.OnNext(interactor); return true; } catch (SocketException ex) { if (ex.SocketErrorCode == SocketError.Interrupted) observer.OnCompleted(); else observer.OnError(ex); } catch (Exception ex) { observer.OnError(ex); } return false; }
void AddInteractor(Interactor interactor) { _interactors.Add(interactor); interactor.ToObservable() .Subscribe( message => Forward(message, interactor), error => _messageBus.FaultedInteractors.OnNext(new SourceMessage<Exception>(interactor, error)), () => _messageBus.ClosedInteractors.OnNext(interactor)); }
public void RemoveNotificationRequest(Interactor source, NotificationRequest notificationRequest) { Notification notification; if (_cache.TryGetValue(notificationRequest.TopicPattern, out notification) && notification.Notifiables.Contains(source)) { notification.Notifiables.Remove(source); if (notification.Notifiables.Count == 0) _cache.Remove(notificationRequest.TopicPattern); } }
/// <summary> /// Assigns the gaze-aware behavior to an interactor. /// </summary> /// <param name="interactor">Interactor to assign the gaze-aware interactor to.</param> public void AssignBehavior(Interactor interactor) { using (var behavior = interactor.CreateBehavior(BehaviorType.GazeAware)) { if (DelayMilliseconds > 0) { var parameters = new GazeAwareParams { GazeAwareMode = GazeAwareMode.Delayed, DelayTime = DelayMilliseconds }; behavior.SetGazeAwareParams(ref parameters); } } }
public void AssignBehavior(Interactor interactor) { using (var behavior = interactor.CreateBehavior(BehaviorType.GazeAware)) { if (DelayTime > 0) { var gazeAwareParams = new GazeAwareParams() { GazeAwareMode = GazeAwareMode.Delayed, DelayTime = DelayTime }; behavior.SetGazeAwareParams(ref gazeAwareParams); } } }
void AddSubscription(string topic, Interactor subscriber) { // Find the list of interactors that have subscribed to this topic. IDictionary<Interactor, Subscription> subscribers; if (!_subscriptionCache.TryGetValue(topic, out subscribers)) _subscriptionCache.Add(topic, (subscribers = new Dictionary<Interactor, Subscription>())); if (subscribers.ContainsKey(subscriber)) ++subscribers[subscriber].SubscriptionCount; else subscribers.Add(subscriber, new Subscription()); }
void AddNotificationRequest(Interactor source, NotificationRequest notificationRequest) { Notification notification; if (!_cache.TryGetValue(notificationRequest.TopicPattern, out notification)) _cache.Add(notificationRequest.TopicPattern, notification = new Notification(new Regex(notificationRequest.TopicPattern))); if (!notification.Notifiables.Contains(source)) { notification.Notifiables.Add(source); _messageBus.NewNotificationRequests.OnNext(SourceMessage.Create(source, notification.TopicPattern)); } }
public void AssignBehavior (Interactor interactor) { // Create the parameters used to create the pannable behavior. var param = new PannableParams { IsHandsFreeEnabled = EyeXBoolean.False, PanDirectionsAvailable = (PanDirection)AvailablePanDirections, Profile = (PanningProfile)Profile }; // Create and associate the pannable behavior with the interactor. interactor.CreatePannableBehavior(ref param); }
void RememberPublisherForTopic(string topic, Interactor publisher) { ISet<Interactor> publishers; if (!_topicToPublisherMap.TryGetValue(topic, out publishers)) _topicToPublisherMap.Add(topic, publishers = new HashSet<Interactor>()); if (!publishers.Contains(publisher)) publishers.Add(publisher); ISet<string> topics; if (!_publisherToTopicMap.TryGetValue(publisher, out topics)) _publisherToTopicMap.Add(publisher, topics = new HashSet<string>()); if (!topics.Contains(topic)) topics.Add(topic); }
protected abstract void AssignBehavior(Interactor interactor);
public override void OnInteractorExit(Interactor interactor) { //Por las dudas rb.isKinematic = false; transform.SetParent(null); }
public void OnInspectedStart(Interactor interactor) { }
public void OnPressed(Interactor by) { this.GetComponentInParent <ExosuitFabricator>().TryDelete(index); }
/// <summary> /// Removes a task from the queue and adds a new task with the same charIdx, kind, id, and bonus for a later time. /// </summary> /// <param name="intr"></param> /// <param name="charIdx"></param> /// <param name="taskKind"></param> /// <param name="taskId"></param> /// <param name="bonusFactor"></param> /// <param name="incrementTaskId"></param> /// <param name="force">If set to true, advances a task even if it has not matured.</param> private void AdvanceTask(Interactor intr, uint charIdx, TaskKind taskKind, int taskId, float bonusFactor, bool incrementTaskId, bool force) { // CHECK TO SEE IF THAT TASK IS ALREADY IN QUEUE, // IF NOT ADD // IF SO, CHECK TO SEE IF THAT TASK HAS MATURED // IF IT HAS MATURED, ADVANCE intr.Log(LogEntryType.Info, "Advancing task: " + "[charIdx: " + charIdx + ", taskKind: " + taskKind.ToString() + ", taskId: " + taskId + "]."); var nowTicks = DateTime.Now.AddSeconds(1).Ticks; long taskKey = 0; bool keyExists = this.TryGetTaskKey(charIdx, taskKind, taskId, out taskKey); if (keyExists) { intr.Log(LogEntryType.Debug, "Queue entry found for task: " + "taskId: " + taskId.ToString() + ", " + "taskKind: " + taskKind.ToString() + ", " + "charIdx: " + charIdx.ToString() + ". "); if (taskKey < nowTicks || force) // MATURE or FORCED { if (taskKey < nowTicks) { intr.Log(LogEntryType.Debug, "Task is mature. Removing and adding anew ..."); } else { intr.Log(LogEntryType.Debug, "Forcing task advancement. Removing and adding anew ..."); } //intr.Log(LogEntryType.Debug, "Removing old task."); Queue.Remove(taskKey); if (taskKind == TaskKind.Invocation) { intr.Log(LogEntryType.Debug, "Queuing subsequent invocation task."); var invokesToday = (incrementTaskId) ? taskId + 1 : taskId; this.QueueSubsequentInvocationTask(intr, charIdx, invokesToday); } else if (taskKind == TaskKind.Profession) { intr.Log(LogEntryType.Debug, "Queuing subsequent professions task."); this.QueueSubsequentProfessionTask(intr, charIdx, taskId, bonusFactor); } } else // NOT MATURE { intr.Log(LogEntryType.Debug, "Task is not mature: taskKey: " + taskKey + ", nowTicks: " + nowTicks + "."); } } else // DOESN'T EXIST YET { intr.Log(LogEntryType.Info, "Key not found for task."); if (taskKind == TaskKind.Invocation) { this.QueueSubsequentInvocationTask(intr, charIdx, 1); } else if (taskKind == TaskKind.Profession) { this.QueueSubsequentProfessionTask(intr, charIdx, taskId, bonusFactor); } } }
void Start() { interactor = GetComponent <Interactor>(); movementAI = GetComponent <MovementAI>(); layerHandler = GameObject.FindGameObjectWithTag("LayerHandler").GetComponent <LayerHandler>(); }
// Actually queues a profession task: private static bool ContinueTask(Interactor intr, Point continueButton, out float bonusFactor) { Mouse.Click(intr, continueButton); intr.Wait(100); // Detect currently selected asset: LeadershipAsset primaryAsset = new LeadershipAsset(ProfessionAssetId.None, 1.00f); foreach (var asset in leadershipAssets) { if (Screen.ImageSearch(intr, asset.LargeTileImageLabel).Found) { primaryAsset = asset; break; } } if (primaryAsset.AssetId == ProfessionAssetId.None) { intr.Log(LogEntryType.Error, "Primary profession asset not detected."); bonusFactor = 0.0f; return false; } else { intr.Log(LogEntryType.Debug, "Using primary profession asset: '{0}'.", primaryAsset.Label); } // Attempt to add optional assets: Mouse.ClickImage(intr, "ProfessionsAssetButton"); intr.Wait(50); LeadershipAsset optionalAsset = new LeadershipAsset(ProfessionAssetId.None, 1.00f); foreach (var asset in leadershipAssets) { if (Mouse.ClickImage(intr, asset.SmallIconImageLabel)) { optionalAsset = asset; break; } } if (optionalAsset.AssetId == ProfessionAssetId.None) { intr.Log(LogEntryType.Debug, "No optional profession assets found."); } else { intr.Log(LogEntryType.Debug, "Using optional profession asset: '{0}'.", optionalAsset.Label); } intr.Wait(50); // Enqueue the profession task: Mouse.ClickImage(intr, "ProfessionsStartTaskButton"); intr.Wait(500); if (primaryAsset.AssetId == ProfessionAssetId.Mercenary || primaryAsset.AssetId == ProfessionAssetId.Guard || primaryAsset.AssetId == ProfessionAssetId.Footman) { bonusFactor = optionalAsset.BonusFactor; } else { bonusFactor = primaryAsset.BonusFactor + optionalAsset.BonusFactor; } return true; }
// Token: 0x06001E23 RID: 7715 RVA: 0x0000AC89 File Offset: 0x00008E89 public bool ShouldIgnoreSpherecastForInteractibility(Interactor activator) { return(false); }
public static CompletionStatus MaintainProfs(Interactor intr, uint charIdx, List<ProfessionTaskResult> completionList) { if (intr.CancelSource.IsCancellationRequested) { return CompletionStatus.Cancelled; } string charLabel = intr.AccountSettings.CharNames[(int)charIdx]; string profsWinKey = intr.AccountSettings.GetSettingValOr("professions", "gameHotkeys", Global.Default.ProfessionsWindowKey); intr.Log(LogEntryType.Debug, "Opening professions window for " + charLabel + "."); Keyboard.SendKey(intr, profsWinKey); intr.Wait(1000); if (!Screen.ImageSearch(intr, "ProfessionsWindowTitle").Found) { MoveAround(intr); Keyboard.SendKey(intr, profsWinKey); intr.Wait(200); if (!Screen.ImageSearch(intr, "ProfessionsWindowTitle").Found) { intr.Log(LogEntryType.FatalWithScreenshot, "Unable to open professions window"); return CompletionStatus.Failed; } } if (Mouse.ClickImage(intr, "ProfessionsOverviewInactiveTile")) { intr.Wait(500); } int profResultsCollected = 0; if (Screen.ImageSearch(intr, "ProfessionsCollectResult").Found) { while (profResultsCollected < 9) { if (!CollectCompleted(intr)) { break; } else { profResultsCollected += 1; } } intr.Log(LogEntryType.Debug, "Collected " + profResultsCollected + " profession results for " + charLabel + "."); } int noValidTaskId = 0; int noValidTaskCounter = 0; int currentTaskId = 0; var anySuccess = false; for (int slotId = 0; slotId < 9; slotId++) { if (intr.CancelSource.IsCancellationRequested) { return CompletionStatus.Cancelled; }; if (Mouse.ClickImage(intr, "ProfessionsOverviewInactiveTile")) { intr.Wait(400); } var EmptySlotResult = Screen.ImageSearch(intr, "ProfessionsEmptySlot"); if (EmptySlotResult.Found) { intr.Log(LogEntryType.Info, "Empty professions slot found at: " + EmptySlotResult.Point.ToString() + "."); } else { intr.Log(LogEntryType.Info, "All professions slots busy."); break; } // Click the "Choose Task" button below the empty slot: Mouse.Click(intr, EmptySlotResult.Point, 30, 90); intr.Wait(400); // Click the "Leadership" category tile if it is not selected (determined by color): Mouse.ClickImage(intr, "ProfessionsLeadershipTileUnselected"); intr.Wait(200); var taskContinueResult = Screen.ImageSearch(intr, "ProfessionsTaskContinueButton"); if (slotId == 0 || !taskContinueResult.Found) { while(true) { if (currentTaskId < ProfessionTasksRef.ProfessionTaskNames.Length) { SelectProfTask(intr, ProfessionTasksRef.ProfessionTaskNames[currentTaskId]); taskContinueResult = Screen.ImageSearch(intr, "ProfessionsTaskContinueButton"); if (taskContinueResult.Found) { intr.Log(LogEntryType.Debug, "Profession task: '{0}' has been selected.", ProfessionTasksRef.ProfessionTaskNames[currentTaskId]); break; } else { currentTaskId += 1; continue; } } else { // We've been stuck // if (noValidTaskId == currentTaskId) { // We have already set `noValidTaskId` for this task // if (noValidTaskCounter >= 2) { // This is the 3rd time we've been here // intr.Log(LogEntryType.Error, "Error starting profession task on " + charLabel + ":"); intr.Log(LogEntryType.Error, "- Ensure that profession assets are sorted correctly in inventory."); return CompletionStatus.Stuck; } else { noValidTaskCounter += 1; } } else { noValidTaskId = currentTaskId; noValidTaskCounter = 1; } intr.Log(LogEntryType.Normal, "Could not find valid professions task."); CollectCompleted(intr); Mouse.ClickImage(intr, "ProfessionsWindowTitle"); Mouse.Move(intr, Screen.ImageSearch(intr, "ProfessionsWindowTitle").Point); } } } if (taskContinueResult.Found && currentTaskId < ProfessionTasksRef.ProfessionTaskNames.Length) { float bonusFactor = 0.0f; // Start the in-game task: if (ContinueTask(intr, taskContinueResult.Point, out bonusFactor)) { intr.Log(LogEntryType.Debug, "Profession task '{0}' (id: {1}, bf: {2}) started.", ProfessionTasksRef.ProfessionTaskNames[currentTaskId], currentTaskId, bonusFactor); completionList.Add(new ProfessionTaskResult(currentTaskId, bonusFactor)); anySuccess = true; } } } // Condense tasks into groups (of 3 generally): CondenseTasks(intr, completionList); if (intr.CancelSource.IsCancellationRequested) { return CompletionStatus.Cancelled; } if (anySuccess) { return CompletionStatus.Complete; } else { return CompletionStatus.Immature; } }
private static bool CollectCompleted(Interactor intr) { var resultAvailable = Screen.ImageSearch(intr, "ProfessionsCollectResult"); if (resultAvailable.Found) { Mouse.Click(intr, resultAvailable.Point, 15, 5); intr.Wait(900); Mouse.ClickImage(intr, "ProfessionsTakeRewardsButton", 21, 5); intr.Wait(1500); return true; } else { return false; } }
// Combines tasks with the same id into one task, preserving the worst (lowest) bonus factor. public static void CondenseTasks(Interactor intr, List<ProfessionTaskResult> completionList) { var buckets = new Dictionary<int, ProfessionTaskResult>(9); foreach (ProfessionTaskResult taskResult in completionList) { //intr.Log(LogEntryType.Debug, "Professions::CondenseTasks(): Attempting to condense list task (id: {0}, bf: {1})...", // taskResult.TaskId, taskResult.BonusFactor); int bucket_id = taskResult.TaskId; ProfessionTaskResult peerTaskResult; bool peerExists = buckets.TryGetValue(bucket_id, out peerTaskResult); if (peerExists) { //intr.Log(LogEntryType.Debug, "Professions::CondenseTasks(): Pre-existing peer found (id: {0}, bf: {1}).", // peerTaskResult.TaskId, peerTaskResult.BonusFactor); if (taskResult.BonusFactor < peerTaskResult.BonusFactor) { buckets[bucket_id] = taskResult; } } else { //intr.Log(LogEntryType.Debug, "Professions::CondenseTasks(): No peer found, adding task (id: {0}, bf: {1}).", // taskResult.TaskId, taskResult.BonusFactor); buckets.Add(bucket_id, taskResult); } } completionList.Clear(); foreach (ProfessionTaskResult taskResult in buckets.Values) { intr.Log(LogEntryType.Debug, "Professions::CondenseTasks(): Profession completion list task: '{0}' has been " + "condensed with a bonus factor of: '{1}'.", taskResult.TaskId, taskResult.BonusFactor); completionList.Add(taskResult); } }
void RemoveInteractor(Interactor interactor) { Log.DebugFormat("Removing subscriptions for {0}", interactor); // Remove the subscriptions var subscriptions = new List<string>(); var emptySubscriptions = new List<string>(); foreach (var item in _subscriptionCache) { if (item.Value.ContainsKey(interactor)) { item.Value.Remove(interactor); if (item.Value.Count == 0) emptySubscriptions.Add(item.Key); subscriptions.Add(item.Key); } } foreach (var topic in subscriptions) _messageBus.ForwardedSubscriptionRequests.OnNext(new ForwardedSubscriptionRequest(interactor.Id, topic, false)); foreach (var topic in emptySubscriptions) _subscriptionCache.Remove(topic); }
void RemoveSubscription(string topic, Interactor subscriber) { IDictionary<Interactor, Subscription> subscribers; if (!_subscriptionCache.TryGetValue(topic, out subscribers)) return; if (subscribers.ContainsKey(subscriber)) { if (--subscribers[subscriber].SubscriptionCount <= 0) subscribers.Remove(subscriber); } if (subscribers.Count == 0) _subscriptionCache.Remove(topic); }
private new void Awake() { base.Awake(); m_movementController.InitializeCharacterController(45f, 0.3f, 0.01f, 0.25f, 1.76f); m_movementController.InitializeCharacterMotor(false, 1f, 1f, 1f, false, false, false); interactor = gameObject.GetComponent<Interactor>(); camTransitioner = thisCamera.GetComponent<CameraTransitioner>(); cameraFollow = thisCamera.GetComponent<CameraFollow>(); flshCtrl = gameObject.GetComponent<FlashlightController>(); firstPersonRig.gameObject.SetActive(false); var neckBone = siljaAnimation.GetBoneTransform(HumanBodyBones.Neck); cameraFollow.cameraFocusTarget = neckBone; }
private static void SelectProfTask(Interactor intr, string taskName) { intr.Log(LogEntryType.Debug, "Attempting to select profession task: '{0}'.", taskName); var searchButton = Screen.ImageSearch(intr, "ProfessionsSearchButton"); intr.Wait(50); Mouse.Click(intr, searchButton.Point, -100, 0); intr.Wait(50); Keyboard.SendKey(intr, "Shift", "Home"); intr.Wait(50); Keyboard.Send(intr, taskName); intr.Wait(50); Keyboard.SendKey(intr, "Enter"); intr.Wait(100); }
void RemoveInteractor(Interactor interactor) { _interactors.Remove(interactor); }
public static void InteractorConstructed(Interactor.Base interactor) { if (_interactors==null) _interactors = new ArrayList(); _interactors.Add(interactor); }
public void OnExplosiveGrab(Handle handle, Interactor interactor) { CancelInvoke("Explosion"); }
public static void InteractorDisposed(Interactor.Base interactor) { _interactors.Remove(interactor); }
// FOR PROFESSIONS public void AdvanceProfessionsTask(Interactor intr, uint charIdx, int taskId, float bonusFactor) { this.AdvanceTask(intr, charIdx, TaskKind.Profession, taskId, bonusFactor, false, true); }
private bool AttemptUnlock(GameObject chestObject, InteractionDriver interactionDriver, float UnlockChance) { if (!interactionDriver) { return(false); } Highlight highlight = chestObject.GetComponent <Highlight>(); PurchaseInteraction purchaseInteraction = chestObject.GetComponent <PurchaseInteraction>(); if (!highlight || !purchaseInteraction) { return(false); } BulletstormChestInteractorComponent chestComponent = chestObject.GetComponent <BulletstormChestInteractorComponent>(); if (chestComponent && chestComponent.hasUsedLockpicks) { return(false); } GameObject selectedEffect = UnlockEffect; Vector3 offset = Vector3.up * 1f; if (!purchaseInteraction.isShrine && purchaseInteraction.available && purchaseInteraction.costType == CostTypeIndex.Money) { Interactor interactor = interactionDriver.interactor; //interactionDriver.interactor.AttemptInteraction(chestObject); if (Util.CheckRoll(UnlockChance)) { purchaseInteraction.SetAvailable(false); //purchaseInteraction.Networkavailable = false; purchaseInteraction.gameObject.GetComponent <ChestBehavior>().Open(); //purchaseInteraction.cost = 0; //purchaseInteraction.Networkcost = 0; purchaseInteraction.onPurchase.Invoke(interactor); purchaseInteraction.lastActivator = interactor; Util.PlaySound(UnlockSound, interactor.gameObject); EffectManager.SimpleEffect(UnlockEffect, chestObject.transform.position + offset, Quaternion.identity, true); } else { purchaseInteraction.cost = Mathf.CeilToInt(purchaseInteraction.cost * cfgPriceMultiplier.Value); //https://discord.com/channels/562704639141740588/562704639569428506/916819003064864788 purchaseInteraction.Networkcost = purchaseInteraction.cost; //weaver generated shit ^ selectedEffect = Fail_LockEffect; //purchaseInteraction.displayNameToken = (prefix + purchaseInteraction.displayNameToken); chestObject.AddComponent <BulletstormChestInteractorComponent>().hasUsedLockpicks = true; //does this even work? lol EffectManager.SimpleEffect(selectedEffect, chestObject.transform.position + offset, Quaternion.identity, true); } return(true); } else { return(false); } }
/// <summary> /// Sets the FixationData behavior on the global interactor and specifies the data mode /// to be used. /// <param name="interactor">Interactor object to be fitted with the interaction behavior.</param> /// <param name="fixationDataMode">Which fixation data mode to use.</param> /// </summary> private void AddFixationDataBehavior(Interactor interactor, FixationDataMode fixationDataMode) { var behavior = interactor.CreateBehavior(InteractionBehaviorType.FixationData); var behaviorParams = new FixationDataParams() { FixationDataMode = fixationDataMode }; behavior.SetFixationDataParams(ref behaviorParams); }
private Interactability PurchaseInteraction_GetInteractability(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { var gameObject = self.gameObject; Highlight highlight = gameObject.GetComponent <Highlight>(); BulletstormChestInteractorComponent bulletstormChestInteractor = gameObject.GetComponent <BulletstormChestInteractorComponent>(); if (bulletstormChestInteractor && bulletstormChestInteractor.hasUsedLockpicks) { if (highlight) { highlight.highlightColor = Highlight.HighlightColor.teleporter; } return(orig(self, activator)); } return(orig(self, activator)); }
public void OnInspectedUpdate(Interactor interactor) { }
internal string GenericPickupController_GetContextString(On.RoR2.GenericPickupController.orig_GetContextString orig, GenericPickupController self, Interactor activator) { PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex); string pickupText = string.Format(Language.GetString(((pickupDef != null) ? pickupDef.interactContextToken : null) ?? string.Empty), Language.GetString(pickupDef.nameToken)); if (pickupDef.itemIndex != ItemIndex.None) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); pickupText += $"\n\n{Language.GetString( mod.config.MiscPickupDescriptionAdvanced.Value ? itemDef.descriptionToken : itemDef.pickupToken)}"; } else if (pickupDef.equipmentIndex != EquipmentIndex.None) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); pickupText += $"\n\n{Language.GetString(mod.config.MiscPickupDescriptionAdvanced.Value ? equipmentDef.descriptionToken : equipmentDef.pickupToken)}"; } return(pickupText); }
public void OnHovered(Interactor by) { hoverBuffer = 2; SetIcon(deleteIcon); }
/// <summary> /// 编辑流程图 /// </summary> /// <param name="FlowID">流程图ID</param> /// <param name="data">元数据链表</param> /// <param name="manager">元数据管理器</param> /// <param name="flowVersion">绘图的版本号</param> /// <returns>是否编译成功</returns> public override bool GenerateCode(int FlowID, List <FlowChartMetaData> data, FlowChartMetaDataManager manager) { // 初始化数据 string[] dataArray = scriptPath.Split(new char[] { '\\' }); string shortPath = dataArray[1]; for (int i = 2; i < dataArray.Length; i++) { shortPath = shortPath + string.Format("\\{0}", dataArray[i]); } string fullPath = string.Format(@"{0}\scripts\Map\{1}\ai\{2}", rootDirectory.TrimEnd(new char[] { '\\' }), dataArray[0], shortPath); bool success = true; DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager(); customFunctionList.Clear(); // 初始化参数 StringBuilder code = new StringBuilder(); string initialStateName = CodeProviderClass.GetStateString(manager.GetEventData(1)); // 初态的变量名 List <FlowChartMetaData> metaDataList = manager.GetAllNodes(); List <FlowChartMetaData> stateList = new List <FlowChartMetaData>(); List <FlowChartMetaData> actionList = new List <FlowChartMetaData>(); Hashtable registActions = new Hashtable(); string sqlString = "SELECT actionid, parms FROM AI_Action_Define"; actionTable = dataBaseManager.GetDataTable(sqlString, dataBaseManager.Connection_Jx3web); foreach (FlowChartMetaData metaData in metaDataList) { switch (metaData.DataType) { case "AIStateNode": { stateList.Add(metaData); break; } case "AIActionNode": { actionList.Add(metaData); string[] information = CodeProviderClass.GetActionInformation(metaData.Data); int actionID = int.Parse(information[2]); if ((actionID == 0) || (actionID > 1000 && registActions[information[2]] == null)) // 注册自定义动作 { registActions[information[2]] = metaData; } break; } } } // 添加注释 code.AppendLine(string.Format("-- 编写者:{0}", Dns.GetHostName())); code.AppendLine(string.Format("-- 版本号:{0}", manager.Version)); code.AppendLine(); // 引用头文件 code.AppendLine("Include('scripts/ai/customFuctions.lua')"); code.AppendLine("Include('scripts/ai/AIParam.lua')"); code.AppendLine("Include('scripts/ai/argumentStrings.ls')"); code.AppendLine(); code.AppendLine("g_AIDebugInfo = {}"); code.AppendLine(); // 声明变量 code.AppendLine("-- 声明状态变量"); foreach (FlowChartMetaData stateNode in stateList) { string stateName = stateNode.Code; code.AppendLine(string.Format("local {0} = {1} -- {2}", stateName, stateNode.ID, stateNode.DisplayText)); } code.AppendLine(); // 生成自定义附加脚本 FlowChartInteractor it = Interactor.GetInteractor().CurrentFlowChartInteractor; string customCode = it.CustomText; if (customCode != null && customCode != "") { code.AppendLine("-- 自定义附加脚本"); code.AppendLine(string.Format("{0}", customCode)); code.AppendLine(); } // 写主方法 code.AppendLine("function Setup(ai)"); code.AppendLine(" local state"); code.AppendLine(" local action"); code.AppendLine(" local param = g_AIParam[ai.nAIType]"); code.AppendLine(); // 注册自定义动作 code.AppendLine(" -- 注册自定义动作"); foreach (object o in registActions.Values) { FlowChartMetaData actionNode = o as FlowChartMetaData; string[] information = CodeProviderClass.GetActionInformation(actionNode.Data); code.AppendLine(string.Format(" ai.RegisterUserAction({0}, '{1}')", information[2], information[0])); } code.AppendLine(); List <FlowChartMetaData> list = new List <FlowChartMetaData>(); GenerateCode(code, manager.GetEventNode(1), list); code.AppendLine(string.Format(" ai.SetInitState({0})", initialStateName)); code.AppendLine("end"); code.AppendLine(); // 调试方法定义 code.AppendLine("-- 调试方法"); code.AppendLine("function DebugOnCallAction(action_id)"); code.AppendLine(" Log('[AI] Call action: ' .. g_AIDebugInfo[action_id])"); code.AppendLine("end"); // 写本文件自定义脚本动作定义 if (customFunctionList.Count > 0) { code.AppendLine(); code.AppendLine("-- 本AI图内自定义脚本"); foreach (string s in customFunctionList) { code.AppendLine(string.Format("{0}", s)); code.AppendLine(); } } // 提取转换中文字符串 string scriptText = code.ToString(); scriptText = ConvertScriptText(scriptText); // 输出文件 string fileName = string.Format("{0}.lua", fullPath); saveFile(fileName, scriptText); string userActionScripts = dataBaseManager.GetUserActionContext(); fileName = Path.Combine(rootDirectory, @"scripts\ai\customFuctions.lua"); saveFile(fileName, userActionScripts); fileName = Path.Combine(rootDirectory, @"scripts\ai\argumentStrings.ls"); string lsContent = ConstructLSFile(); saveFile(fileName, lsContent); return(success); }
public override void OnTriggerPressed(Interactor interactor) { rb.isKinematic = true; transform.SetParent(interactor.transform, true); }
private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (!self.CanBeAffordedByInteractor(activator)) { return; } if (!GeneralHooks.IsMultiplayer()) { orig(self, activator); return; } if (self.costType == CostTypeIndex.None) { orig(self, activator); return; } var shop = self.GetComponent <ShopTerminalBehavior>(); #region Cauldronfix if (printerCosts.Contains(self.costType)) { if (ShareSuite.PrinterCauldronFixEnabled.Value) { var characterBody = activator.GetComponent <CharacterBody>(); var inventory = characterBody.inventory; var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex())?.itemIndex; if (item == null) { RoR2.Console.print("ShareSuite: PickupCatalog is null."); } else { inventory.GiveItem(item.Value); } orig(self, activator); ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(), shop.CurrentPickupIndex()); return; } } #endregion Cauldronfix #region EquipDronefix if (ShareSuite.EquipmentShared.Value) { if (self.costType == CostTypeIndex.Equipment) { var rng = self.GetComponent <Xoroshiro128Plus>(); var itemIndex = ItemIndex.None; var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType); if (shop) { itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex; } var payCostResults = costTypeDef.PayCost(self.cost, activator, self.gameObject, rng, itemIndex); if (payCostResults.equipmentTaken.Count >= 1) { orig(self, activator); EquipmentSharingHooks.RemoveAllUnBlacklistedEquipment(); return; } } } #endregion orig(self, activator); }
public void TargetDetected(Interactor interactor) { enemy.EnemyLogic.OnAggro(interactor); }
// Token: 0x06001E20 RID: 7712 RVA: 0x0006FBB0 File Offset: 0x0006DDB0 public string GetContextString(Interactor activator) { throw new NotImplementedException(); }
/// <summary> /// Assigns the behavior corresponding to the data stream type to an interactor. /// </summary> /// <param name="interactor">The global interactor to add the data stream behavior to.</param> protected override void AssignBehavior(Interactor interactor) { var behavior = interactor.CreateBehavior(BehaviorType.EyePositionData); behavior.Dispose(); }
private void AssignGazePointDataBehavior(string interactorId, Interactor interactor) { switch (_gazePointType) { case EyeXGazePointType.GazeUnfiltered: AddGazePointDataBehavior(interactor, GazePointDataMode.Unfiltered); break; case EyeXGazePointType.GazeLightlyFiltered: AddGazePointDataBehavior(interactor, GazePointDataMode.LightlyFiltered); break; case EyeXGazePointType.FixationSlow: AddFixationDataBehavior(interactor, FixationDataMode.Slow); break; case EyeXGazePointType.FixationSensitive: AddFixationDataBehavior(interactor, FixationDataMode.Sensitive); break; } }
public override void Interact(Interactor interactor) { isMoving = true; }
public override bool GetInteractable(Interactor interactor) { return(base.GetInteractable(interactor) && (co == null)); }
// Token: 0x06001E22 RID: 7714 RVA: 0x0006FBB0 File Offset: 0x0006DDB0 public void OnInteractionBegin(Interactor activator) { throw new NotImplementedException(); }
public void AssignBehavior(Interactor interactor) { var behaviorParams = new ActivatableParams { EnableTentativeFocus = IsTentativeFocusEnabled ? EyeXBoolean.True : EyeXBoolean.False }; interactor.CreateActivatableBehavior(ref behaviorParams); }
public Transform InteractIconPosition(InteractionType type, Interactor actor) { return(interactionPoint); }
/// <summary> /// Assigns the panning behavior to an interactor. /// </summary> /// <param name="interactor">The interactor.</param> public void AssignBehavior(Interactor interactor) { var parameters = new PannableParams { IsHandsFreeEnabled = EyeXBoolean.False, PanDirectionsAvailable = PanDirectionsAvailable, Profile = Profile }; interactor.CreatePannableBehavior(ref parameters); }
private CostTypeDef.PayCostResults CostTypeDef_PayCost(On.RoR2.CostTypeDef.orig_PayCost orig, CostTypeDef self, int cost, Interactor activator, GameObject purchasedObject, Xoroshiro128Plus rng, ItemIndex avoidedItemIndex) { var original = orig(self, cost, activator, purchasedObject, rng, avoidedItemIndex); //var copyList = new List<ItemIndex>(original.itemsTaken); if (self.itemTier != ItemTier.NoTier) { CostTypeDef.PayCostResults payCostResults = new CostTypeDef.PayCostResults(); for (int i = 0; i < cost; i++) { payCostResults.itemsTaken.Add(original.itemsTaken[0]); } /*for (int i = 0; i < original.itemsTaken.Count; i++) * { * original.itemsTaken[i] = original.itemsTaken[0]; * }*/ return(payCostResults); } return(original); }
public void AddInteractor(Interactor newInteractor) { interactors.Add(newInteractor); FindClosestInteractor(); }
// FOR INVOCATION public void AdvanceInvocationTask(Interactor intr, uint charIdx, int invokesToday, bool incrementInvokes) { this.AdvanceTask(intr, charIdx, TaskKind.Invocation, invokesToday, 0.0f, incrementInvokes, false); }
public void RemoveInteractor(Interactor newInteractor) { interactors.Remove(newInteractor); newInteractor.DeSelect(); FindClosestInteractor(); }
// Populates queue taking in to account last invoke times. public void Populate(Interactor intr, int charsMax, bool resetDay) { var now = DateTime.Now; for (uint charIdx = 0; charIdx < charsMax; charIdx++) { // ################################### INVOCATION ##################################### int invokesToday = intr.AccountStates.GetCharStateOr(charIdx, "invokesToday", 0); DateTime invokesCompletedOn = intr.AccountStates.GetCharStateOr(charIdx, "invokesCompleteFor", Global.Default.SomeOldDate); // Clear any stale invoke count: if (invokesCompletedOn < TodaysGameDate.AddDays(-1)) { invokesToday = 0; } DateTime mostRecentInvoke = intr.AccountStates.GetCharStateOr(charIdx, "mostRecentInvocationTime", now.AddHours(-24)); var invTaskMatureTime = CalculateTaskMatureTime(mostRecentInvoke, charIdx, TaskKind.Invocation, invokesToday, 0.0f); if (invokesToday >= 6) { if (invokesCompletedOn < TodaysGameDate) // START FRESH DAY { intr.AccountStates.SaveCharState(0, charIdx, "invokesToday"); invokesToday = 0; invTaskMatureTime = now; } else // DONE FOR THE DAY { invTaskMatureTime = NextThreeAmPst; } } if (resetDay) { intr.AccountStates.SaveCharState(0, charIdx, "invokesToday"); intr.AccountStates.SaveCharState(TodaysGameDate.AddDays(-1), charIdx, "mostRecentInvocationTime"); invokesToday = 0; invTaskMatureTime = now; } intr.Log(LogEntryType.Debug, "Adding invocation task to queue for character [{0}], matures: {1}.", charIdx, invTaskMatureTime); var invTask = new GameTask(mostRecentInvoke, invTaskMatureTime, charIdx, TaskKind.Invocation, invokesToday, 0.0f); intr.AccountStates.SaveCharTask(invTask); this.Add(invTask); // ################################## PROFESSIONS ##################################### // ################ Prune Stale Profession Tasks ################ //for (var p = 0; p < ProfessionTasksRef.ProfessionTaskNames.Length; p++) { // var settingKey = "MostRecentProfTime_" + p; // var oldTaskThreshold = now.AddDays(-2); // //DateTime profTaskMatureTime; // //if (DateTime.TryParse(intr.AccountStates.GetCharStateOr(charIdx, // // charSettingSection, ""), out profTaskMatureTime)) { // // intr.Log("Found " + settingKey + " for " + charSettingSection + " in ini file: " + // // profTaskMatureTime.ToString() + ".", LogEntryType.Debug); // // //// [TODO]: Is this necessary?: // // //if (profTaskMatureTime < oldTaskThreshold) { // // // intr.Log("Removing " + settingKey + " for " + charSettingSection + " from ini file.", LogEntryType.Debug); // // // intr.GameAccount.RemoveSetting(settingKey, charSettingSection); // // //} // //} // DateTime profTaskMatureTime = intr.AccountStates.GetCharStateOr(charIdx, // settingKey, Global.Default.SomeOldDate); //} // ################ Add Tasks to Queue ################ int tasksQueued = 0; for (var taskId = 0; taskId < ProfessionTasksRef.ProfessionTaskNames.Length; taskId++) { GameTask profTask; // Attempt to load from new task persistence system: if (!intr.AccountStates.TryGetCharTask(charIdx, TaskKind.Profession, taskId, out profTask)) { // Use old school system: var mostRecentTaskTime = intr.AccountStates.GetCharStateOr(charIdx, "MostRecentProfTime_" + taskId, Global.Default.SomeOldDate); DateTime profTaskMatureTime = CalculateTaskMatureTime(mostRecentTaskTime, charIdx, TaskKind.Profession, taskId, 0.0f); profTask = new GameTask(mostRecentTaskTime, profTaskMatureTime, charIdx, TaskKind.Profession, taskId, 0.0f); } intr.Log(LogEntryType.Info, "Adding profession task to queue for character [" + charIdx + "], matures: " + profTask.MatureTime.ToString() + ", taskId: " + taskId.ToString() + "."); this.Add(profTask); tasksQueued += 1; } intr.Log(LogEntryType.Info, "[" + tasksQueued.ToString() + "] profession tasks queued for character [" + charIdx + "]."); } }
public void FixedUpdate() { // Fix bunny hopping this.ai.localNavigator.SetFieldValue("walkFrustration", 0f); // Skip if no body object if (!this.master.GetBody()) { return; } // Check if body interactor has changed if (this.body != this.master.GetBody()) { body = master.GetBody(); bodyInteractor = master.GetBody().GetComponent <Interactor>(); } // Remove the default combat delay with ai if (this.stateMachine.state is Combat) { ((Combat)this.stateMachine.state).SetFieldValue("aiUpdateTimer", 0); } // Infinite tower override (Simulacrum) if (infiniteTowerRun) { InfiniteTowerRunLogic(); } else { // Use interactables if (CanInteract()) { // Check if stage has changed if (Stage.instance != this.currentStage || this.currentStage == null) { this.currentStage = Stage.instance; try { this.stageCache.Update(); } catch (Exception e) { Debug.LogError(e); } } // Clear this.ai.customTarget.gameObject = null; this.customTargetSkillDriver.minDistance = 0; // Pickups PickupItems(); // Check interactables CheckInteractables(); // Force custom skill driver if not in combat ForceCustomSkillDriver(); } else if (PlayerBotManager.allRealPlayersDead && PlayerBotManager.ContinueAfterDeath.Value) { // Clear this.ai.customTarget.gameObject = null; this.customTargetSkillDriver.minDistance = 0; // Force bot to use teleporter after player dies CheckTeleporter(); // Force custom skill driver if not in combat ForceCustomSkillDriver(); } } // Equipment if (!this.master.IsDeadAndOutOfLivesServer()) { ProcessEquipment(); } }
void RemoveInteractor(Interactor interactor) { Log.DebugFormat("Removing notification requests from {0}", interactor); var emptyNotifications = new List<string>(); foreach (var item in _cache) { if (item.Value.Notifiables.Contains(interactor)) { item.Value.Notifiables.Remove(interactor); if (item.Value.Notifiables.Count == 0) emptyNotifications.Add(item.Key); } } foreach (var topic in emptyNotifications) _cache.Remove(topic); }
/// <summary> /// Sets the GazePointData behavior on the global interactor and specifies the data mode /// to be used. /// <param name="interactor">Interactor object to be fitted with the interaction behavior.</param> /// <param name="gazePointDataMode">Which gaze point data mode to use.</param> /// </summary> private static void AddGazePointDataBehavior(Interactor interactor, GazePointDataMode gazePointDataMode) { var behavior = interactor.CreateBehavior(InteractionBehaviorType.GazePointData); var behaviorParams = new GazePointDataParams() { GazePointDataMode = gazePointDataMode }; behavior.SetGazePointDataParams(ref behaviorParams); }
/// <summary> /// Assigns the activatable behavior to an interactor. /// </summary> /// <param name="interactor">The interactor.</param> public void AssignBehavior(Interactor interactor) { var parameters = new ActivatableParams { EnableTentativeFocus = new EyeXBoolean(IsTentativeFocusEnabled).integerValue }; interactor.CreateActivatableBehavior(ref parameters); }
/// <summary> /// Does nothing. /// </summary> /// <param name="interactor">The interactor to do nothing with.</param> public void AssignBehavior(Interactor interactor) { // do nothing }