private void TagCrew()
        {
#if CLIENT
            GameMain.GameSession.CrewManager.GetCharacters().ForEach(c => ParentEvent.AddTarget(Tag, c));
#else
            TagPlayers(); TagBots(); //TODO: this seems like it would tag more than it should, fix
#endif
        }
Exemple #2
0
        private void TryStartConversation(Character speaker, Character targetCharacter = null)
        {
            IEnumerable <Entity> targets = Enumerable.Empty <Entity>();

            if (!string.IsNullOrEmpty(TargetTag))
            {
                targets = ParentEvent.GetTargets(TargetTag).Where(e => IsValidTarget(e));
                if (!targets.Any() || IsBlockedByAnotherConversation(targets))
                {
                    return;
                }
            }

            if (speaker?.AIController is HumanAIController humanAI)
            {
                prevIdleObjective = humanAI.ObjectiveManager.GetObjective <AIObjectiveIdle>();
                prevGotoObjective = humanAI.ObjectiveManager.GetObjective <AIObjectiveGoTo>();
                humanAI.SetForcedOrder(
                    Order.PrefabList.Find(o => o.Identifier.Equals("wait", StringComparison.OrdinalIgnoreCase)),
                    option: string.Empty, orderGiver: null);
                if (targets.Any())
                {
                    Entity closestTarget = null;
                    float  closestDist   = float.MaxValue;
                    foreach (Entity entity in targets)
                    {
                        float dist = Vector2.DistanceSquared(entity.WorldPosition, speaker.WorldPosition);
                        if (dist < closestDist)
                        {
                            closestTarget = entity;
                            closestDist   = dist;
                        }
                    }
                    if (closestTarget != null)
                    {
                        humanAI.FaceTarget(closestTarget);
                    }
                }
            }

            if (targetCharacter != null && !string.IsNullOrWhiteSpace(InvokerTag))
            {
                ParentEvent.AddTarget(InvokerTag, targetCharacter);
            }

            ShowDialog(speaker, targetCharacter);

            dialogOpened = true;
            if (speaker != null)
            {
                speaker.CampaignInteractionType = CampaignMode.InteractionType.None;
                speaker.SetCustomInteract(null, null);
#if SERVER
                GameMain.NetworkMember.CreateEntityEvent(speaker, new object[] { NetEntityEvent.Type.AssignCampaignInteraction });
#endif
            }
        }
Exemple #3
0
        private void TagCrew()
        {
#if CLIENT
            GameMain.GameSession.CrewManager.GetCharacters().ForEach(c => ParentEvent.AddTarget(Tag, c));
#else
            TagPlayers();
            TagBots(playerCrewOnly: true);
#endif
        }
Exemple #4
0
 private void TagHumansByIdentifier(string identifier)
 {
     foreach (Character c in Character.CharacterList)
     {
         if (c.Prefab?.Identifier.Equals(identifier, StringComparison.OrdinalIgnoreCase) ?? false)
         {
             ParentEvent.AddTarget(Tag, c);
         }
     }
 }
Exemple #5
0
        private void TryStartConversation(Character speaker, Character targetCharacter = null)
        {
            IEnumerable <Entity> targets = Enumerable.Empty <Entity>();

            if (!string.IsNullOrEmpty(TargetTag))
            {
                targets = ParentEvent.GetTargets(TargetTag).Where(e => IsValidTarget(e));
                if (!targets.Any() || IsBlockedByAnotherConversation(targets))
                {
                    return;
                }
            }

            if (speaker?.AIController is HumanAIController humanAI)
            {
                prevSpeakerOrder = null;
                if (humanAI.CurrentOrder != null)
                {
                    prevSpeakerOrder = new OrderInfo(humanAI.CurrentOrder, humanAI.CurrentOrderOption);
                }
                prevIdleObjective = humanAI.ObjectiveManager.GetObjective <AIObjectiveIdle>();
                prevGotoObjective = humanAI.ObjectiveManager.GetObjective <AIObjectiveGoTo>();
                humanAI.SetOrder(
                    Order.PrefabList.Find(o => o.Identifier.Equals("wait", StringComparison.OrdinalIgnoreCase)),
                    option: string.Empty, orderGiver: null, speak: false);
                if (targets.Any())
                {
                    Entity closestTarget = null;
                    float  closestDist   = float.MaxValue;
                    foreach (Entity entity in targets)
                    {
                        float dist = Vector2.DistanceSquared(entity.WorldPosition, speaker.WorldPosition);
                        if (dist < closestDist)
                        {
                            closestTarget = entity;
                            closestDist   = dist;
                        }
                    }
                    if (closestTarget != null)
                    {
                        humanAI.FaceTarget(closestTarget);
                    }
                }
            }

            if (targetCharacter != null && !string.IsNullOrWhiteSpace(InvokerTag))
            {
                ParentEvent.AddTarget(InvokerTag, targetCharacter);
            }

            ShowDialog(speaker, targetCharacter);

            dialogOpened = true;
        }