public ScenesWindowPlayerMovement(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor,
                                          params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, sceneEditor, aOptions)
        {
            new PlayerInitialPositionComponent(Rect.zero, new GUIContent(), null);
            new SideComponent(Rect.zero, new GUIContent(), null);
            PreviewTitle        = "PlayerMovement.Preview".Traslate();
            trajectoryComponent = new TrajectoryComponent(Rect.zero, new GUIContent(), null)
            {
                Action = -1
            };
            if (Controller.Instance.PlayerMode == DescriptorData.MODE_PLAYER_3RDPERSON)
            {
                // Creating this component registers it in the scene editor
                new InfluenceComponent(Rect.zero, new GUIContent(""), aStyle);
            }

            sceneEditor.TypeEnabling[typeof(Player)] = false;
            sceneEditor.TypeEnabling[typeof(TrajectoryDataControl)] = false;
            sceneEditor.TypeEnabling[typeof(SideDataControl)]       = false;
            sceneEditor.TypeEnabling[typeof(NodeDataControl)]       = false;

            tools = new GUIContent[]
            {
                new GUIContent("SceneEditor.PlayerTrajectory.None"),
                new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/nodeEdit"), "SceneEditor.PlayerTrajectory.Edit"),
                new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/sideEdit"), "SceneEditor.PlayerTrajectory.AddSide"),
                new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/selectStartNode"), "SceneEditor.PlayerTrajectory.StartNode"),
                new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/deleteTool"), "SceneEditor.PlayerTrajectory.Delete")
            };
        }
        /// <summary>
        /// Returns a verified <see cref="IQuantity"/> from <paramref name="results"/>
        /// corresponding to the <paramref name="component"/>.
        /// </summary>
        /// <param name="results"></param>
        /// <param name="component"></param>
        /// <returns>A verified <see cref="IQuantity"/> component.</returns>
        public static IQuantity Verify(this IReadOnlyDictionary <TrajectoryComponent, IQuantity> results,
                                       TrajectoryComponent component)
        {
            Assert.That(results.ContainsKey(component), "Expected {{{0}}} component.", component);
            var qty = results[component];

            Assert.That(qty, Is.Not.Null);
            return(qty);
        }
    public static void OnSpy()
    {
        bool flag = TrajectoryComponent.Highlighted != null;

        if (flag)
        {
            TrajectoryComponent.RemoveHighlight(TrajectoryComponent.Highlighted);
        }
        TrajectoryComponent.spying = true;
    }
        /// <summary>
        /// Tries to verify that <paramref name="results"/> contains the <paramref name="component"/>.
        /// Optionally provide whether such an item is <paramref name="expected"/>.
        /// </summary>
        /// <param name="results"></param>
        /// <param name="component"></param>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static bool TryVerify(this IReadOnlyDictionary <TrajectoryComponent, IQuantity> results,
                                     TrajectoryComponent component, bool?expected = null)
        {
            var tried = results.ContainsKey(component);

            if (expected != null)
            {
                Assert.That(tried, Is.EqualTo(expected.Value));
            }

            return(tried);
        }
Exemple #5
0
 private void setEnginTrajectoryFromEditor(Trajectory tra, TrajectoryED traED)
 {
     if (tra != null)
     {
         tra.relToCharFrame  = traED.characterFrameRelative;
         tra.noReverseStance = traED.noReverseStance;
         for (int j = 0; j < tra.getTrajectoryComponentCount(); j++)
         {
             TrajectoryComponent com = tra.getTrajectoryComponent(j);
             com.offset = traED.component[j].offset;
             com.reverseAngleOnLeftStance  = traED.component[j].reverseAngleOnLeftStance;
             com.reverseAngleOnRightStance = traED.component[j].reverseAngleOnRightStance;
             if (Mathf.Abs(traED.component[j].balance.cd) > 0 || Mathf.Abs(traED.component[j].balance.cv) > 0)
             {
                 com.bFeedback = new LinearBalanceFeedback();
                 com.bFeedback.feedbackProjectionAxis = traED.component[j].balance.feedbackProjectionAxis;
                 com.bFeedback.cd         = traED.component[j].balance.cd;
                 com.bFeedback.cv         = traED.component[j].balance.cv;
                 com.bFeedback.reversedCD = traED.component[j].balance.reversedCD;
                 com.bFeedback.reversedCV = traED.component[j].balance.reversedCV;
                 com.bFeedback.dMin       = traED.component[j].balance.dMin;
                 com.bFeedback.dMax       = traED.component[j].balance.dMax;
                 com.bFeedback.vMin       = traED.component[j].balance.vMin;
                 com.bFeedback.vMax       = traED.component[j].balance.vMax;
             }
             else
             {
                 com.bFeedback = null;
             }
             com.baseTraj.clear();
             for (int i = 0; i < traED.component[j].baseTrajectory.Length; i++)
             {
                 com.baseTraj.addKnot(traED.component[j].baseTrajectory[i].t, traED.component[j].baseTrajectory[i].angle);
             }
         }
     }
 }
