Exemplo n.º 1
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.CoverState);

        if (prop.GetCoverState() == E_CoverState.None)
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    public override void CalculateGoalRelevancy()
    {
        GoalRelevancy = 0;

        if (Owner.BlackBoard.MotionType != E_MotionType.None)
        {
            return;
        }

        // Do not enter the cover once player is either aiming or shooting
        //if (Owner.BlackBoard.Desires.WeaponTriggerOn || Owner.BlackBoard.Desires.WeaponTriggerUp)
        if (Owner.BlackBoard.Desires.WeaponTriggerOn)
        {
            Hack_DisableGoalForOneMoreTick = true;
            return;
        }
        else
        {
            //FIXME: This nasty hack is required in a special situation when we need to postpone entering into for one extra tick.
            // This time it solves the problem when player gets close to a cover while aiming (with OSG or Shitstorm weapon)
            // and releases the fire button to shoot. Without the hack the player would enter into the cover and thus
            // there would be no shot fired. (becasue the fire is processed later in the same tick)
            if (Hack_DisableGoalForOneMoreTick)
            {
                Hack_DisableGoalForOneMoreTick = false;
                return;
            }
        }

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.CoverState);

        if (prop == null || prop.GetCoverState() != E_CoverState.None || Owner.BlackBoard.Desires.CoverNear.Cover == null)
        {
            return;
        }

        // no cover during reloading - BUG #283 - Missing animation of reloading when player is sprinting against cover
        WeaponBase Weapon = Owner.WeaponComponent.GetCurrentWeapon();

        if (null != Weapon)
        {
            if (Weapon.IsBusy())
            {
                return;
            }
        }

        GoalRelevancy = Owner.BlackBoard.GoapSetup.CoverRelevancy;
        Owner.BlackBoard.Desires.CoverSelected = Owner.BlackBoard.Desires.CoverNear.Cover;
    }
Exemplo n.º 3
0
    public override void CalculateGoalRelevancy()
    {
        GoalRelevancy = 0;

        if (Owner.CanFire() == false)
        {
            //Debug.Log(Time.timeSinceLevelLoad + "goal can NOT fire");
            return;
        }

        if (Owner.BlackBoard.Desires.WeaponTriggerOn == false)
        {
            //xxxx
            //Debug.Log(Time.timeSinceLevelLoad + "goal trigger false");
            return;             // musi mit zmacknuty trigger
        }

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.CoverState);

        if (prop.GetCoverState() == E_CoverState.Middle)
        {
            if (Owner.BlackBoard.Cover.CoverFlags.Get(Cover.E_CoverFlags.UpCrouch) == false)
            {
                // Debug.Log(Time.timeSinceLevelLoad + "goal bad cover");
                return;                 //je uprostred ale nemuze strilet pres cover
            }
        }
        else if (prop.GetCoverState() != E_CoverState.Edge)
        {
            //Debug.Log(Time.timeSinceLevelLoad + "goal not possible");
            return;             // neni na kraji
        }

        GoalRelevancy = Owner.BlackBoard.GoapSetup.KillTargetRelevancy;

        //Debug.Log(Time.timeSinceLevelLoad + "goal ok " + GoalRelevancy);
    }
Exemplo n.º 4
0
    public void SetWSProperty(WorldStateProp other)
    {
        if (other == null)
        {
            return;
        }

        switch (other.PropType)
        {
        case E_PropType.Bool:
            SetWSProperty(other.PropKey, other.GetBool());
            break;

        case E_PropType.Int:
            SetWSProperty(other.PropKey, other.GetInt());
            break;

        case E_PropType.Float:
            SetWSProperty(other.PropKey, other.GetFloat());
            break;

        case E_PropType.Vector:
            SetWSProperty(other.PropKey, other.GetVector());
            break;

        case E_PropType.Agent:
            SetWSProperty(other.PropKey, other.GetAgent());
            break;

        case E_PropType.CoverState:
            SetWSProperty(other.PropKey, other.GetCoverState());
            break;

        default:
            Debug.LogError("error in SetWSProperty " + other.PropKey.ToString());
            break;
        }
    }
