public void ConflictsAreDetected() { Cloud cloud_Mike = MikeSharesCloudWithRussell(); Thought thought_Mike = cloud_Mike.NewThought(); cloud_Mike.CentralThought = thought_Mike; thought_Mike.Text = "Initial value"; Synchronize(); Thought thought_Russell = _russellsIdentity.SharedClouds.Single().CentralThought; thought_Mike.Text = "Mike's change"; thought_Russell.Text = "Russell's change"; Synchronize(); Assert.IsTrue(thought_Mike.Text.InConflict); Assert.IsTrue(thought_Mike.Text.Candidates.Contains("Mike's change")); Assert.IsTrue(thought_Mike.Text.Candidates.Contains("Russell's change")); Assert.IsFalse(thought_Mike.Text.Candidates.Contains("Initial value")); Assert.IsTrue(thought_Russell.Text.InConflict); Assert.IsTrue(thought_Russell.Text.Candidates.Contains("Mike's change")); Assert.IsTrue(thought_Russell.Text.Candidates.Contains("Russell's change")); Assert.IsFalse(thought_Russell.Text.Candidates.Contains("Initial value")); }
public void RussellCanShareAThoughtWithMike() { Cloud cloud = MikeSharesCloudWithRussell(); Thought thought = cloud.NewThought(); cloud.CentralThought = thought; thought.Text = "Lunch suggestions"; Synchronize(); Cloud sharedCloud = _russellsIdentity.SharedClouds.Single(); Thought newThought = sharedCloud.NewThought(); newThought.Text = "Mi Pueblo"; Thought centralThought = sharedCloud.CentralThought; centralThought.LinkTo(newThought); Synchronize(); IEnumerable <Thought> suggestions = thought.Neighbors.Where(n => n != thought); Assert.AreEqual(1, suggestions.Count()); string suggestionText = suggestions.Single().Text; Assert.AreEqual("Mi Pueblo", suggestionText); }
public void UpdateThoughts() { update = false; Queue <Thought> delete = new Queue <Thought>(); if (locked) { Thought lockedThought = panels[lockedIndex].GetComponentInChildren <Option>().thought; foreach (Thought newThought in unUpdatedThoughts) { if (newThought.Text.Equals(lockedThought.Text)) { delete.Enqueue(newThought); } } } while (delete.Count > 0) { unUpdatedThoughts.Remove(delete.Dequeue()); } thoughts = new List <Thought>(unUpdatedThoughts); UpdateOptions(); }
public void ConflictsCanBeResolved() { Cloud cloud_Mike = MikeSharesCloudWithRussell(); Thought thought_Mike = cloud_Mike.NewThought(); cloud_Mike.CentralThought = thought_Mike; thought_Mike.Text = "Initial value"; Synchronize(); Thought thought_Russell = _russellsIdentity.SharedClouds.Single().CentralThought; thought_Mike.Text = "Mike's change"; thought_Russell.Text = "Russell's change"; Synchronize(); thought_Mike.Text = "Mike's resolution"; Synchronize(); Assert.IsFalse(thought_Mike.Text.InConflict); Assert.AreEqual("Mike's resolution", thought_Mike.Text.Value); Assert.IsFalse(thought_Russell.Text.InConflict); Assert.AreEqual("Mike's resolution", thought_Russell.Text.Value); }
public async Task <IActionResult> CreateThought([FromBody] Thought newThought) { try { if (ModelState.IsValid) { newThought.DateAdded = DateTime.UtcNow; newThought.DateModified = newThought.DateAdded; newThought.UserName = this.User.Identity.Name; _repo.CreateThought(newThought); if (await _repo.SaveAllAsync()) { return(Created($"/api/thoughts/{newThought.Id}", newThought)); } else { return(BadRequest("Faield to create thought in database.")); } } else { return(BadRequest(ModelState)); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static void ToggleMoodThoughtBubble(Pawn pawn, Thought thought, ref MoteBubble __result) { if (!bubblesEnabled) { __result = null; } }
IEnumerator TrainOfThought(Thought thought) { sRC++; isThinking = true; string[] allTexts = new string[] { thought.text }; if (thought.continuation != null && thought.continuation.Length > 0) { allTexts = new string[thought.continuation.Length + 1]; allTexts [0] = thought.text; for (int i = 0; i < thought.continuation.Length; i++) { allTexts [i + 1] = thought.continuation [i]; } } for (int i = 0; i < allTexts.Length; i++) { string text = allTexts [i]; float duration = 2.5f + text.Length / 16f; bubble.ShowThought(text, duration); float delay = Random.Range(delayBetweenChainedThoughtsMinMax.x, delayBetweenChainedThoughtsMinMax.y); if (i == allTexts.Length - 1) { delay = 0; } yield return(new WaitForSeconds(duration + delay)); } isThinking = false; nextThinkTime = Time.time + timeBetweenThoughts; nextAllowedRandomThoughtTime = Time.time + Random.Range(minTimeBetweenRandomThoughts, maxTimeBetweenRandomThoughts); }
public async Task <IActionResult> Edit(int id, [Bind("ThoughtId,ContentText,DateCreated,DateModified,ViewCount,UpvoteCount,DownvoteCount,LikeCount")] Thought thought) { if (id != thought.ThoughtId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(thought); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThoughtExists(thought.ThoughtId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(thought)); }
public override void Receive(ThoughtFocus thoughtFocus) { Thought original = thoughtFocus.MainThought; if (thoughtFocus.RemoveThought && original != null) { Remove(original); } Topic topic = null; if (thoughtFocus.Topic != null) { topic = topicsByName[thoughtFocus.Topic]; } if (topic != null && topic.MyStage.Equals(Topic.Stage.Hidden)) { ExitTo(topic, Topic.Stage.Orientation); } foreach (String tangent in thoughtFocus.Tangents) { //Debug.Log("\"" + tangent + "\""); Topic tangentialTopic = topicsByName[tangent]; ExitTo(tangentialTopic, Topic.Stage.Orientation); if (tangentialTopic.MyStage.Equals(Topic.Stage.Complication)) { ShiftFocusChange(tangentialTopic, tangentialTopic.Focus + 3f, true, thoughtFocus.FinalMultiplier); } } TopicHeard(topic, thoughtFocus); }
public void SetThought(Thought thought) { bubbleImage.gameObject.SetActive(true); iconImage.sprite = icons.Where(i => i.thought == thought) .Select(s => s.sprite) .FirstOrDefault(); }
private void ReadFields(Thought result, DataRow row) { result.Id = Utilities.GetIntFromRow(row, tableFieldID).Value; result.CreationDate = Utilities.GetDateWithTimeFromRow(row, tableFieldCREATION_DATE).Value; { result.ThoughtType = null; int?value = Utilities.GetIntFromRow(row, tableFieldID_THOUGHT_TYPE); if (value.HasValue) { result.ThoughtType = this.session.ThoughtTypeUtils.GetById(value.Value); } } result.Number = Utilities.GetIntFromRow(row, tableFieldNUMBER); result.Idea = Utilities.GetStringFromRow(row, tableFieldIDEA); result.Description = Utilities.GetStringFromRow(row, tableFieldDESCRIPTION); result.Note = Utilities.GetStringFromRow(row, tableFieldNOTE); }
public void TrapIn(Transform target) { state = State.Trapped; thought = Thought.Danger; transform.position = target.position + new Vector3(UnityEngine.Random.Range(-0.4f, 0.4f), UnityEngine.Random.Range(-0.1f, 0.5f)); AudioManager.instance.PlaySound("FallingIntoHole"); }
public bool TryDoRandomMoodCausedMentalBreak() { if (!this.CanDoRandomMentalBreaks || this.pawn.Downed || !this.pawn.Awake() || this.pawn.InMentalState) { return(false); } if (this.pawn.Faction != Faction.OfPlayer && this.CurrentDesiredMoodBreakIntensity != MentalBreakIntensity.Extreme) { return(false); } MentalBreakDef mentalBreakDef; if (!this.CurrentPossibleMoodBreaks.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(this.pawn), out mentalBreakDef)) { return(false); } Thought thought = this.RandomFinalStraw(); string text = "MentalStateReason_Mood".Translate(); if (thought != null) { text = text + "\n\n" + "FinalStraw".Translate(thought.LabelCap); } return(mentalBreakDef.Worker.TryStart(this.pawn, text, true)); }
public Breakup(Date date, Pawn pawn1, Pawn pawn2, Thought thought) { this.date = date; this.pawn1 = pawn1; this.pawn2 = pawn2; this.thought = thought; }
private static string CustomMoodNeedTooltip(Need_Mood mood) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(mood.GetTipString()); PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(mood, thoughtGroupsPresent); bool flag = false; for (int i = 0; i < thoughtGroupsPresent.Count; i++) { Thought group = thoughtGroupsPresent[i]; mood.thoughts.GetMoodThoughts(group, thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup); if (leadingThoughtInGroup.VisibleInNeedsTab) { if (!flag) { flag = true; stringBuilder.AppendLine(); } stringBuilder.Append(leadingThoughtInGroup.LabelCap); if (thoughtGroup.Count > 1) { stringBuilder.Append(" x"); stringBuilder.Append(thoughtGroup.Count); } stringBuilder.Append(": "); stringBuilder.AppendLine(mood.thoughts.MoodOffsetOfGroup(group).ToString("##0")); } } return(stringBuilder.ToString()); }
private static void Fan(Thought thought, Dictionary <Thought, Point> centerByThought, Point origin, double startRadians, double sweepRadians, int depth) { List <Thought> neighbors = thought.Neighbors .Distinct() .Where(n => !centerByThought.ContainsKey(n)) .ToList(); int step = 0; double arc = sweepRadians / (double)neighbors.Count; foreach (Thought neighbor in neighbors) { double theta = arc * ((double)step + 0.5) + startRadians; Point center = new Point( -HorizontalRadius * Math.Sin(theta) + origin.X, VerticalRadius * Math.Cos(theta) + origin.Y); centerByThought.Add(neighbor, center); ++step; } if (depth <= 3) { step = 0; foreach (Thought neighbor in neighbors) { Fan(neighbor, centerByThought, centerByThought[neighbor], arc * (double)step + startRadians, arc, depth + 1); ++step; } } }
private void CreateThoughtBubble(int index) { Destroy(newBubble); newBubble = Instantiate(thoughtPrefab, transform.position, Quaternion.identity); primaryBubble = newBubble.transform.GetChild(0).gameObject; firstBubble = newBubble.transform.GetChild(3).gameObject; joint.connectedBody = firstBubble.GetComponent <Rigidbody2D>(); joint.distance = 0.5f; joint.enabled = true; Vector2 randomDir = Random.insideUnitCircle * speed; randomDir = new Vector2(randomDir.x, Mathf.Abs(randomDir.y)); primaryBubble.GetComponent <Rigidbody2D>().AddForce(randomDir, ForceMode2D.Impulse); currentThought = thoughts[index]; ThoughtBubble bubble = newBubble.GetComponent <ThoughtBubble>(); bubble.timeBetweenImageChange = currentThought.timeBetweenImages; bubble.repeat = currentThought.repeat; bubble.images = currentThought.images; StartCoroutine(Delay(bubble.timeBetweenImageChange * bubble.images.Count + 1)); if (newBubble.GetComponent <SortingGroup>()) { newBubble.GetComponent <SortingGroup>().sortingLayerName = transform.parent.GetComponent <SortingGroup>().sortingLayerName; } }
// activate the menu with a countdown timer public void Activate(List <Thought> thoughts) { // right now we should only be displaying 3 thoughts if (thoughts.Count == 0) { Debug.Log("need at least 1 thought passed into thought menu"); } currentThought = thoughts[0]; runManager.runState.thoughtHistory.Add(currentThought); // freeze time and activate canvas // Time.timeScale = 0; canvas.SetActive(true); /*if (!nameText.activeSelf) * { * Flip(); * }*/ // nameText.GetComponent<TextMeshProUGUI>().color = currentThought.GetColor(); // nameText.GetComponent<TextMeshProUGUI>().text = currentThought.name; // descriptionText.GetComponent<TextMeshProUGUI>().text = currentThought.descriptionText; energyText.GetComponent <TextMeshProUGUI>().text = "-" + currentThought.energyCost.ToString(); int rejectCost = runManager.RejectThoughtCost(); rejectEnergyText.GetComponent <TextMeshProUGUI>().text = rejectCost == 0 ? "FREE" : "-" + rejectCost.ToString(); rejectLabelText.GetComponent <TextMeshProUGUI>().text = rejectCost == 0 ? "Let Go" : "Think"; rejectEnergyIcon.SetActive(rejectCost != 0); // jumpPowerText.GetComponent<TextMeshProUGUI>().text = currentThought.maxJumpPower.ToString();*/ // TODO: create a countdown timer to limit decision time? }
private void CreateSpeechBubble(Thought thought) { Destroy(newBubble); newBubble = Instantiate(speechPrefab, transform.position, Quaternion.identity); joint.connectedBody = newBubble.GetComponent <Rigidbody2D>(); joint.distance = 3f; joint.enabled = true; tail = newBubble.transform.GetChild(0).GetChild(1).GetChild(0); maintainTail = true; Vector2 randomDir = Random.insideUnitCircle * speed; randomDir = new Vector2(randomDir.x, Mathf.Abs(randomDir.y)); newBubble.GetComponent <Rigidbody2D>().AddForce(randomDir, ForceMode2D.Impulse); ThoughtBubble bubble = newBubble.GetComponent <ThoughtBubble>(); bubble.timeBetweenImageChange = thought.timeBetweenImages; bubble.repeat = thought.repeat; bubble.images = thought.images; if (transform.parent.GetComponent <SortingGroup>()) { newBubble.GetComponent <SortingGroup>().sortingLayerName = transform.parent.GetComponent <SortingGroup>().sortingLayerName; } if (thought == question) { bubble.onEnd += OnQuestionAsked; } }
void Update() { if (transform.parent.CompareTag("Goblin") && currentNPC) { if (Input.GetKeyDown(KeyCode.E)) { if (currentNPC.canBeAsked) { CreateSpeechBubble(question); StartCoroutine(Ask()); } else { Thought npcThought = currentNPC.GetComponent <ThoughtCreator>().thoughts[0]; CreateThoughtBubble(npcThought); } //CreateThoughtBubble(thoughtIndex); //CreateSpeechBubble(thoughtIndex); } } if (maintainTail && tail) { tail.position = transform.position; } }
public bool TryDoRandomMoodCausedMentalBreak() { if (!CanDoRandomMentalBreaks || pawn.Downed || !pawn.Awake() || pawn.InMentalState) { return(false); } if (pawn.Faction != Faction.OfPlayer && CurrentDesiredMoodBreakIntensity != MentalBreakIntensity.Extreme) { return(false); } if (QuestUtility.AnyQuestDisablesRandomMoodCausedMentalBreaksFor(pawn)) { return(false); } if (!CurrentPossibleMoodBreaks.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(pawn, moodCaused: true), out MentalBreakDef result)) { return(false); } Thought thought = RandomFinalStraw(); TaggedString taggedString = "MentalStateReason_Mood".Translate(); if (thought != null) { taggedString += "\n\n" + "FinalStraw".Translate(thought.LabelCap); } return(result.Worker.TryStart(pawn, taggedString, causedByMood: true)); }
protected bool TrySendLetter(Pawn pawn, string textKey, Thought reason) { bool result; if (!PawnUtility.ShouldSendNotificationAbout(pawn)) { result = false; } else { string label = "MentalBreakLetterLabel".Translate() + ": " + this.def.LabelCap; string text = textKey.Translate(new object[] { pawn.Label }).CapitalizeFirst(); if (reason != null) { text = text + "\n\n" + "FinalStraw".Translate(new object[] { reason.LabelCap }); } text = text.AdjustedFor(pawn, "PAWN"); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NegativeEvent, pawn, null, null); result = true; } return(result); }
/// <summary> /// Thread-safe version for vanilla. /// </summary> /// <param name="group"></param> /// <param name="handler"></param> /// <returns></returns> private float MoodOffsetOfGroup(Thought group, ThoughtHandler handler) { List <Thought> tmpThoughts = _thoughts.Value; handler.GetMoodThoughts(group, tmpThoughts); if (!tmpThoughts.Any()) { return(0f); } float totalMoodOffset = 0f; float effectMultiplier = 1f; float totalEffectMultiplier = 0f; foreach (Thought thought in tmpThoughts) { totalMoodOffset += thought.MoodOffset(); totalEffectMultiplier += effectMultiplier; effectMultiplier *= thought.def.stackedEffectMultiplier; } float num4 = totalMoodOffset / (float)tmpThoughts.Count; tmpThoughts.Clear(); return(num4 * totalEffectMultiplier); }
public static bool MoodOffsetOfGroup(ThoughtHandler __instance, ref float __result, Thought group) { List <Thought> tmpThoughts = new List <Thought>(); __instance.GetMoodThoughts(group, tmpThoughts); if (!tmpThoughts.Any <Thought>()) { __result = 0.0f; return(false); } float num1 = 0.0f; float num2 = 1f; float num3 = 0.0f; for (int index = 0; index < tmpThoughts.Count; ++index) { Thought tmpThought = tmpThoughts[index]; if (null != tmpThought) { num1 += tmpThought.MoodOffset(); num3 += num2; num2 *= tmpThought.def.stackedEffectMultiplier; } } double num4 = (double)num1 / (double)tmpThoughts.Count; tmpThoughts.Clear(); double num5 = (double)num3; __result = (float)(num4 * num5); return(false); }
// Update is called once per frame void Update() { Thought thought = thoughtMenu.currentThought; if (thought == null) { // freeze when thought is chosen, and still jumping if (!player.grounded) { gameObject.GetComponent <SpriteRenderer>().enabled = true; transform.position = previousPosition; } else { gameObject.GetComponent <SpriteRenderer>().enabled = false; } return; } gameObject.GetComponent <SpriteRenderer>().enabled = true; float zeroY = runManager.runState.height; float minY = zeroY + ActivityPlatform.PowerToYDiff(thought.minJumpPower); float maxY = zeroY + ActivityPlatform.PowerToYDiff(thought.maxJumpPower + 1); float range = maxY - minY; float period = .5f; // number of seconds per cycle // move position up and down until thought has been chosen, then freeze float offset = range == 0 ? 0 : (Time.time * range / period) % range; transform.position = new Vector2(transform.parent.position.x - 0.3f, minY + offset - ActivityPlatform.platformThickness); previousPosition = transform.position; }
private FocusedThought FocusThought(Thought thought) { FocusedThought focusedThought = new FocusedThought(thought, 0f, 0f); Appraise(focusedThought); return(focusedThought); }
public async Task <IActionResult> AddThought(ThoughtViewModel model) { if (!ModelState.IsValid) { return(View(model)); } _logger.LogInformation("Adding thought!"); var distinctTags = model.Tags.Split(',').Distinct(); model.Tags = string.Join(",", distinctTags); var thought = new Thought { Content = model.Content, CreatedAt = DateTime.Now, Tags = model.Tags, TagsDelimiter = ',', Views = 0 }; await _context.Thoughts.AddAsync(thought); await _context.SaveChangesAsync(); _logger.LogInformation("Thought added!", thought); return(RedirectToAction("GetSpecificThought", "Home", new { id = thought.Id })); }
public async Task <IActionResult> EditThought(int id, [FromBody] Thought updatedThought) { if (ModelState.IsValid) { if (updatedThought.UserName == this.User.Identity.Name && id == updatedThought.Id) { try { updatedThought.DateModified = DateTime.UtcNow; _repo.EditThought(updatedThought); if (await _repo.SaveAllAsync()) { return(NoContent()); } else { return(BadRequest("Error manipulating database.")); } } catch (Exception ex) { return(BadRequest(ex)); } } else { return(Unauthorized()); } } return(BadRequest(ModelState)); }
public static void Postfix(Thought __instance, ref float __result) { if (__instance.def == ThoughtDefOf.Naked && __instance.pawn.HasTrait(VTEDefOf.VTE_Prude)) { __result *= 2f; } if (__instance.def == VTEDefOf.SmokeleafHigh && __instance.pawn.HasTrait(VTEDefOf.VTE_Stoner)) { __result *= 2f; } if (__instance.def == VTEDefOf.Inebriated && __instance.pawn.HasTrait(VTEDefOf.VTE_Lush)) { __result *= 2f; } if (__instance.pawn.HasTrait(VTEDefOf.VTE_RefinedPalate)) { if (__instance.def == ThoughtDefOf.AteFineMeal || __instance.def.defName == "VCE_AteFineDessert") { __result = 0; } else if (__instance.def == ThoughtDefOf.AteLavishMeal || __instance.def.defName == "VCE_AteGourmetMeal" || __instance.def.defName == "VCE_AteLavishDessert") { __result *= 1.5f; } } if (TryGainMemory_Patch.animalThoughtDefs.Contains(__instance.def) && __instance.pawn.HasTrait(VTEDefOf.VTE_AnimalLover)) { __result *= 2f; } if (__instance.def == ThoughtDefOf.KilledMyRival && __instance.pawn.HasTrait(VTEDefOf.VTE_Vengeful)) { __result *= 2f; } }
public static bool NewInteracted(InteractionWorker_Breakup __instance, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { /* If you want to patch this method, you can stuff it. */ Thought thought = __instance.RandomBreakupReason(initiator, recipient); if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient)) { initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient); initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient); recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator); recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator); initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried); recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried); initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient); recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator); } else { initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient); initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient); if (PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.PsychologyEnabled(recipient)) { BreakupHelperMethods.AddExLover(initiator, recipient); //AddExLover(realRecipient, realInitiator); BreakupHelperMethods.AddBrokeUpOpinion(recipient, initiator); BreakupHelperMethods.AddBrokeUpMood(recipient, initiator); BreakupHelperMethods.AddBrokeUpMood(initiator, recipient); } else { initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient); recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator); recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator); } } if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed) { Pawn pawn = (Rand.Value >= 0.5f) ? recipient : initiator; pawn.ownership.UnclaimBed(); } TaleRecorder.RecordTale(TaleDefOf.Breakup, new object[] { initiator, recipient }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("LetterNoLongerLovers".Translate(initiator, recipient)); if (thought != null) { stringBuilder.AppendLine(); stringBuilder.AppendLine("FinalStraw".Translate(thought.CurStage.label)); } if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient)) { Find.LetterStack.ReceiveLetter("LetterLabelBreakup".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, initiator, null); } return(false); }
/// <summary> /// Clear the head from thoughts /// </summary> public void Clear() { Thought pos = _head; _head = null; while(pos != null && pos.Next != null) { pos.Next.Unlink(pos); pos = pos.Next; } }
public ThoughtTwin(double prior) { priorBelief = prior; for (int i = 0; i < N; i++) { thoughts[i] = new Thought(priorBelief); thoughts[i].OpinionChanged += ThoughtTwin_OpinionChanged; } }
public void queueThought(Thought thought) { SpeechEntry entry = new ThoughtSpeechEntry(thought); Debug.Log("Add thought: " + thought.getDescription()); this.textQueue.Add(entry); // Generate and show the bubble Bubble bubble = this.genBubble(); entry.setBubble(bubble); }
public bool IsContraryForThought(Thought thought) { if(thought == null) return false; foreach(PickableObject pickable in thought.ContraryObjects) { if(pickable.Type == Type) return true; } return false; }
public void Merge(Thought.vCards.vCard card) { this.DisplayName = card.GivenName + " " + card.FamilyName; if (card.EmailAddresses.Count > 0) this.Email = card.EmailAddresses.First().Address; var workPhones = card.Phones.Where(x => x.IsCellular); if (workPhones.Count() > 0) this.MobilePhone = workPhones.First().FullNumber; var msgPhones = card.Phones.Where(x => x.IsWork); if (msgPhones.Count() > 0) this.OfficePhone = msgPhones.First().FullNumber; }
/// <summary> /// Remove a thought from the head /// </summary> /// <param name="thought"></param> public void Remove(Thought thought) { if(_head == thought) { _head = _head.Next; } else { Thought pos = _head; while(pos != null && pos.Next != thought) { pos = pos.Next; } if(pos != null && pos.Next == thought) { thought.Unlink(pos); } } }
public ActionResult Convert(Thought thought, string outcome) { var newToDo = new Todo { Title = thought.Name, Outcome = outcome, Topic = Topic.Topics.Find(t => t.Id == thought.Topic.Id ) }; CreateTodo(newToDo); Thought.Thoughts.RemoveAll( thoughtToRemove => thoughtToRemove.Name == thought.Name); return RedirectToAction("Process", "Thought"); }
public ThoughtSpeechEntry(Thought thought) { this.thought = thought; }
public bool thoughtOk(Thought thought) { return true; }
void Awake() { thought = GetComponentInChildren<Thought>(); moveControl = GetComponent<NavMeshAgent>(); moveControl.avoidancePriority = Random.Range(1, 100); supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>(); spawner = GameObject.FindGameObjectWithTag("Entrance").GetComponent<Spawner>(); gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUI>(); listeners = new List<ICustomerStateListener>(); // Find selectionCollider colliders = GetComponentsInChildren<Collider>(); foreach (Collider collider in colliders) { if (collider.tag == "Interactor") { selectionCollider = collider; break; } } }
/// <summary> /// Requeues the thought /// </summary> /// <param name="time"></param> /// <param name="thought"></param> public void Requeue(double time, Thought thought) { thought.TriggerTime = (int)(_time + time *10); thought.AutoLink(ref _head); }
/// <summary> /// Requeues the thought with a delta timer /// </summary> /// <param name="delta"></param> /// <param name="thought"></param> public void RequeueDelta(double delta, Thought thought) { thought.TriggerTime += (int)(delta*10); thought.AutoLink(ref _head); }
public override Thought Think() { Thought thought = new Thought(); GamepadState state = GamePad.GetState(whichController); thought.duck = state.LeftStickAxis.y < -0.1f ? -state.LeftStickAxis.y : 0; thought.jump = state.A; thought.run = Math.Min(Math.Max(state.LeftStickAxis.x + state.dPadAxis.x, -1.0f), 1.0f); if(state.X && isTalking == 0) { thought.talk = UnityEngine.Random.Range(0, racerJokes.Length); } return thought; }
public override Thought Think() { Thought thought = new Thought(); thought.duck = 0; thought.jump = false; thought.run = 0.25f; if(isTalking == 0 && Time.realtimeSinceStartup - timeToTalk > timeDontTalk) { thought.talk = UnityEngine.Random.Range(1, 19); timeToTalk = Time.realtimeSinceStartup; timeDontTalk = UnityEngine.Random.Range(10.0f, 15.0f); } return thought; }
void Talk(Thought thought) { if (thought.talk > 0 && thought.talk != brain.isTalking) { talkBubble = new GameObject (); Sprite talkSprite = Resources.Load<Sprite> ("Art/Effects/speechbubble"); SpriteRenderer spriteRenderer = talkBubble.AddComponent<SpriteRenderer> (); spriteRenderer.sprite = talkSprite; brain.isTalking = thought.talk; talkBubble.name = "talkBubble"; Destroy(talkBubble, talkStayTime); talkBubble.transform.position = new Vector2 (gameObject.transform.position.x, gameObject.transform.position.y + 20); talkBubble.transform.localScale = new Vector2(1.1f, 1.1f); talkText = new GameObject (); talkText.transform.position = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y /*+ 20*/, -5.0f); Destroy(talkText, talkStayTime); //talkText.renderer.material.color = Color.black; //talkText.transform.localScale = new Vector2(10, 10); MeshRenderer meshRenderer = talkText.AddComponent<MeshRenderer>(); TextMesh talkLayer = talkText.AddComponent<TextMesh> (); //meshRenderer.material = (Resources.Load("Livingst") as Material); talkText.renderer.material = Resources.Load("arialbd", typeof(Material)) as Material; talkLayer.text = GenerateTalkText(); talkLayer.anchor = TextAnchor.LowerCenter; talkLayer.fontSize = 16; //20; talkLayer.characterSize = 2.0f; talkLayer.renderer.material.color = Color.black; Font myFont = Resources.Load("arialbd", typeof(Font)) as Font; talkLayer.font = myFont; } if (talkBubble) { talkBubble.transform.position = new Vector2 (gameObject.transform.position.x, gameObject.transform.position.y + 20); talkText.transform.position = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y +13/*+ 20*/, -5.0f); } else { brain.isTalking = 0; } }
void Run(Thought thought) { Rigidbody2D rbody = GetComponent<Rigidbody2D>(); float currVelX = thought.run; if(runSprite && OnGround()) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = runSprite; } rbody.velocity = new Vector2((currVelX + 1.0f) * maxRunSpeed, rbody.velocity.y); myTransform.eulerAngles = new Vector3(0, 0, -rbody.velocity.x/3); }
void Jump(Thought thought) { if (thought.jump) { if (jumpSprite) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = jumpSprite; } Rigidbody2D rbody = GetComponent<Rigidbody2D>(); rbody.velocity = new Vector2(rbody.velocity.x, jumpSpeed); anim.SetTrigger ("Jump"); // choose random jump sound // int jumpSound = (int)UnityEngine.Random.Range(0.0f, 3.9f); Vector3 camPos = GameObject.Find("Main Camera").transform.position; switch (jumpSound) { case 0: AudioSource.PlayClipAtPoint(racerJump1, camPos); break; case 1: AudioSource.PlayClipAtPoint(racerJump2, camPos); break; case 2: AudioSource.PlayClipAtPoint(racerJump3, camPos); break; case 3: AudioSource.PlayClipAtPoint(racerJump4, camPos); break; } // ; } onGround = false; }
float Duck(Thought thought) { if (slideSprite && thought.duck > 0.5f) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = slideSprite; } //myTransform.localScale = new Vector3(startScale.x * (1.0f + thought.duck), startScale.y * (1.0f - thought.duck/2), startScale.z); Rigidbody2D rbody = GetComponent<Rigidbody2D>(); rbody.velocity = new Vector2(rbody.velocity.x, rbody.velocity.y + Physics2D.gravity.y*thought.duck); return thought.duck; }
public AvegaContact(Thought.vCards.vCard card) { Merge(card); }
private void StartDriving() { // Set up driving thinker AddAction( 0, 1, time => { if((time % 6) != 0) { UpdateAngle(); UpdatePosition(); } else { float dx, dy; Angles.AngleToDirection(Angle, out dx, out dy); float ahead = 0.0f; // Find where the navigation wants us to go next. int bx = ((int)(X+dx*ahead))/32; int by = ((int)(Y+dy*ahead))/32; if(_game.Navigation.IsBlocked(bx,by)) { bx = ((int)X)/32; by = ((int)Y)/32; } int nextx, nexty; _game.Navigation.FollowStraightPath((int)X,(int)Y, out nextx, out nexty); bool isTarget = _game.Navigation.IsTarget(bx, by); _targetLine.X = X; _targetLine.Y = Y; _targetLine.X2 = nextx; _targetLine.Y2 = nexty; // The vehicle will try to point toward this lookahead point. Currently it's just // the center of the "next" cell. _targetAngle = Util.DeltasToAngle(nextx-X, nexty-Y); _angleDampening += (_targetAngle-_angleDampening) * 0.1f; _angleDampening2 += (_angleDampening-_angleDampening2) * 0.1f; Angle = ((int)(Angle + (_angleDampening2-Angle) * 0.1f)) & 4095; float lastx = X, lasty = Y; UpdatePosition(); var tooCloseObjects =_game.FindObjectsWithinRadius(this,lastx,lasty,40,typeof(Vehicle)); var closeObjects =_game.FindObjectsWithinRadius(this,lastx,lasty,55,typeof(Vehicle)); var closeObjects2 =_game.FindObjectsWithinRadius(this,X,Y,55,typeof(Vehicle)); float colliderDist = float.MaxValue; Vehicle collider = null; foreach(var gob2 in closeObjects2) { foreach(var gob in closeObjects) { if(gob.Object == gob2.Object && gob2.Distance < gob.Distance && gob2.Distance < colliderDist) { collider = (Vehicle)gob2.Object; colliderDist = gob2.Distance; } } } bool iWillDriveAnyway = true; //if(tooCloseObjects. != 0) { int thisMuchOnCourse = Math.Abs(Angles.Difference(Angle,_targetAngle)); foreach(var tco in tooCloseObjects) { var v = (Vehicle)tco.Object; if(v.CurrentThought != Thought.Stopping && Math.Abs(Angles.Difference(v.Angle, _targetAngle)) < thisMuchOnCourse) { iWillDriveAnyway = false; break; } } if(!iWillDriveAnyway) { _targetSpeed = 0; CurrentThought = Thought.Stopping; } } if(iWillDriveAnyway) { if(collider != null) { if(collider.MaxSpeed <= MaxSpeed) { CurrentThought = Thought.Slowing; _targetSpeed = ((Vehicle)collider).Speed; } } else { // Accelerate to reach max velocity and stay there (currently). _targetSpeed = Math.Min(MaxSpeed, _targetSpeed + Acceleration); CurrentThought = Thought.Normal; } } Speed = Util.Lerp(Speed, _targetSpeed, 0.1f); if((time % 10) == 0) { // SpawnDust(); } if(isTarget) { _game.AddObject(new Explosion(_game, X, Y, ExplosionType.Smoky)); _game.RemoveObject(this); return false; } } return true; }); }
/// <summary> /// Executes the thoughts work /// </summary> public void Work() { while(true) { int time = _time; Thought head; Thought pos; pos = head = _head; head = _head = Thought.UnlinkJob(_head, time); if(pos == head) { Thread.Sleep(10); continue; } while(pos != null) { Thought next = pos.Next; pos.Unlink(null); try { pos.Trigger(); } catch(Exception e) { ServerConsole.WriteLine(System.Drawing.Color.Red,"Exception in timed callback: {0}", e.Message); if(e.StackTrace != null) { ServerConsole.WriteLine(System.Drawing.Color.Red,e.StackTrace); } ServerConsole.WriteLine(""); } pos = next; } _time = Math.Min(_time, time+5); Thread.Sleep(10); } }
public void chainThought(Thought t) { this.nextThought = t; }
public bool thoughtOk(Thought thought) { return _sinfulThoughts.Contains(thought.ThoughtType); }
public void addThought(Thought t) { this.thoughts.Add(t); this.think (t); }
public void removeThought(Thought t) { this.thoughts.Remove(t); }
/// <summary> /// Recalculates entities in view for each entitie. /// </summary> /// <param name="thought"></param> /// <param name="Params"></param> public static void UpdateEntitiesInView(Thought thought, object[] Params) { lock (typeof(ServerWorld)) { foreach (WorldEntity entity in Entities.Values) { entity.UpdateEntitiesInView(false); } } //requeue Thinker.Requeue(1, thought); }
public void think(Thought t) { this.GetComponent<Speech>().queueThought(t); }