public void DeleteById(int id) { Desire delete = Get(id); delete.IsActive = false; claimDAL.Update(delete); }
public void assertParent(Desire desire) { if (desire.Parent == null) { desire.Parent = parent; } }
private List <Node> search(Node curNode, int depth) { Queue <Node> file = new Queue <Node>(); List <Node> visitedNode = new List <Node>(); file.Enqueue(curNode); depth = (int)Math.Pow(depth, 6); while (depth > 0 || Desire.desireReach(curNode)) { curNode = file.Dequeue(); if (!visitedNode.Contains(curNode)) { visitedNode.Add(curNode); foreach (Node nextNode in curNode.nextNode()) { file.Enqueue(nextNode); } depth--; } } return(file.ToList()); }
private void Complete() { AgentActor agent = this.Agent; agent.Animation.CrossFadeScreen(-1f); agent.ActivateNavMeshAgent(); agent.SetActiveOnEquipedItem(true); agent.SetStand(agent.Animation.RecoveryPoint, false, 0.0f, 0); agent.Animation.RecoveryPoint = (Transform)null; int desireKey = Desire.GetDesireKey(Desire.Type.H); agent.SetDesire(desireKey, 0.0f); agent.UpdateStatus(agent.ActionID, agent.PoseID); agent.ApplySituationResultParameter(31); agent.ClearItems(); agent.ClearParticles(); agent.ResetActionFlag(); if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null)) { agent.CurrentPoint.SetActiveMapItemObjs(true); agent.CurrentPoint.ReleaseSlot((Actor)agent); agent.CurrentPoint = (ActionPoint)null; agent.PrevActionPoint = agent.TargetInSightActionPoint; } agent.TargetInSightActionPoint = (ActionPoint)null; agent.SurprisePoseID = new PoseKeyPair?(); agent.Animation.EndIgnoreEvent(); agent.Animation.ResetDefaultAnimatorController(); }
private static void GetAddRate(ref float __result, int key, AgentActor __instance) { if (key == Desire.GetDesireKey(Desire.Type.Game) && InteractionRate.Value != 0) { __result = InteractionRate.Value; } }
protected virtual Intention Filter(Desire desire) { switch (desire) { case Desire.DEFEND_PROTEGE: foreach (Point p in this.getAASMAFramework().visiblePierres(this)) { if (Utils.SquareDistance(this.Location, p) <= this.DefenseDistance * this.DefenseDistance) { return(new Intention(desire, p)); } } // Debug.Write(this.InternalName + " is trying to defend no one"); return(new Intention(Desire.EMPTY)); case Desire.GO_TO_PROTEGE: if (!protege.IsEmpty) { return(new Intention(Desire.GO_TO_PROTEGE, protege)); } // Debug.Write(this.InternalName + " is trying to go to an inexistent AI"); return(new Intention(Desire.EMPTY)); case Desire.SEARCH_PROTEGE: return(new Intention(desire)); default: // Debug.WriteLine(this.InternalName + " built an empty intention"); return(new Intention(Desire.EMPTY)); } }
public override void DoActions() { // if (! (currentPlan.Count == 0 || Succeeded(currentIntention))) if (currentPlan.Count != 0) { Debug.WriteLine("doing actions; plan.count =" + currentPlan.Count); Execute(currentPlan); UpdateBeliefs(); if (Reconsider(currentIntention)) { Desire d = Options(); currentIntention = Filter(d); currentPlan = Plan(currentIntention); } } else { Debug.WriteLine("new plan"); UpdateBeliefs(); Desire d = Options(); currentIntention = Filter(d); currentPlan = Plan(currentIntention); } }
public IActionResult AddDesire([FromBody] DesireClaimerDto Input) { try { Desire desire = new Desire() { BidPrice = Input.BidPrice, RequestedImgUrl = Input.RequestedImgUrl, UserID = Input.UserID, Title = Input.Title, Description = Input.Description, Fullname = Input.Fullname, Adress = Input.Adress, EMail = Input.EMail, Phone = Input.Phone }; claimBLL.Insert(desire); return(Ok(new { message = "İstek gönderildi.", check = true })); } catch (Exception ex) { return(Ok(new { message = ex.Message, check = false })); } }
internal Task <MqttCommand> WaitForCommand(CommandMessage message, MessageId messageId, TimeSpan timeout) { lock (_desireLock) { MqttCommand maybeLoved = _unlovedCommands.Where(c => c.MessageId == messageId && c.CommandMessage == message).FirstOrDefault(); if (maybeLoved != null) { var tcs = new TaskCompletionSource <MqttCommand>(); tcs.SetResult(maybeLoved); return(tcs.Task); } else { MqttCommand result = null; ManualResetEvent wait = new ManualResetEvent(false); Desire d = new Desire(message, messageId, (MqttCommand cmd) => { result = cmd; wait.Set(); }); _desireCache.AddAndRemoveDuplicates(d); return(Task <MqttCommand> .Factory.StartNew(() => { wait.WaitOne(timeout); return result; })); } } }
public DesireLabel(Desire desire) : this() { this.desire = desire; label.Text = string.Format("{0} - {1}", desire.GainedAt, desire.Reason); }
private void Complete() { AgentActor agent = this.Agent; agent.UpdateStatus(agent.ActionID, agent.PoseID); int desireKey = Desire.GetDesireKey(Desire.Type.Sleep); agent.SetDesire(desireKey, 0.0f); this.OnCompletedStateTask(); if (Random.Range(0, 100) < 50) { agent.ChangeBehavior(Desire.ActionType.EndTaskSecondSleep); } else { agent.ActivateNavMeshAgent(); agent.SetActiveOnEquipedItem(true); agent.ClearItems(); agent.ClearParticles(); agent.Animation.EndStates(); agent.ResetActionFlag(); agent.SetDefaultStateHousingItem(); if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null)) { agent.CurrentPoint.SetActiveMapItemObjs(true); agent.CurrentPoint.ReleaseSlot((Actor)agent); agent.CurrentPoint = (ActionPoint)null; } agent.EventKey = (EventType)0; agent.PrevActionPoint = agent.TargetInSightActionPoint; agent.TargetInSightActionPoint = (ActionPoint)null; agent.AgentData.YobaiTrigger = false; } }
public DesireViewModel() { if (App.Current.Properties.TryGetValue("desire", out object desire)) { Desire des = JsonConvert.DeserializeObject <Desire>(desire.ToString()); Monday = StringToIntArray(des.Понедельник); Tuesday = StringToIntArray(des.Вторник); Wednesday = StringToIntArray(des.Среда); Thursday = StringToIntArray(des.Четверг); Friday = StringToIntArray(des.Пятница); Saturday = StringToIntArray(des.Суббота); Message = des.Message; } else { Monday = new int[] { 1, 1, 1, 1, 1 }; Tuesday = new int[] { 1, 1, 1, 1, 1 }; Wednesday = new int[] { 1, 1, 1, 1, 1 }; Thursday = new int[] { 1, 1, 1, 1, 1 }; Friday = new int[] { 1, 1, 1, 1, 1 }; Saturday = new int[] { 1, 1, 1, 1, 1 }; Message = ""; } }
public virtual TaskStatus OnUpdate() { float num1 = 0.0f; Desire.Type type = Desire.WithPlayerDesireTable[0]; if (this._withPlayer) { foreach (Desire.Type key in Desire.WithPlayerDesireTable) { float num2; if (this.Agent.AgentData.DesireTable.TryGetValue(Desire.GetDesireKey(key), out num2) && (double)num1 < (double)num2) { num1 = num2; type = key; } } } else { foreach (KeyValuePair <int, float> keyValuePair in this.Agent.AgentData.DesireTable) { if ((double)num1 < (double)keyValuePair.Value) { num1 = keyValuePair.Value; type = (Desire.Type)keyValuePair.Key; } } } if (type == Desire.Type.None) { return((TaskStatus)1); } return(type == this._desire ? (TaskStatus)2 : (TaskStatus)1); }
//Add method to build tree private List <EnumIA.Action> search(Node node) { List <Node> closedList = new List <Node>(); List <Node> openList = new List <Node>(); openList.Add(node); while (openList.Any()) { var curNode = selectNode(openList); openList.Remove(curNode); closedList.Add(node); if (Desire.desireReach(curNode) || curNode.Actions.Count > 9) { return(curNode.Actions); } foreach (var nNode in curNode.nextNode()) { if (!openList.Contains(nNode)) { openList.Add(nNode); } else if (nNode.Heuristic > curNode.Heuristic) { curNode = nNode; } } } return(null); }
public virtual TaskStatus OnUpdate() { int desireKey = Desire.GetDesireKey(this._key); float num1 = (float)Singleton <Resources> .Instance.GetDesireBorder(desireKey).Item2; float?desire = this.Agent.GetDesire(desireKey); if (!desire.HasValue) { return((TaskStatus)1); } float num2 = Random.Range(0.0f, num1); if (!this._compareDowner) { if (Mathf.Approximately(desire.Value, 0.0f)) { return((TaskStatus)1); } return((double)num2 <= (double)desire.Value ? (TaskStatus)2 : (TaskStatus)1); } if (Mathf.Approximately(desire.Value, num1)) { return((TaskStatus)1); } return((double)desire.Value <= (double)num2 ? (TaskStatus)2 : (TaskStatus)1); }
public void SynchronizeDataFromJson(JsonDto jto, Simulator sim) { var checkedProperties = new List <string>(); ValidateAndUpdateValueAsNeeded(nameof(Desire), checkedProperties, Desire.Guid, jto.Desire.Guid, () => _desire = sim.Desires.FindByGuid(jto.Desire.Guid) ?? throw new LPGException("Could not find a desire with the guid " + jto.Desire.Guid + " and the name " + jto.Desire.Name)); ValidateAndUpdateValueAsNeeded(nameof(DecayTime), checkedProperties, _decayTime, jto.DecayTime, () => _decayTime = jto.DecayTime); ValidateAndUpdateValueAsNeeded(nameof(SicknessDesire), checkedProperties, SicknessDesire, jto.Sicknessdesire, () => SicknessDesire = jto.Sicknessdesire); ValidateAndUpdateValueAsNeeded(nameof(Threshold), checkedProperties, Threshold, jto.Threshold, () => Threshold = jto.Threshold); ValidateAndUpdateValueAsNeeded(nameof(Weight), checkedProperties, Weight, jto.Weight, () => Weight = jto.Weight); ValidateAndUpdateValueAsNeeded(nameof(MinAge), checkedProperties, MinAge, jto.MinAge, () => MinAge = jto.MinAge); ValidateAndUpdateValueAsNeeded(nameof(MaxAge), checkedProperties, MaxAge, jto.MaxAge, () => MaxAge = jto.MaxAge); ValidateAndUpdateValueAsNeeded(nameof(Gender), checkedProperties, Gender, jto.Gender, () => Gender = jto.Gender); NeedsUpdate = true; ValidateAndUpdateValueAsNeeded(nameof(Guid), checkedProperties, Guid, jto.Guid, () => Guid = jto.Guid); CheckIfAllPropertiesWereCovered(checkedProperties, this); SaveToDB(); }
public JsonDto GetJson() { return(new JsonDto(Desire.GetJsonReference(), DecayTime, SicknessDesire, Threshold, Weight, MinAge, MaxAge, Gender, Guid)); }
public virtual TaskStatus OnUpdate() { AgentActor agent = this.Agent; int desireKey = Desire.GetDesireKey(this._key); float? desire = agent.GetDesire(desireKey); if (!desire.HasValue) { return((TaskStatus)1); } if ((double)desire.Value >= (double)this._migrationBorder) { float?motivation = agent.GetMotivation(desireKey); if (motivation.HasValue) { if ((double)motivation.Value >= (double)Singleton <Resources> .Instance.AgentProfile.ActiveMotivationBorder) { return((TaskStatus)2); } agent.SetDesire(desireKey, 0.0f); return((TaskStatus)1); } } return((TaskStatus)1); }
public void LoadFromDatabaseTest() { using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { var desires = new ObservableCollection <Desire>(); Desire.LoadFromDatabase(desires, db.ConnectionString, false); var subAffordances = new ObservableCollection <SubAffordance>(); var locations = new ObservableCollection <Location>(); var variables = new ObservableCollection <Variable>(); SubAffordance.LoadFromDatabase(subAffordances, db.ConnectionString, desires, false, locations, variables); var affordances = new ObservableCollection <Affordance>(); var affordanceSubAffordances = new ObservableCollection <AffordanceSubAffordance>(); var tbp = new ObservableCollection <TimeBasedProfile>(); var dateBasedProfiles = db.LoadDateBasedProfiles(); var timeLimits = db.LoadTimeLimits(dateBasedProfiles); var aic = new AllItemCollections(timeProfiles: tbp, timeLimits: timeLimits); DBBase.LoadAllFromDatabase(affordances, db.ConnectionString, Affordance.TableName, Affordance.AssignFields, aic, false, true); AffordanceSubAffordance.LoadFromDatabase(affordanceSubAffordances, db.ConnectionString, affordances, subAffordances, false); affordanceSubAffordances.Count.Should().BeGreaterThan(1); db.ClearTable(AffordanceSubAffordance.TableName); affordanceSubAffordances.Clear(); AffordanceSubAffordance.LoadFromDatabase(affordanceSubAffordances, db.ConnectionString, affordances, subAffordances, false); affordanceSubAffordances.Count.Should().Be(0); db.Cleanup(); } }
public virtual TaskStatus OnUpdate() { AgentActor agent = this.Agent; if (Object.op_Inequality((Object)agent.TargetInSightActionPoint, (Object)null)) { if (this._checkFollowType) { if (agent.TargetInSightActionPoint.AgentDateEventType.Contains(this._eventType)) { return((TaskStatus)2); } } else if (agent.TargetInSightActionPoint.AgentEventType.Contains(this._eventType)) { return((TaskStatus)2); } } if (Object.op_Equality((Object)this._destination, (Object)null)) { if (this._desireIfNotFound != Desire.Type.None) { int desireKey = Desire.GetDesireKey(this._desireIfNotFound); agent.SetDesire(desireKey, 0.0f); agent.ChangeBehavior((Desire.ActionType) this._modeIDIfNotFound); } return((TaskStatus)1); } agent.TargetInSightActionPoint = this._destination; agent.EventKey = this._eventType; this._destination.Reserver = (Actor)agent; return((TaskStatus)2); }
private void Complete() { AgentActor agent = this.Agent; agent.UpdateStatus(agent.ActionID, agent.PoseID); agent.CauseSick(); int desireKey = Desire.GetDesireKey(Desire.Type.Eat); agent.SetDesire(desireKey, 0.0f); agent.ApplyFoodParameter(agent.AgentData.CarryingItem); agent.AgentData.CarryingItem = (StuffItem)null; agent.ActivateNavMeshAgent(); agent.SetActiveOnEquipedItem(true); agent.Animation.EndStates(); agent.ClearItems(); agent.ClearParticles(); agent.ResetActionFlag(); agent.SetDefaultStateHousingItem(); if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null)) { agent.CurrentPoint.SetActiveMapItemObjs(true); agent.CurrentPoint.ReleaseSlot((Actor)agent); agent.CurrentPoint = (ActionPoint)null; } agent.EventKey = (EventType)0; agent.PrevActionPoint = agent.TargetInSightActionPoint; agent.TargetInSightActionPoint = (ActionPoint)null; }
public DesirePresenter([NotNull] ApplicationPresenter applicationPresenter, [NotNull] DesireView view, [NotNull] Desire desire) : base(view, "ThisDesire.HeaderString", desire, applicationPresenter) { _desire = desire; _usedIn = new ObservableCollection <UsedIn>(); RefreshUsedIn(); }
private void initializeAncDesires() { List <DesireType> desireTypes = Desire.GetRandomAncDesireTypes(numAncDesires); for (int i = 0; i < desireTypes.Count; i++) { DesireType type = desireTypes[i]; switch (type) { case DesireType.chill: chillDesireIdx = i; break; case DesireType.music: musicDesireIdx = i; break; case DesireType.nature: natureDesireIdx = i; break; case DesireType.science: scienceDesireIdx = i; break; case DesireType.exercise: exerciseDesireIdx = i; break; case DesireType.creative: creativeDesireIdx = i; break; case DesireType.community: communityDesireIdx = i; break; case DesireType.education: educationDesireIdx = i; break; case DesireType.spirituality: spiritualityDesireIdx = i; break; } ancDesires[i] = new Desire(type, 1); } }
private void Complete() { AgentActor agent = this.Agent; agent.UpdateStatus(agent.ActionID, agent.PoseID); int desireKey = Desire.GetDesireKey(Desire.Type.Sleep); agent.SetDesire(desireKey, 0.0f); agent.SetStatus(0, 50f); agent.HealSickBySleep(); this.Agent.ActivateNavMeshAgent(); this.Agent.SetActiveOnEquipedItem(true); agent.Animation.EndStates(); agent.ClearItems(); agent.ClearParticles(); if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null)) { agent.CurrentPoint.SetActiveMapItemObjs(true); agent.CurrentPoint.ReleaseSlot((Actor)agent); agent.CurrentPoint = (ActionPoint)null; } agent.EventKey = (EventType)0; agent.PrevActionPoint = agent.TargetInSightActionPoint; agent.TargetInSightActionPoint = (ActionPoint)null; }
/// <summary> /// Given an array of desires, gets the one of the highest value /// </summary> /// <param name="desireArr">The array of desires to pick from</param> /// <returns>The Desire that should next be addressed</returns> private Desire getDesireToAddress(Desire[] desireArr, List <DesireType> doNotSelect) { int largestIdx = -1; float largestVal = 0; bool wanted = false, needed = false; for (int i = 0; i < desireArr.Length; i++) { Desire desire = desireArr[i]; if (doNotSelect.Contains(desire.GetDesireType())) { continue; } else if (needed && !desire.IsNeeded()) { continue; } else if (wanted && !desire.IsWanted()) { continue; } wanted = desire.IsWanted(); needed = desire.IsNeeded(); if (desire.value >= largestVal) { largestIdx = i; largestVal = desire.value; } } if (largestIdx == -1) { return(null); } return(desireArr[largestIdx]); }
private static HHTDesire AssignFields([NotNull] DataReader dr, [NotNull] string connectionString, bool ignoreMissingFields, [NotNull] AllItemCollections aic) { var hhtDesireID = dr.GetIntFromLong("ID"); var householdTraitID = dr.GetIntFromLong("HouseholdTraitID"); var decayTime = dr.GetDecimal("DecayTime", false); var threshold = dr.GetDecimal("Threshold", false); var weight = dr.GetDecimal("Weight", false); var sicknessdesire = (HealthStatus)dr.GetIntFromLong("SicknessDesire", false); var mininumAge = dr.GetIntFromLong("MinimumAge", false); var maxAge = dr.GetIntFromLong("MaximumAge", false); var gender = (PermittedGender)dr.GetIntFromLong("Gender", false); var desireID = dr.GetNullableIntFromLong("DesireID", false); Desire desire = null; var name = "(no name)"; if (desireID != null) { desire = aic.Desires.FirstOrDefault(myDesire => myDesire.ID == desireID); } if (desire != null) { name = desire.Name; } var guid = GetGuid(dr, ignoreMissingFields); var hhad = new HHTDesire(hhtDesireID, householdTraitID, decayTime, desire, sicknessdesire, threshold, weight, connectionString, name, mininumAge, maxAge, gender, guid); return(hhad); }
private Intention Filter(Desire desire) { switch (desire) { case Desire.SEARCH_AZNPOINT: case Desire.SEARCH_NEEDLE: return(new Intention(desire, Point.Empty)); case Desire.GOTO_AZN: if (azn_points.Count > 0) { return(new Intention(desire, Utils.getNearestPoint(this.Location, azn_points))); } // Debug.WriteLine(this.InternalName + " tried to go to an empty azn point"); return(new Intention(Desire.EMPTY, Point.Empty)); case Desire.GOTO_NEEDLE: if (empty_needles.Count > 0) { return(new Intention(desire, Utils.getNearestPoint(this.Location, empty_needles))); } // Debug.WriteLine(this.InternalName + " tried to go to an inexistent needle"); return(new Intention(Desire.EMPTY, Point.Empty)); default: return(new Intention(Desire.EMPTY, Point.Empty)); } }
private void Complete() { AgentActor agent = this.Agent; agent.Animation.CrossFadeScreen(-1f); agent.SetStand(agent.Animation.RecoveryPoint, false, 0.0f, 0); agent.Animation.RecoveryPoint = (Transform)null; agent.ResetActionFlag(); if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null)) { agent.CurrentPoint.SetActiveMapItemObjs(true); agent.CurrentPoint.ReleaseSlot((Actor)agent); agent.CurrentPoint = (ActionPoint)null; agent.PrevActionPoint = agent.TargetInSightActionPoint; } agent.TargetInSightActionPoint = (ActionPoint)null; agent.SurprisePoseID = new PoseKeyPair?(); Desire.Type key; if (Desire.ModeTable.TryGetValue(agent.PrevMode, out key)) { int desireKey = Desire.GetDesireKey(key); agent.SetDesire(desireKey, 0.0f); } agent.Animation.ResetDefaultAnimatorController(); agent.ChaControl.SetClothesStateAll((byte)0); agent.ActivateNavMeshAgent(); }
public override Desire ResolveConflict(Desire other) { if (other is Migration) { return ResolveConflict((Migration) other); } else { return this; } }
public override Desire ResolveConflict(Desire other) { if (other is ThreatAvoidance) { return ResolveConflict((ThreatAvoidance) other); } else { return this; } }
protected override void OnCompletedStateTask() { AgentActor agent = this.Agent; int desireKey = Desire.GetDesireKey(Desire.Type.Toilet); agent.SetDesire(desireKey, 0.0f); agent.SurprisePoseID = new PoseKeyPair?(); }
public Trade(Trader seller, Settlement buyer, Vector3 position, Desire desire, int price) { this.seller = seller; this.buyer = buyer; this.position = position; this.desire = desire; this.price = price; }
public override bool ConflictsWith(Desire other) { return other is WallAvoidance; }
public override bool ConflictsWith(Desire other) { return other is Wander; }
private void updateDesires() { if (!sameTeam(agentBeliefs.playerWithDisk) && agentBeliefs.playerWithDisk != null) desire = Desire.TACKLE; else desire = Desire.SCORE; }
public override Desire ResolveConflict(Desire other) { return this; }
public override bool ConflictsWith(Desire other) { return other is Migration || other is Barricading || other is PlayerMovementCommand || other is Mobbing; }
public override bool ConflictsWith(Desire other) { return other is Mobbing || other is ThreatAvoidance; }
public override bool ConflictsWith(Desire other) { return other is Migration; }
public override bool ConflictsWith(Desire other) { throw new NotImplementedException(); }
public override Desire ResolveConflict(Desire other) { throw new NotImplementedException(); }
internal Task<MqttCommand> WaitForCommand(CommandMessage message, MessageId messageId, TimeSpan timeout) { lock (_desireLock) { var maybeLoved = _unlovedCommands.FirstOrDefault(c => c.MessageId == messageId && c.CommandMessage == message); if (maybeLoved != null) { var tcs = new TaskCompletionSource<MqttCommand>(); tcs.SetResult(maybeLoved); return tcs.Task; } MqttCommand result = null; var wait = new ManualResetEvent(false); var d = new Desire(message, messageId, cmd => { result = cmd; wait.Set(); }); _desireCache.AddAndRemoveDuplicates(d); return Task<MqttCommand>.Factory.StartNew(() => { wait.WaitOne(timeout); return result; }); } }