public void ProcessMessage(AIMessageSuspicionFound message, AIMemory memSender) { var memInfo = memory.GetSuspicionWithBaseTransform <InformationAlive>(message.Info.BaseTransform); if (memInfo != null) { if (memInfo.UpdateTime < message.Info.UpdateTime) { memInfo.Update(message.Info.lastKnownPosition.Value, memInfo.lastKnownPosition.Confidence); } } else { var n = new InformationSuspicion(message.Info); //n.SuspicionFirm = 1; //n.IsSure = true; memory.Add(n); } }
public void OnAudioAdded(AudioEventMonoB mb, AudioSource audSrc, Transform owner, AudioEventMonoB.AudioType audType) { if (owner != null && (owner == ai.Transform || ai.Memory.isFriend(owner))) { return; } mb.onAudioPlaying += OnPlayingAudio; var info = ai.Memory.GetSuspicionWithBaseTransform <InformationSuspicion>(owner); if (info != null) { currentlyListeningSources.Add(new ListeningSourceVar(info, owner ? owner : audSrc.transform, audSrc)); } else { // Create info InformationSuspicion newInfo = new InformationSuspicion("Unknown source Audio", audSrc.transform.position, 0); ai.Memory.Add(newInfo); // Add to listened infos for quick access currentlyListeningSources.Add(new ListeningSourceVar(newInfo, owner ? owner : audSrc.transform, audSrc)); } }
public override bool CanActivate(AIBrain ai) { checkingInfo = ai.Memory.Items.OfType <InformationSuspicion>().Where(x => /*!x.IsSure &&*/ !x.LastPositionChecked).OrderByDescending(x => x.UpdateTime).FirstOrDefault(); bool retVal = false; if (checkingInfo != null) { infoCheckPositions = ai.GetSensor <SensorRandPosAroundGtor>().RequestAllInfo(checkingInfo.lastKnownPosition.Value); } if (infoCheckPositions != null) { retVal = true; if (infoCheckPositions.Count > maxRandCheckPos) { infoCheckPositions.RemoveAll(x => infoCheckPositions.IndexOf(x) >= maxRandCheckPos); } } if (retVal) { checkingInfo.IsBeingUsed = true; } return(retVal); }
public ListeningSourceVar(InformationSuspicion _info, Transform _ownerOrAudSrc, AudioSource _audioSource) { info = _info; transformId = _ownerOrAudSrc; audioSource = _audioSource; }