Exemplo n.º 5
0
    void DrawBase()
    {
        AgentDebugInfo debugInfo = target as AgentDebugInfo;
        AgentHuman     agent     = debugInfo.GetComponent <AgentHuman>();

        if (agent.Transform == null)
        {
            return;
        }

        BlackBoard bb = agent.BlackBoard;

        GUILayout.BeginVertical();
        //GUILayout.Label("Base Settings", "OL Title" );
        ShowBase = EditorGUILayout.Foldout(ShowBase, "Base Setings ");

        if (ShowBase && agent.WeaponComponent)
        {
            EditorGUILayout.FloatField("Health ", bb.Health, GUILayout.Width(250), GUILayout.ExpandWidth(false));
            EditorGUILayout.EnumPopup("Weapon", agent.WeaponComponent.CurrentWeapon, GUILayout.Width(250), GUILayout.ExpandWidth(false));

            EditorGUILayout.ObjectField("Melee Target ", bb.Desires.MeleeTarget, typeof(GameObject), true, GUILayout.Width(250), GUILayout.ExpandWidth(false));
        }

        GUILayout.Space(10);
        GUILayout.EndVertical();


        GUILayout.BeginVertical();
        MoveInfo = EditorGUILayout.Foldout(MoveInfo, "Move info ");

        if (MoveInfo)
        {
            EditorGUILayout.EnumPopup("Motion", agent.BlackBoard.MotionType, GUILayout.Width(250), GUILayout.ExpandWidth(false));
            EditorGUILayout.EnumPopup("Move", agent.BlackBoard.MoveType, GUILayout.Width(250), GUILayout.ExpandWidth(false));
            EditorGUILayout.FloatField("Speed ", agent.BlackBoard.Speed, GUILayout.Width(250), GUILayout.ExpandWidth(false));
            EditorGUILayout.Vector3Field("Rotation", agent.Forward, GUILayout.Width(250), GUILayout.ExpandWidth(false));
            EditorGUILayout.Vector3Field("Fire Dir", agent.BlackBoard.FireDir, GUILayout.Width(250), GUILayout.ExpandWidth(false));
        }

        GUILayout.Space(10);
        GUILayout.EndVertical();

        GUILayout.BeginVertical();
        ShowGoap = EditorGUILayout.Foldout(ShowGoap, "Goap Manager ");

        if (ShowGoap)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", "OL Title", GUILayout.Width(100));
            GUILayout.Label("Relevancy", "OL Title", GUILayout.Width(60));
            GUILayout.Label("Enabled", "OL Title", GUILayout.Width(60));
            GUILayout.EndHorizontal();

            foreach (E_GOAPGoals key in System.Enum.GetValues(typeof(E_GOAPGoals)))
            {
                GOAPGoal goal = agent.GetGOAPGoal(key);
                if (goal == null)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();

                if (goal.Active)
                {
                    GUILayout.Label(goal.GoalType.ToString(), EditorStyles.whiteLabel, GUILayout.Width(100), GUILayout.ExpandWidth(false));
                }
                else
                {
                    GUILayout.Label(goal.GoalType.ToString(), GUILayout.Width(100), GUILayout.ExpandWidth(false));
                }

                EditorGUILayout.LabelField(goal.GoalRelevancy.ToString(), "", GUILayout.Width(60), GUILayout.ExpandWidth(false));
                EditorGUILayout.LabelField((goal.IsDisabled() == false).ToString(), "", GUILayout.Width(60), GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.Space(10);

        GUILayout.EndVertical();


        GUILayout.BeginVertical();
        ShowWorldState = EditorGUILayout.Foldout(ShowWorldState, "World States ");

        if (ShowWorldState && agent.WorldState != null)
        {
            for (E_PropKey key = E_PropKey.Start; key < E_PropKey.Count; key++)
            {
                if (agent.WorldState == null)
                {
                    continue;
                }

                WorldStateProp prop = agent.WorldState.GetWSProperty(key);

                if (prop == null)
                {
                    continue;
                }

                switch (prop.PropType)
                {
                case E_PropType.Bool:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetBool().ToString(), GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                case E_PropType.Int:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetBool().ToString(), GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                case E_PropType.Float:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetFloat().ToString(), GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                case E_PropType.Vector:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetVector().ToString(), GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                case E_PropType.Agent:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetAgent().name, GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                case E_PropType.CoverState:
                    EditorGUILayout.LabelField(prop.PropName, prop.GetCoverState().ToString(), GUILayout.Width(250), GUILayout.ExpandWidth(false));
                    break;

                default:
                    Debug.LogError("Unknow prop type " + prop.PropType);
                    break;
                }
            }
        }
        GUILayout.Space(10);
        GUILayout.EndVertical();

        GUILayout.BeginVertical();

        ShowAnim = EditorGUILayout.Foldout(ShowAnim, "Animations");

        if (ShowAnim && agent.AnimComponent != null)
        {
            EditorGUILayout.LabelField("Current State: ", agent.AnimComponent.CurrentAnimState != null? agent.AnimComponent.CurrentAnimState.ToString() : " none", GUILayout.Width(250), GUILayout.ExpandWidth(false));


            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", "OL Title", GUILayout.Width(200));
            GUILayout.Label("Layer", "OL Title", GUILayout.Width(40));
            GUILayout.Label("Weight", "OL Title", GUILayout.Width(100));
            GUILayout.Label("Time", "OL Title", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            if (Application.isPlaying)
            {
                foreach (AnimationState state in agent.GetComponent <Animation>())
                {
                    if (agent.GetComponent <Animation>().IsPlaying(state.clip.name) == false)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Label(state.name, GUILayout.Width(200), GUILayout.ExpandWidth(false));

                    EditorGUILayout.LabelField(state.layer.ToString(), "", GUILayout.Width(40), GUILayout.ExpandWidth(false));
                    EditorGUILayout.LabelField(state.weight.ToString(), "", GUILayout.Width(100), GUILayout.ExpandWidth(false));
                    EditorGUILayout.LabelField(state.time.ToString(), "", GUILayout.Width(100), GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                }
            }
        }
        GUILayout.Space(10);

        GUILayout.EndVertical();

/*
 *      GUILayout.BeginVertical();
 *      EditorGUI.indentLevel++;
 *      GUILayout.Label("User Settings", "OL Title");
 *      interaction.EntryTransform = EditorGUILayout.ObjectField("Entry position", interaction.EntryTransform, typeof(Transform), true, GUILayout.Width(250), GUILayout.ExpandWidth(false)) as Transform;
 *      interaction.LeaveTransform = EditorGUILayout.ObjectField("Leave position", interaction.LeaveTransform, typeof(Transform), true, GUILayout.Width(250), GUILayout.ExpandWidth(false)) as Transform;
 *      interaction.UserAnimationClip = EditorGUILayout.ObjectField("User animation", interaction.UserAnimationClip, typeof(AnimationClip), false, GUILayout.Width(250), GUILayout.ExpandWidth(false)) as AnimationClip;
 *      EditorGUI.indentLevel--;
 *      GUILayout.EndVertical();
 *
 *      GUILayout.BeginVertical();
 *      EditorGUI.indentLevel++;
 *      GUILayout.Label("Cutscene Settings", "OL Title");
 *      interaction.CutsceneCamera = EditorGUILayout.ObjectField("Camera", interaction.CutsceneCamera, typeof(GameObject), true, GUILayout.Width(250), GUILayout.ExpandWidth(false)) as GameObject;
 *      interaction.CameraAnim = EditorGUILayout.ObjectField("Animation", interaction.CameraAnim, typeof(AnimationClip), true, GUILayout.Width(250), GUILayout.ExpandWidth(false)) as AnimationClip;
 *      interaction.FadeInTime= EditorGUILayout.FloatField("Fade In", interaction.FadeInTime, GUILayout.Width(250), GUILayout.ExpandWidth(false));
 *      interaction.FadeOutTime = EditorGUILayout.FloatField("Fade out", interaction.FadeOutTime, GUILayout.Width(250), GUILayout.ExpandWidth(false));
 *      EditorGUI.indentLevel--;
 *      GUILayout.EndVertical();*/
    }