Exemple #6
0
    private void setEditorStateFromEngine(TrajectoryED traED, Trajectory tra)
    {
        if (tra != null)
        {
            traED.characterFrameRelative = tra.relToCharFrame;
            traED.noReverseStance        = tra.noReverseStance;
            traED.component = new ComponentED[tra.getTrajectoryComponentCount()];
            for (int j = 0; j < tra.getTrajectoryComponentCount(); j++)
            {
                TrajectoryComponent com = tra.getTrajectoryComponent(j);
                traED.component[j]        = new ComponentED();
                traED.component[j].offset = com.offset;
                traED.component[j].reverseAngleOnLeftStance  = com.reverseAngleOnLeftStance;
                traED.component[j].reverseAngleOnRightStance = com.reverseAngleOnRightStance;
                if (com.bFeedback != null)
                {
                    traED.component[j].balance = new BalanceED();
                    traED.component[j].balance.feedbackProjectionAxis = com.bFeedback.feedbackProjectionAxis;
                    traED.component[j].balance.cd         = com.bFeedback.cd;
                    traED.component[j].balance.cv         = com.bFeedback.cv;
                    traED.component[j].balance.reversedCD = com.bFeedback.reversedCD;
                    traED.component[j].balance.reversedCV = com.bFeedback.reversedCV;
                    traED.component[j].balance.dMin       = com.bFeedback.dMin;
                    traED.component[j].balance.dMax       = com.bFeedback.dMax;
                    traED.component[j].balance.vMin       = com.bFeedback.vMin;
                    traED.component[j].balance.vMax       = com.bFeedback.vMax;
                }
                else
                {
                    traED.component[j].balance = new BalanceED();
                    traED.component[j].balance.feedbackProjectionAxis = Vector3.right;
                    traED.component[j].balance.cd         = 0;
                    traED.component[j].balance.cv         = 0;
                    traED.component[j].balance.reversedCD = false;
                    traED.component[j].balance.reversedCV = false;
                    traED.component[j].balance.dMin       = -100;
                    traED.component[j].balance.dMax       = 100;
                    traED.component[j].balance.vMin       = -100;
                    traED.component[j].balance.vMax       = 100;
                }
                traED.component[j].baseTrajectory = new TrajectoryDataED[com.baseTraj.getKnotCount()];
                for (int i = 0; i < com.baseTraj.getKnotCount(); i++)
                {
                    traED.component[j].baseTrajectory[i]       = new TrajectoryDataED();
                    traED.component[j].baseTrajectory[i].t     = com.baseTraj.getKnotPosition(i);
                    traED.component[j].baseTrajectory[i].angle = com.baseTraj.getKnotValue(i);
                }
            }
        }
        else
        {
            traED.characterFrameRelative = false;
            traED.noReverseStance        = false;
            traED.component           = new ComponentED[1];
            traED.component[0]        = new ComponentED();
            traED.component[0].offset = 0;
            traED.component[0].reverseAngleOnLeftStance  = false;
            traED.component[0].reverseAngleOnRightStance = false;

            traED.component[0].balance = new BalanceED();
            traED.component[0].balance.feedbackProjectionAxis = Vector3.right;
            traED.component[0].balance.cd         = 0;
            traED.component[0].balance.cv         = 0;
            traED.component[0].balance.reversedCD = false;
            traED.component[0].balance.reversedCV = false;
            traED.component[0].balance.dMin       = -100;
            traED.component[0].balance.dMax       = 100;
            traED.component[0].balance.vMin       = -100;
            traED.component[0].balance.vMax       = 100;
            traED.component[0].baseTrajectory     = new TrajectoryDataED[0];
        }
    }
    public void OnGUI()
    {
        Player mainPlayer = OptimizationVariables.MainPlayer;
        object obj;

        if (mainPlayer == null)
        {
            obj = null;
        }
        else
        {
            PlayerEquipment equipment = mainPlayer.equipment;
            obj = ((equipment != null) ? equipment.useable : null);
        }
        UseableGun useableGun = obj as UseableGun;
        bool       flag       = useableGun == null || TrajectoryComponent.spying || !WeaponOptions.EnableBulletDropPrediction || !Provider.modeConfigData.Gameplay.Ballistics;

        if (flag)
        {
            bool flag2 = TrajectoryComponent.Highlighted != null;
            if (flag2)
            {
                TrajectoryComponent.RemoveHighlight(TrajectoryComponent.Highlighted);
                TrajectoryComponent.Highlighted = null;
            }
        }
        else
        {
            List <Vector3> list   = TrajectoryComponent.PlotTrajectory(useableGun, out RaycastHit raycastHit, 255);
            bool           flag3  = Vector3.Distance(list.Last <Vector3>(), OptimizationVariables.MainPlayer.look.aim.position) > useableGun.equippedGunAsset.range;
            ColorVariable  color  = ColorUtilities.getColor("_TrajectoryPredictionInRange");
            ColorVariable  color2 = ColorUtilities.getColor("_TrajectoryPredictionOutOfRange");
            bool           flag4  = WeaponOptions.HighlightBulletDropPredictionTarget && raycastHit.collider != null;
            if (flag4)
            {
                Transform  transform  = raycastHit.transform;
                GameObject gameObject = null;
                bool       flag5      = DamageTool.getPlayer(transform) != null;
                if (flag5)
                {
                    gameObject = DamageTool.getPlayer(transform).gameObject;
                }
                else
                {
                    bool flag6 = DamageTool.getZombie(transform) != null;
                    if (flag6)
                    {
                        gameObject = DamageTool.getZombie(transform).gameObject;
                    }
                    else
                    {
                        bool flag7 = DamageTool.getAnimal(transform) != null;
                        if (flag7)
                        {
                            gameObject = DamageTool.getAnimal(transform).gameObject;
                        }
                        else
                        {
                            bool flag8 = DamageTool.getVehicle(transform) != null;
                            if (flag8)
                            {
                                gameObject = DamageTool.getVehicle(transform).gameObject;
                            }
                        }
                    }
                }
                bool flag9 = gameObject != null;
                if (flag9)
                {
                    Highlighter highlighter = gameObject.GetComponent <Highlighter>() ?? gameObject.AddComponent <Highlighter>();
                    bool        flag10      = !highlighter.enabled;
                    if (flag10)
                    {
                        highlighter.occluder = true;
                        highlighter.overlay  = true;
                        highlighter.ConstantOnImmediate(flag3 ? color2 : color);
                    }
                    bool flag11 = TrajectoryComponent.Highlighted != null && highlighter != TrajectoryComponent.Highlighted;
                    if (flag11)
                    {
                        TrajectoryComponent.RemoveHighlight(TrajectoryComponent.Highlighted);
                    }
                    TrajectoryComponent.Highlighted = highlighter;
                }
                else
                {
                    bool flag12 = TrajectoryComponent.Highlighted != null;
                    if (flag12)
                    {
                        TrajectoryComponent.RemoveHighlight(TrajectoryComponent.Highlighted);
                        TrajectoryComponent.Highlighted = null;
                    }
                }
            }
            else
            {
                bool flag13 = !WeaponOptions.HighlightBulletDropPredictionTarget && TrajectoryComponent.Highlighted != null;
                if (flag13)
                {
                    TrajectoryComponent.RemoveHighlight(TrajectoryComponent.Highlighted);
                    TrajectoryComponent.Highlighted = null;
                }
            }
            ESPComponent.GLMat.SetPass(0);
            GL.PushMatrix();
            GL.LoadProjectionMatrix(OptimizationVariables.MainCam.projectionMatrix);
            GL.modelview = OptimizationVariables.MainCam.worldToCameraMatrix;
            GL.Begin(2);
            GL.Color(flag3 ? color2 : color);
            foreach (Vector3 vector in list)
            {
                GL.Vertex(vector);
            }
            GL.End();
            GL.PopMatrix();
        }
    }