예제 #1
0
        partial void UpdateProjSpecific(float deltaTime, Camera cam)
        {
            if (info != null || health < maxHealth * 0.98f)
            {
                hudInfoTimer -= deltaTime;
                if (hudInfoTimer <= 0.0f)
                {
                    if (controlled == null)
                    {
                        hudInfoVisible = true;
                    }

                    //if the character is not in the camera view, the name can't be visible and we can avoid the expensive visibility checks
                    else if (WorldPosition.X < cam.WorldView.X || WorldPosition.X > cam.WorldView.Right ||
                             WorldPosition.Y > cam.WorldView.Y || WorldPosition.Y < cam.WorldView.Y - cam.WorldView.Height)
                    {
                        hudInfoVisible = false;
                    }
                    else
                    {
                        //Ideally it shouldn't send the character entirely if we can't see them but /shrug, this isn't the most hacker-proof game atm
                        hudInfoVisible = controlled.CanSeeCharacter(this);
                    }
                    hudInfoTimer = Rand.Range(0.5f, 1.0f);
                }
            }
        }
예제 #2
0
        static bool CheckSpeakerViability(Character potentialSpeaker, NPCConversation selectedConversation, List <Character> checkedSpeakers, bool ignoreFlags)
        {
            //check if the character has an appropriate job to say the line
            if ((potentialSpeaker.Info?.Job != null && potentialSpeaker.Info.Job.Prefab.OnlyJobSpecificDialog) || selectedConversation.AllowedJobs.Count > 0)
            {
                if (!selectedConversation.AllowedJobs.Contains(potentialSpeaker.Info?.Job.Prefab))
                {
                    return(false);
                }
            }

            //check if the character has all required flags to say the line
            if (!ignoreFlags)
            {
                var characterFlags = GetCurrentFlags(potentialSpeaker);
                if (!selectedConversation.Flags.All(flag => characterFlags.Contains(flag)))
                {
                    return(false);
                }
            }

            //check if the character is close enough to hear the rest of the speakers
            if (checkedSpeakers.Any(s => !potentialSpeaker.CanHearCharacter(s)))
            {
                return(false);
            }

            //check if the character is close enough to see the rest of the speakers (this should be replaced with a more performant method)
            if (checkedSpeakers.Any(s => !potentialSpeaker.CanSeeCharacter(s)))
            {
                return(false);
            }

            //check if the character has an appropriate personality
            if (selectedConversation.allowedSpeakerTags.Count > 0)
            {
                if (potentialSpeaker.Info?.PersonalityTrait == null)
                {
                    return(false);
                }
                if (!selectedConversation.allowedSpeakerTags.Any(t => potentialSpeaker.Info.PersonalityTrait.AllowedDialogTags.Any(t2 => t2 == t)))
                {
                    return(false);
                }
            }
            else
            {
                if (potentialSpeaker.Info?.PersonalityTrait != null &&
                    !potentialSpeaker.Info.PersonalityTrait.AllowedDialogTags.Contains("none"))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #3
0
        partial void UpdateProjSpecific(float deltaTime, Camera cam)
        {
            if (!IsDead && !IsUnconscious)
            {
                if (soundTimer > 0)
                {
                    soundTimer -= deltaTime;
                }
                else if (AIController != null)
                {
                    switch (AIController.State)
                    {
                    case AIController.AIState.Attack:
                        PlaySound(CharacterSound.SoundType.Attack);
                        break;

                    default:
                        PlaySound(CharacterSound.SoundType.Idle);
                        break;
                    }
                }
            }

            if (info != null || Vitality < MaxVitality * 0.98f)
            {
                hudInfoTimer -= deltaTime;
                if (hudInfoTimer <= 0.0f)
                {
                    if (controlled == null)
                    {
                        hudInfoVisible = true;
                    }

                    //if the character is not in the camera view, the name can't be visible and we can avoid the expensive visibility checks
                    else if (WorldPosition.X < cam.WorldView.X || WorldPosition.X > cam.WorldView.Right ||
                             WorldPosition.Y > cam.WorldView.Y || WorldPosition.Y < cam.WorldView.Y - cam.WorldView.Height)
                    {
                        hudInfoVisible = false;
                    }
                    else
                    {
                        //Ideally it shouldn't send the character entirely if we can't see them but /shrug, this isn't the most hacker-proof game atm
                        hudInfoVisible = controlled.CanSeeCharacter(this, controlled.ViewTarget == null ? controlled.WorldPosition : controlled.ViewTarget.WorldPosition);
                    }
                    hudInfoTimer = Rand.Range(0.5f, 1.0f);
                }
            }

            if (controlled == this)
            {
                CharacterHealth.UpdateHUD(deltaTime);
            }
        }