Exemplo n.º 1
0
    public void UpdateList(HumanController humanController)
    {
        this.humanController = humanController;

        endTurnButton.onClick.RemoveAllListeners();
        endTurnButton.onClick.AddListener(delegate() { this.humanController.EndTurn(); });

        content.sizeDelta = new Vector2(content.sizeDelta.x, 100 * humanController.friendlies.Count);
        for (int i = 0; i < activeButtons.Count; ++i)
        {
            Destroy(activeButtons[i].gameObject);
        }
        activeButtons.Clear();

        MeshRenderer mr;

        for (int i = 0; i < humanController.friendlies.Count; ++i)
        {
            mr = humanController.friendlies[i].GetComponent <MeshRenderer>();
            if (mr == null)
            {
                humanController.friendlies[i].GetComponentInChildren <SkinnedMeshRenderer>().material.SetInt("_Highlighted", 0);
            }
            else
            {
                mr.material.SetInt("_Highlighted", 0);
            }
        }

        for (int i = 0; i < humanController.friendlies.Count; ++i)
        {
            Character c = humanController.friendlies[i];

            if (c.hasHadTurn)
            {
                continue;
            }

            Button characterInfoButton = Instantiate(characterInfoButtonPrefab, content);
            characterInfoButton.transform.position += new Vector3(0, (-100 * activeButtons.Count), 0);

            Text[]  textFields    = characterInfoButton.GetComponentsInChildren <Text>();
            Image[] images        = characterInfoButton.GetComponentsInChildren <Image>(true);
            Image[] abilityImages = { images[1], images[2], images[3], images[4], images[5], images[6] };

            textFields[0].text = c.Name;
            textFields[1].text = "Health: " + c.currentHealth.ToString() + " / " + c.MaxHealth.ToString();
            textFields[2].text = "Major Abilities: " + c.numMajorAbilities.ToString() + " / " + c.maxMajorAbilities.ToString();
            textFields[3].text = "Minor Abilities: " + c.numMinorAbilities.ToString() + " / " + c.maxMinorAbilities.ToString();

            for (int j = 0; j < c.abilities.Count && j < 6; ++j)
            {
                abilityImages[j].gameObject.SetActive(true);
                abilityImages[j].sprite = c.abilities[j].sprite;
            }

            int index = i;
            characterInfoButton.onClick.AddListener(delegate { SelectCharacter(index); });
            activeButtons.Add(characterInfoButton);
        }
    }
Exemplo n.º 2
0
 private void Start()
 {
     humanController = GetComponent <HumanController>();
 }
Exemplo n.º 3
0
        private object IOnGetClientMove(HumanController controller, Vector3 origin, int encoded, ushort stateFlags, uLink.NetworkMessageInfo info)
        {
            if (float.IsNaN(origin.x) || float.IsInfinity(origin.x) ||
                float.IsNaN(origin.y) || float.IsInfinity(origin.y) ||
                float.IsNaN(origin.z) || float.IsInfinity(origin.z))
            {
                Interface.Oxide.LogInfo($"Banned {controller.netUser.displayName} [{controller.netUser.userID}] for sending bad packets (possible teleport hack)");
                BanList.Add(controller.netUser.userID, controller.netUser.displayName, "Sending bad packets (possible teleport hack)");
                controller.netUser.Kick(NetError.ConnectionBanned, true);
                return false;
            }

            return null;
        }
Exemplo n.º 4
0
        public void OnGUI()
        {
            if (!WorldEditor.Instance.Enabled)
            {
                return;
            }

            try
            {
                Vector3 playerloc = Camera.main.ViewportToWorldPoint(transform.localPosition);


                if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                {
                    Collider collider    = SpawnedObject.ObjectInstantiate.collider;
                    bool     hascollider = false;
                    if (collider != null)
                    {
                        hascollider = SpawnedObject.ObjectInstantiate
                                      .collider.enabled;
                    }

                    GUI.Label(new Rect(0, Screen.height - 100, Screen.width, 20), "POS:"
                              + SpawnedObject.ObjectInstantiate
                              .transform.position.ToString()
                              + " ROT:" + SpawnedObject
                              .ObjectInstantiate.transform
                              .rotation.ToString()
                              + " Size:" +
                              SpawnedObject.ObjectInstantiate
                              .transform.localScale.ToString()
                              + " Col: " +
                              hascollider, style2);
                }

                string prefab = "";
                if (ShowList)
                {
                    int selectedItemIndex = comboBoxControl.Show();
                    if (comboBoxList[selectedItemIndex] != null)
                    {
                        prefab = comboBoxList[selectedItemIndex].text;
                    }
                }

                GUI.Box(new Rect(0, 60, 140, 90), "Object Spawn");
                GUI.Label(new Rect(Screen.width / 2, Screen.height - Screen.height + 10, 200, 30),
                          string.Format("<b><color=#298A08>" + prefab + "</color></b> "));

                if (GUI.Button(new Rect(0, 0, 120, 20), "Fly (" + flySpeed + ")"))
                {
                    _fly = !_fly;
                    if (_fly)
                    {
                        this.localPlayerClient = PlayerClient.GetLocalPlayer();
                        this.controllable      = this.localPlayerClient.controllable;
                        this.localCharacter    = this.controllable.character;
                        this.localController   = this.localCharacter.controller as HumanController;
                    }
                }

                if (GUI.Button(new Rect(10, 80, 120, 20), "Spawn"))
                {
                    try
                    {
                        TempGameObject = new GameObject();
                        SpawnedObject  = TempGameObject.AddComponent <LoadingHandler.LoadObjectFromBundle>();
                        SpawnedObject.Create(prefab, WorldEditor.Instance.PrefabBundleDictionary[prefab],
                                             new Vector3(playerloc.x + 10f, playerloc.y, playerloc.z + 10f),
                                             new Quaternion(0f, 0f, 0f, 0f),
                                             new Vector3(1f, 1f, 1f));
                        UnityEngine.Object.DontDestroyOnLoad(TempGameObject);
                        Screen.lockCursor = true;
                    }
                    catch
                    {
                        Rust.Notice.Inventory("", "Failed to create prefab!");
                        // ignore
                    }
                }

                if (GUI.Button(new Rect(10, 100, 120, 20), "Destroy"))
                {
                    if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                    {
                        WorldEditor.Instance.AllSpawnedObjects.Remove(SpawnedObject);
                        UnityEngine.Object.Destroy(SpawnedObject.ObjectInstantiate);
                        SpawnedObject = null;
                        UnityEngine.Object.Destroy(TempGameObject);
                        TempGameObject = null;
                    }
                }

                if (GUI.Button(new Rect(10, 120, 120, 20), "Player loc"))
                {
                    var b = File.Exists(RustBuster2016.API.Hooks.GameDirectory +
                                        "\\RB_Data\\WorldEditor\\PlayerLocation.txt");
                    string text = "";

                    if (!b)
                    {
                        File.Create(RustBuster2016.API.Hooks.GameDirectory +
                                    "\\RB_Data\\WorldEditor\\PlayerLocation.txt");
                    }
                    else
                    {
                        text = File.ReadAllText(RustBuster2016.API.Hooks.GameDirectory +
                                                "\\RB_Data\\WorldEditor\\PlayerLocation.txt");
                    }
                    text += "X: " + playerloc.x + ", Y: " + playerloc.y + ", Z: " + playerloc.z + "\r\n";
                    File.WriteAllText(
                        RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\PlayerLocation.txt", text);
                }

                GUI.Box(new Rect(0, 170, 140, 120), "File Manager");
                if (GUI.Button(new Rect(10, 190, 120, 20), "SAVE CURRENT"))
                {
                    if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                    {
                        string line = "" + WorldEditor.Instance.PrefabBundleDictionary[SpawnedObject.Name] + ":" +
                                      SpawnedObject.Name + ":" +
                                      SpawnedObject.ObjectInstantiate.transform.position.x.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.position.y.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.position.z.ToString() + ":" +
                                      SpawnedObject.ObjectInstantiate.transform.rotation.x.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.rotation.y.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.rotation.z.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.rotation.w.ToString() + ":" +
                                      SpawnedObject.ObjectInstantiate.transform.localScale.x.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.localScale.y.ToString() + "," +
                                      SpawnedObject.ObjectInstantiate.transform.localScale.z.ToString();

                        var file = new System.IO.StreamWriter(WorldEditor.Instance.SavedObjectsPath, true);
                        file.WriteLine(line);
                        file.Close();
                    }
                }

                if (GUI.Button(new Rect(10, 210, 120, 20), "SAVEALL"))
                {
                    foreach (var x in WorldEditor.Instance.AllSpawnedObjects)
                    {
                        string line = "" + x.Name + ":" +
                                      x.ObjectInstantiate.transform.position.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.position.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.position.z.ToString() + ":" +
                                      x.ObjectInstantiate.transform.rotation.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.z.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.w.ToString() + ":" +
                                      x.ObjectInstantiate.transform.localScale.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.localScale.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.localScale.z.ToString();

                        var file = new System.IO.StreamWriter(WorldEditor.Instance.SavedObjectsPath, true);
                        file.WriteLine(line);
                        file.Close();
                    }
                }

                if (GUI.Button(new Rect(10, 230, 120, 20), "CLEAR & SAVEALL"))
                {
                    File.WriteAllText(WorldEditor.Instance.SavedObjectsPath, string.Empty);
                    foreach (var x in WorldEditor.Instance.AllSpawnedObjects)
                    {
                        string line = "" + WorldEditor.Instance.PrefabBundleDictionary[x.Name] + ":" + x.Name + ":" +
                                      x.ObjectInstantiate.transform.position.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.position.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.position.z.ToString() + ":" +
                                      x.ObjectInstantiate.transform.rotation.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.z.ToString() + "," +
                                      x.ObjectInstantiate.transform.rotation.w.ToString() + ":" +
                                      x.ObjectInstantiate.transform.localScale.x.ToString() + "," +
                                      x.ObjectInstantiate.transform.localScale.y.ToString() + "," +
                                      x.ObjectInstantiate.transform.localScale.z.ToString();

                        var file = new System.IO.StreamWriter(WorldEditor.Instance.SavedObjectsPath, true);
                        file.WriteLine(line);
                        file.Close();
                    }
                }

                if (GUI.Button(new Rect(10, 250, 120, 20), "CLEAR & DESTROY"))
                {
                    File.WriteAllText(WorldEditor.Instance.SavedObjectsPath, string.Empty);
                    foreach (var x in WorldEditor.Instance.AllSpawnedObjects)
                    {
                        UnityEngine.Object.Destroy(x.ObjectInstantiate);
                    }

                    WorldEditor.Instance.AllSpawnedObjects.Clear();
                }

                if (GUI.Button(new Rect(10, 270, 120, 20), "LOAD FILE"))
                {
                    var last = SpawnedObject;
                    foreach (string line in File.ReadAllLines(WorldEditor.Instance.SavedObjectsPath))
                    {
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        string[] pares = line.Split(':');

                        var nombre = pares[0];
                        var loc    = pares[1];
                        var qua    = pares[2];
                        var siz    = pares[3];

                        // Position
                        string[] locsplit = loc.ToString().Split(',');
                        float    posx     = float.Parse(locsplit[0]);
                        float    posy     = float.Parse(locsplit[1]);
                        float    posz     = float.Parse(locsplit[2]);

                        // Quaternion
                        string[] quasplit = qua.ToString().Split(',');
                        float    quax     = float.Parse(quasplit[0]);
                        float    quay     = float.Parse(quasplit[1]);
                        float    quaz     = float.Parse(quasplit[2]);
                        float    quaw     = float.Parse(quasplit[3]);

                        // Size
                        string[] sizsplit = siz.ToString().Split(',');
                        float    sizx     = float.Parse(sizsplit[0]);
                        float    sizy     = float.Parse(sizsplit[1]);
                        float    sizz     = float.Parse(sizsplit[2]);


                        TempGameObject = new GameObject();
                        SpawnedObject  = TempGameObject.AddComponent <LoadingHandler.LoadObjectFromBundle>();
                        SpawnedObject.Create(nombre, WorldEditor.Instance.PrefabBundleDictionary[nombre],
                                             new Vector3(posx, posy, posz), new Quaternion(quax, quay, quaz, quaw),
                                             new Vector3(sizx, sizy, sizz));
                        UnityEngine.Object.DontDestroyOnLoad(TempGameObject);
                    }

                    SpawnedObject = last;
                }

                GUI.Box(new Rect(0, 310, 140, 120), "Object Control");

                if (GUI.Button(new Rect(10, 330, 120, 20), "To Me"))
                {
                    if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                    {
                        SpawnedObject.ObjectInstantiate.transform.position = playerloc;
                    }
                }

                if (GUI.Button(new Rect(10, 350, 120, 20), "Reset Rot"))
                {
                    if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                    {
                        SpawnedObject.ObjectInstantiate.transform.rotation = new Quaternion(0, 0, 0, 1);
                    }
                }

                if (GUI.Button(new Rect(10, 370, 120, 20), "Collider"))
                {
                    if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null)
                    {
                        Collider collider = SpawnedObject.ObjectInstantiate.collider;
                        if (collider != null)
                        {
                            SpawnedObject.ObjectInstantiate.collider.enabled =
                                !SpawnedObject.ObjectInstantiate.collider.enabled;
                        }
                    }
                }

                if (GUI.Button(new Rect(10, 390, 120, 20), "Select Object"))
                {
                    if (RustBuster2016.API.Hooks.LocalPlayer != null)
                    {
                        if (WorldEditor.Instance.AllSpawnedObjects.Count == 0)
                        {
                            Rust.Notice.Inventory("", "We got no spawned objects buddy!");
                            return;
                        }

                        //RustBuster2016.API.Hooks.LogData("test", "test12");
                        var     player     = RustBuster2016.API.Hooks.LocalPlayer;
                        Vector3 pos        = player.controllable.character.transform.position;
                        Vector3 eyesOrigin = player.controllable.character.eyesOrigin;
                        Vector3 direction  = player.controllable.character.eyesRay.direction;

                        RaycastHit[] hitArray = Physics.RaycastAll(eyesOrigin, direction, 60f);

                        LoadingHandler.LoadObjectFromBundle obj = null;
                        float dist = float.MaxValue;


                        RaycastHit closesthit = new RaycastHit();
                        closesthit.distance = -1;
                        float hitdist = float.MaxValue;
                        //RustBuster2016.API.Hooks.LogData("test", "test1233333");
                        foreach (var hit in hitArray)
                        {
                            if (hit.distance < hitdist)
                            {
                                closesthit = hit;
                                hitdist    = hit.distance;
                            }
                        }

                        if (closesthit.distance >= 0f)
                        {
                            foreach (var x in WorldEditor.Instance.AllSpawnedObjects)
                            {
                                try
                                {
                                    //RustBuster2016.API.Hooks.LogData("test", "dist2");
                                    float dist2 = Vector3.Distance(closesthit.transform.position,
                                                                   x.ObjectInstantiate.transform.position);

                                    //RustBuster2016.API.Hooks.LogData("test", "playerdist");
                                    float playerdist = Vector3.Distance(pos, x.ObjectInstantiate.transform.position);

                                    //RustBuster2016.API.Hooks.LogData("test", "boom");
                                    if (dist2 < dist && playerdist <= 60f)
                                    {
                                        //RustBuster2016.API.Hooks.LogData("test", "boom2");
                                        dist = dist2;
                                        obj  = x;
                                    }
                                }
                                catch
                                {
                                    // probably hit a rust object, avoid it.
                                }
                            }
                        }

                        if (obj != null)
                        {
                            SpawnedObject = obj;
                            Rust.Notice.Inventory("", "Found the closest object to you hopefully.");
                        }
                        else
                        {
                            Rust.Notice.Inventory("", "Couldn't find anything.");
                        }
                    }

                    /*RustBuster2016.API.Hooks.LogData("test", "test1");
                     * if (RustBuster2016.API.Hooks.LocalPlayer != null)
                     * {
                     *  RustBuster2016.API.Hooks.LogData("test", "test12");
                     *  var player = RustBuster2016.API.Hooks.LocalPlayer;
                     *  Vector3 eyesOrigin = player.controllable.character.eyesOrigin;
                     *  Vector3 direction = player.controllable.character.eyesRay.direction;
                     *
                     *  RaycastHit[] hitArray = Physics.RaycastAll(eyesOrigin, direction, 60f);
                     *
                     *  foreach (RaycastHit hit in hitArray)
                     *  {
                     *      RustBuster2016.API.Hooks.LogData("test", "test32 " + hit.collider.GetComponent<LoadingHandler.CustomObjectIdentifier>());
                     *      RustBuster2016.API.Hooks.LogData("test", "test32 " + hit.collider.gameObject);
                     *      RustBuster2016.API.Hooks.LogData("test", "test3 " + hit.collider.gameObject.GetComponent<LoadingHandler.CustomObjectIdentifier>());
                     *      if (hit.collider != null && hit.collider.gameObject != null && hit.collider.gameObject.GetComponent<LoadingHandler.CustomObjectIdentifier>() != null)
                     *      {
                     *          RustBuster2016.API.Hooks.LogData("test", "test4 " + hit.collider.gameObject.name);
                     *          var data = hit.collider.gameObject
                     *              .GetComponent<LoadingHandler.CustomObjectIdentifier>();
                     *          SpawnedObject = data.BundleClass;
                     *      }
                     *  }
                     * }*/
                }

                if (GUI.Button(new Rect(10, 410, 120, 20), "Toggle Animation"))
                {
                    if (SpawnedObject.ObjectInstantiate.animation.isPlaying)
                    {
                        SpawnedObject.ObjectInstantiate.animation.Stop();
                    }
                    else
                    {
                        SpawnedObject.ObjectInstantiate.animation.Play();
                    }
                }

                const string a = "LIST (LControl + LAlt)" + "\n \n" +
                                 "POSx + (NUMPAD 1)" + "\n" +
                                 "POSx - (NUMPAD 2)" + "\n" +
                                 "POSz + (NUMPAD 4)" + "\n" +
                                 "POSz - (NUMPAD 5)" + "\n" +
                                 "POSy + (NUMPAD 7)" + "\n" +
                                 "POSy - (NUMPAD 8)" + "\n \n" +
                                 "ROTx + (UP)" + "\n" +
                                 "ROTx - (DOWN)" + "\n" +
                                 "ROTy + (LEFT)" + "\n" +
                                 "ROTy - (RIGTH)" + "\n \n" +
                                 "ROTz + (NUMPAD 3)" + "\n" +
                                 "ROTz - (NUMPAD Intro)" + "\n \n" +
                                 "SIZE + (NUMPAD *)" + "\n" +
                                 "SIZE - (NUMPAD -)";
                GUI.Label(new Rect(10, 430, 600, 600), a);
            }
            catch (Exception ex)
            {
                RustBuster2016.API.Hooks.LogData("Error", "Something is wrong with the gui: " + ex);
            }
        }
Exemplo n.º 5
0
 void Start()
 {
     human = GetComponentInParent <HumanController>();
 }
        private void MotorHacks()
        {
            HumanController localController = HackLocal.LocalController;
            Character       localCharacter  = HackLocal.LocalCharacter;
            CCMotor         ccmotor         = localController.ccmotor;

            if (ccmotor != null)
            {
                if (!this.defaultJumping.HasValue)
                {
                    this.defaultJumping = new CCMotor.Jumping?(ccmotor.jumping.setup);
                }
                else
                {
                    ccmotor.minTimeBetweenJumps      = 0.1f;
                    ccmotor.jumping.setup.baseHeight = this.defaultJumping.Value.baseHeight * CVars.Misc.JumpModifer;
                }
                if (!this.defaultMovement.HasValue)
                {
                    this.defaultMovement = new CCMotor.Movement?(ccmotor.movement.setup);
                }
                else
                {
                    ccmotor.movement.setup.maxForwardSpeed       = this.defaultMovement.Value.maxForwardSpeed * CVars.Misc.SpeedModifer / 10f;
                    ccmotor.movement.setup.maxSidewaysSpeed      = this.defaultMovement.Value.maxSidewaysSpeed * CVars.Misc.SpeedModifer / 10f;
                    ccmotor.movement.setup.maxBackwardsSpeed     = this.defaultMovement.Value.maxBackwardsSpeed * CVars.Misc.SpeedModifer / 10f;
                    ccmotor.movement.setup.maxGroundAcceleration = this.defaultMovement.Value.maxGroundAcceleration * CVars.Misc.SpeedModifer / 10f;
                    ccmotor.movement.setup.maxAirAcceleration    = this.defaultMovement.Value.maxAirAcceleration * CVars.Misc.SpeedModifer / 10f;
                    if (CVars.Misc.NoFallDamage)
                    {
                        ccmotor.movement.setup.maxFallSpeed = 17f;
                    }
                    else
                    {
                        ccmotor.movement.setup.maxFallSpeed = this.defaultMovement.Value.maxFallSpeed;
                    }
                }
                if (CVars.Misc.FlyHack)
                {
                    ccmotor.velocity = Vector3.zero;
                    Vector3 forward = localCharacter.eyesAngles.forward;
                    Vector3 right   = localCharacter.eyesAngles.right;
                    if (!ChatUI.IsVisible())
                    {
                        if (Input.GetKey(KeyCode.W))
                        {
                            ccmotor.velocity += forward * (ccmotor.movement.setup.maxForwardSpeed * 3f);
                        }
                        if (Input.GetKey(KeyCode.S))
                        {
                            ccmotor.velocity -= forward * (ccmotor.movement.setup.maxBackwardsSpeed * 3f);
                        }
                        if (Input.GetKey(KeyCode.A))
                        {
                            ccmotor.velocity -= right * (ccmotor.movement.setup.maxSidewaysSpeed * 3f);
                        }
                        if (Input.GetKey(KeyCode.D))
                        {
                            ccmotor.velocity += right * (ccmotor.movement.setup.maxSidewaysSpeed * 3f);
                        }
                        if (Input.GetKey(KeyCode.Space))
                        {
                            ccmotor.velocity += Vector3.up * (this.defaultMovement.Value.maxAirAcceleration * 3f);
                        }
                    }
                    if (ccmotor.velocity == Vector3.zero)
                    {
                        ccmotor.velocity += Vector3.up * (ccmotor.settings.gravity * Time.deltaTime * 0.5f);
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void AddToFightList(HumanController human)
 {
     hitList.Add(human);
 }
Exemplo n.º 8
0
 private void ProcessInput(ref HumanController.InputSample sample)
 {
     bool flag;
     bool flag1;
     CCMotor.InputFrame movementScale = new CCMotor.InputFrame();
     float single;
     float single1;
     CCMotor cCMotor = base.ccmotor;
     if (!cCMotor)
     {
         flag1 = false;
         flag = true;
     }
     else
     {
         flag = cCMotor.isGrounded;
         flag1 = cCMotor.isSliding;
         if (!flag && !flag1)
         {
             sample.sprint = false;
             sample.crouch = false;
             sample.aim = false;
             sample.info__crouchBlocked = false;
             if (!this.wasInAir)
             {
                 this.wasInAir = true;
                 this.magnitudeAir = cCMotor.input.moveDirection.magnitude;
                 this.midairStartPos = base.transform.position;
             }
             this.lastFrameVelocity = cCMotor.velocity;
         }
         else if (this.wasInAir)
         {
             this.wasInAir = false;
             this.magnitudeAir = 1f;
             this.landingSpeedPenaltyTime = 0f;
             if (base.transform.position.y < this.midairStartPos.y && Mathf.Abs(base.transform.position.y - this.midairStartPos.y) > 2f)
             {
                 base.idMain.GetLocal<FallDamage>().SendFallImpact(this.lastFrameVelocity);
             }
             this.lastFrameVelocity = Vector3.zero;
             this.midairStartPos = Vector3.zero;
         }
         bool flag2 = (sample.crouch ? true : sample.info__crouchBlocked);
         movementScale.jump = sample.jump;
         movementScale.moveDirection.x = sample.strafe;
         movementScale.moveDirection.y = 0f;
         movementScale.moveDirection.z = sample.walk;
         movementScale.crouchSpeed = (!sample.crouch ? 1f : -1f);
         if (movementScale.moveDirection == Vector3.zero)
         {
             this.sprinting = false;
             this.exitingSprint = false;
             this.sprintTime = 0f;
             this.crouchTime = (!sample.crouch ? 0f : this.controlConfig.curveCrouchMulSpeedByTime.GetEndTime());
             this.magnitudeAir = 1f;
         }
         else
         {
             float single2 = movementScale.moveDirection.magnitude;
             if (single2 < 1f)
             {
                 movementScale.moveDirection = movementScale.moveDirection / single2;
                 single2 = single2 * single2;
                 movementScale.moveDirection = movementScale.moveDirection * single2;
             }
             else if (single2 > 1f)
             {
                 movementScale.moveDirection = movementScale.moveDirection / single2;
             }
             if (HumanController.InputSample.MovementScale < 1f)
             {
                 if (HumanController.InputSample.MovementScale <= 0f)
                 {
                     movementScale.moveDirection = Vector3.zero;
                 }
                 else
                 {
                     movementScale.moveDirection = movementScale.moveDirection * HumanController.InputSample.MovementScale;
                 }
             }
             Vector3 vector3 = movementScale.moveDirection;
             vector3.x = vector3.x * this.controlConfig.sprintScaleX;
             vector3.z = vector3.z * this.controlConfig.sprintScaleY;
             if (!sample.sprint || flag2 || sample.aim)
             {
                 sample.sprint = false;
                 single = -Time.deltaTime;
             }
             else
             {
                 single = Time.deltaTime * this.sprintInMulTime;
             }
             movementScale.moveDirection = movementScale.moveDirection + (vector3 * this.controlConfig.curveSprintAddSpeedByTime.EvaluateClampedTime(ref this.sprintTime, single));
             single1 = (!flag2 ? -Time.deltaTime : Time.deltaTime * this.crouchInMulTime);
             movementScale.moveDirection = movementScale.moveDirection * this.controlConfig.curveCrouchMulSpeedByTime.EvaluateClampedTime(ref this.crouchTime, single1);
             movementScale.moveDirection = base.transform.TransformDirection(movementScale.moveDirection);
             if (!this.wasInAir)
             {
                 movementScale.moveDirection = movementScale.moveDirection * this.controlConfig.curveLandingSpeedPenalty.EvaluateClampedTime(ref this.landingSpeedPenaltyTime, Time.deltaTime);
             }
             else
             {
                 float single3 = movementScale.moveDirection.magnitude;
                 if (!Mathf.Approximately(single3, this.magnitudeAir))
                 {
                     movementScale.moveDirection = movementScale.moveDirection / single3;
                     movementScale.moveDirection = movementScale.moveDirection * this.magnitudeAir;
                 }
             }
         }
         if (DebugInput.GetKey(KeyCode.H))
         {
             movementScale.moveDirection = movementScale.moveDirection * 100f;
         }
         cCMotor.input = movementScale;
         if (cCMotor.stepMode == CCMotor.StepMode.Elsewhere)
         {
             cCMotor.Step();
         }
     }
     Character character = base.idMain;
     Crouchable crouchable = character.crouchable;
     if (character)
     {
         Angle2 angle2 = base.eyesAngles;
         Angle2 angle21 = base.eyesAngles;
         angle2.yaw = Mathf.DeltaAngle(0f, angle21.yaw + sample.yaw);
         angle2.pitch = base.ClampPitch(angle2.pitch + sample.pitch);
         base.eyesAngles = angle2;
         ushort num = character.stateFlags.flags;
         if (crouchable)
         {
             this.crouch_smoothing.AddSeconds((double)Time.deltaTime);
             crouchable.LocalPlayerUpdateCrouchState(cCMotor, ref sample.crouch, ref sample.info__crouchBlocked, ref this.crouch_smoothing);
         }
         int num1 = (!sample.aim ? 0 : 4) | (!sample.sprint ? 0 : 2) | (!sample.attack ? 0 : 8) | (!sample.attack2 ? 0 : 256) | (!sample.crouch ? 0 : 1) | (sample.strafe != 0f || sample.walk != 0f ? 64 : 0) | (!LockCursorManager.IsLocked() ? 128 : 0) | (!flag ? 16 : 0) | (!flag1 ? 0 : 32) | (!this.bleeding ? 0 : 512) | (!sample.lamp ? 0 : 2048) | (!sample.laser ? 0 : 4096) | (!sample.info__crouchBlocked ? 0 : 1024);
         character.stateFlags = num1;
         if (num != num1)
         {
             character.Signal_State_FlagsChanged(false);
         }
     }
     this.crouch_was_blocked = sample.info__crouchBlocked;
     if (sample.inventory)
     {
         RPOS.Toggle();
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         RPOS.Hide();
     }
 }
Exemplo n.º 9
0
 void Awake()
 {
     positions       = new List <Vector3>();
     humanController = GetComponent <HumanController>();
 }
Exemplo n.º 10
0
 public void InvokeInputItemPostFrame(object item, ref HumanController.InputSample sample)
 {
     IHeldItem heldItem = item as IHeldItem;
     if (heldItem != null)
     {
         heldItem.ItemPostFrame(ref sample);
     }
 }
Exemplo n.º 11
0
 public object InvokeInputItemPreFrame(ref HumanController.InputSample sample)
 {
     IHeldItem heldItem = this.inputItem as IHeldItem;
     if (heldItem != null)
     {
         heldItem.ItemPreFrame(ref sample);
     }
     return heldItem;
 }
Exemplo n.º 12
0
 public void OnPlayerMove(HumanController hc, Vector3 v, int p, ushort p2,
                          uLink.NetworkMessageInfo networkMessageInfo, Util.PlayerActions action)
 {
     this.Invoke("On_PlayerMove", new object[] { hc, v, p, p2, networkMessageInfo, action });
 }
Exemplo n.º 13
0
 public void Add(HumanController human)
 {
     human_all.Add(human);
 }
Exemplo n.º 14
0
        private void NoRecoil()
        {
            if (CVars.Misc.NoRecoil)
            {
                HumanController localController     = ESP_UpdateOBJs.LocalController;
                InventoryItem   currentEquippedItem = Local.GetCurrentEquippedItem(localController);
                if ((currentEquippedItem != null) && !(currentEquippedItem is MeleeWeaponItem <MeleeWeaponDataBlock>))
                {
                    BulletWeaponItem <BulletWeaponDataBlock> item2 = currentEquippedItem as BulletWeaponItem <BulletWeaponDataBlock>;
                    if (item2 != null)
                    {
                        defaultBulletRange    = item2.datablock.bulletRange;
                        defaultRecoilPitchMin = item2.datablock.recoilPitchMin;
                        defaultRecoilPitchMax = item2.datablock.recoilPitchMax;
                        defaultRecoilYawMin   = item2.datablock.recoilYawMin;
                        defaultRecoilYawMax   = item2.datablock.recoilYawMax;
                        defaultAimSway        = item2.datablock.aimSway;
                        defaultAimSwaySpeed   = item2.datablock.aimSwaySpeed;

                        //item2.datablock.bulletRange = 300f;
                        item2.datablock.recoilPitchMin = 0f;
                        item2.datablock.recoilPitchMax = 0f;
                        item2.datablock.recoilYawMin   = 0f;
                        item2.datablock.recoilYawMax   = 0f;
                        item2.datablock.aimSway        = 0f;
                        item2.datablock.aimSwaySpeed   = 0f;
                    }
                }
                CameraMount componentInChildren = localController.GetComponentInChildren <CameraMount>();
                if (componentInChildren != null)
                {
                    HeadBob component = componentInChildren.GetComponent <HeadBob>();
                    if (component != null)
                    {
                        defaultAimRotationScalar          = component.aimRotationScalar;
                        defaultViewModelRotationScalar    = component.viewModelRotationScalar;
                        component.aimRotationScalar       = 0f;
                        component.viewModelRotationScalar = 0f;
                    }
                }
            }
            else
            {
                if (defaultBulletRange == 0f)
                {
                    HumanController localController     = ESP_UpdateOBJs.LocalController;
                    InventoryItem   currentEquippedItem = Local.GetCurrentEquippedItem(localController);
                    if ((currentEquippedItem != null) && !(currentEquippedItem is MeleeWeaponItem <MeleeWeaponDataBlock>))
                    {
                        BulletWeaponItem <BulletWeaponDataBlock> item2 = currentEquippedItem as BulletWeaponItem <BulletWeaponDataBlock>;
                        if (item2 != null)
                        {
                            defaultBulletRange    = item2.datablock.bulletRange;
                            defaultRecoilPitchMin = item2.datablock.recoilPitchMin;
                            defaultRecoilPitchMax = item2.datablock.recoilPitchMax;
                            defaultRecoilYawMin   = item2.datablock.recoilYawMin;
                            defaultRecoilYawMax   = item2.datablock.recoilYawMax;
                            defaultAimSway        = item2.datablock.aimSway;
                            defaultAimSwaySpeed   = item2.datablock.aimSwaySpeed;
                        }
                    }
                    CameraMount componentInChildren = localController.GetComponentInChildren <CameraMount>();
                    if (componentInChildren != null)
                    {
                        HeadBob component = componentInChildren.GetComponent <HeadBob>();
                        if (component != null)
                        {
                            defaultAimRotationScalar       = component.aimRotationScalar;
                            defaultViewModelRotationScalar = component.viewModelRotationScalar;
                        }
                    }
                }
                else
                {
                    HumanController localController     = ESP_UpdateOBJs.LocalController;
                    InventoryItem   currentEquippedItem = Local.GetCurrentEquippedItem(localController);
                    if ((currentEquippedItem != null) && !(currentEquippedItem is MeleeWeaponItem <MeleeWeaponDataBlock>))
                    {
                        BulletWeaponItem <BulletWeaponDataBlock> item2 = currentEquippedItem as BulletWeaponItem <BulletWeaponDataBlock>;
                        if (item2 != null)
                        {
                            //item2.datablock.bulletRange = defaultBulletRange;
                            item2.datablock.recoilPitchMin = defaultRecoilPitchMin;
                            item2.datablock.recoilPitchMax = defaultRecoilPitchMax;
                            item2.datablock.recoilYawMin   = defaultRecoilYawMin;
                            item2.datablock.recoilYawMax   = defaultRecoilYawMax;
                            item2.datablock.aimSway        = defaultAimSway;
                            item2.datablock.aimSwaySpeed   = defaultAimSwaySpeed;
                        }
                    }
                    CameraMount componentInChildren = localController.GetComponentInChildren <CameraMount>();
                    if (componentInChildren != null)
                    {
                        HeadBob component = componentInChildren.GetComponent <HeadBob>();
                        if (component != null)
                        {
                            component.aimRotationScalar       = defaultAimRotationScalar;
                            component.viewModelRotationScalar = defaultViewModelRotationScalar;
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
        public void Initialise()
        {
            Root = new Root();
            ConfigFile cf = new ConfigFile();

            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair <string, string> pair in settings)
                {
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
                }
            }

            if (!Root.RestoreConfig())
            {
                if (!Root.ShowConfigDialog())
                {
                    return;
                }
            }

            Root.RenderSystem.SetConfigOption("VSync", "Yes");
            RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg");  // @@@@@@@@@@@@@@@ Nazwa okna gry.

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            SceneManager            = Root.CreateSceneManager(SceneType.ST_GENERIC);
            Camera                  = SceneManager.CreateCamera("MainCamera");
            Viewport                = RenderWindow.AddViewport(Camera);
            Camera.NearClipDistance = 0.1f;
            Camera.FarClipDistance  = 1000.0f;
            Camera.AspectRatio      = ((float)RenderWindow.Width / (float)RenderWindow.Height);

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr         windowHnd;

            RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            InputManager = MOIS.InputManager.CreateInputSystem(pl);

            Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            Mouse    = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            NewtonWorld    = new World();
            NewtonDebugger = new Debugger(NewtonWorld);
            NewtonDebugger.Init(SceneManager);

            GameCamera    = new GameCamera();
            ObjectManager = new ObjectManager();

            MaterialManager = new MaterialManager();
            MaterialManager.Initialise();


            Items                   = new Items();
            PrizeManager            = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
            CharacterProfileManager = new CharacterProfileManager();
            Quests                  = new Quests();
            NPCManager              = new NPCManager();

            Labeler         = new TextLabeler(5);
            Random          = new Random();
            HumanController = new HumanController();

            TypedInput = new TypedInput();


            SoundManager = new SoundManager();

            Dialog        = new Dialog();
            Mysz          = new MOIS.MouseState_NativePtr();
            Conversations = new Conversations();

            TriggerManager = new TriggerManager();

            Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed);
            Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased);

            IngameConsole = new IngameConsole();
            IngameConsole.Init();
            IngameConsole.AddCommand("dupa", "soundOddawajPiec");
            IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy");
            IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii");
            IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3");
            IngameConsole.AddCommand("map", "ChangeMap");
            IngameConsole.AddCommand("save", "SaveGame");
            IngameConsole.AddCommand("load", "LoadGame");
            IngameConsole.AddCommand("help", "ConsoleHelp");
            IngameConsole.AddCommand("h", "CommandHelp");
        }
Exemplo n.º 16
0
    protected Vector2 GetDirectionToTargetForMovement()
    {
        Vector2 direction = Vector2.zero;

        closestHumanDistanceSqr = 9999;
        closestLightDistanceSqr = 9999;

        bool biasUpNode    = true;
        bool biasRightNode = true;

        bool canTurnOffLight = true;

        Node selfNode = map.GetNode(playerController.GetPosition());

        Vector2 targetPosition = Vector2.zero;
        Vector2 toTarget       = Vector2.zero;
        Vector2 selfPosition   = playerController.GetPosition();

        Vector2 totalAwayFromHuman = new Vector2();
        Vector2 totalToTiles       = new Vector2();

        // Have to get these each time because some players may die and then they leave the array
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        GameObject[] lights  = GameObject.FindGameObjectsWithTag("Light");

        for (int i = 0; i < players.Length; ++i)
        {
            HumanController hc = players[i].GetComponent <HumanController>();
            if (hc != null)
            {
                targetPosition = hc.GetPosition();
                toTarget       = targetPosition - selfPosition;

                Vector2 newTargetDirection = Vector2.zero;
                bool    canSeeTarget       = FindIfTargetIsVisible(targetPosition, toTarget, ref newTargetDirection, ignoreLightLanternProjectileLayerMask);

                Node  targetNode             = map.GetNode(targetPosition);
                float distanceToNewTargetSqr = 0;

                if (canSeeTarget)
                {
                    // Use - because we want to move away from the target
                    direction          -= newTargetDirection.normalized * directionToTargetWeight;
                    totalAwayFromHuman -= newTargetDirection.normalized * directionToTargetWeight;

                    // Bias the node selection to be as away from the target as you can get
                    // only do this if you can see the target or you'll get stuck in between nodes
                    biasUpNode    = toTarget.y < 0 ? true : false;
                    biasRightNode = toTarget.x < 0 ? true : false;

                    distanceToNewTargetSqr = toTarget.sqrMagnitude;
                }
                else
                {
                    distanceToNewTargetSqr = Mathf.Pow(selfNode.distances[targetNode.x, targetNode.y] * map.unitSize, 2);
                }

                // If a human is too close to this AI then turning off a light could end up in them getting caught, so don't do it
                if (distanceToNewTargetSqr < minimumDistanceFromHumansSqr)
                {
                    canTurnOffLight = false;
                }

                if (closestHumanDistanceSqr > distanceToNewTargetSqr)
                {
                    directionToAttack       = toTarget;
                    closestHumanDistanceSqr = distanceToNewTargetSqr;
                }

                Node destination  = selfNode;
                int  bestDistance = selfNode.distances[targetNode.x, targetNode.y];

                Node leftNode              = selfNode;
                Node rightNode             = selfNode;
                Node upNode                = selfNode;
                Node downNode              = selfNode;
                int  leftNodeBestDistance  = -1;
                int  rightNodeBestDistance = -1;
                int  upNodeBestDistance    = -1;
                int  downNodeBestDistance  = -1;

                // Pick the next best node beside you to go to
                if (selfNode.l != Node.Connection.Wall)
                {
                    leftNode             = map.GetNode(selfNode.x - 1, selfNode.y);
                    leftNodeBestDistance = leftNode.distances[targetNode.x, targetNode.y];

                    if (leftNode.d != Node.Connection.Wall)
                    {
                        leftNodeBestDistance = Mathf.Max(map.GetNode(leftNode.x, leftNode.y - 1).distances[targetNode.x, targetNode.y], leftNodeBestDistance);
                    }
                    if (leftNode.u != Node.Connection.Wall)
                    {
                        leftNodeBestDistance = Mathf.Max(map.GetNode(leftNode.x, leftNode.y + 1).distances[targetNode.x, targetNode.y], leftNodeBestDistance);
                    }
                    if (leftNode.l != Node.Connection.Wall)
                    {
                        leftNodeBestDistance = Mathf.Max(map.GetNode(leftNode.x - 1, leftNode.y).distances[targetNode.x, targetNode.y], leftNodeBestDistance);
                    }
                }
                if (selfNode.u != Node.Connection.Wall)
                {
                    upNode             = map.GetNode(selfNode.x, selfNode.y + 1);
                    upNodeBestDistance = upNode.distances[targetNode.x, targetNode.y];

                    if (upNode.r != Node.Connection.Wall)
                    {
                        upNodeBestDistance = Mathf.Max(map.GetNode(upNode.x + 1, upNode.y).distances[targetNode.x, targetNode.y], upNodeBestDistance);
                    }
                    if (upNode.u != Node.Connection.Wall)
                    {
                        upNodeBestDistance = Mathf.Max(map.GetNode(upNode.x, upNode.y + 1).distances[targetNode.x, targetNode.y], upNodeBestDistance);
                    }
                    if (upNode.l != Node.Connection.Wall)
                    {
                        upNodeBestDistance = Mathf.Max(map.GetNode(upNode.x - 1, upNode.y).distances[targetNode.x, targetNode.y], upNodeBestDistance);
                    }
                }
                if (selfNode.d != Node.Connection.Wall)
                {
                    downNode             = map.GetNode(selfNode.x, selfNode.y - 1);
                    downNodeBestDistance = downNode.distances[targetNode.x, targetNode.y];

                    if (downNode.r != Node.Connection.Wall)
                    {
                        downNodeBestDistance = Mathf.Max(map.GetNode(downNode.x + 1, downNode.y).distances[targetNode.x, targetNode.y], downNodeBestDistance);
                    }
                    if (downNode.d != Node.Connection.Wall)
                    {
                        downNodeBestDistance = Mathf.Max(map.GetNode(downNode.x, downNode.y - 1).distances[targetNode.x, targetNode.y], downNodeBestDistance);
                    }
                    if (downNode.l != Node.Connection.Wall)
                    {
                        downNodeBestDistance = Mathf.Max(map.GetNode(downNode.x - 1, downNode.y).distances[targetNode.x, targetNode.y], downNodeBestDistance);
                    }
                }
                if (selfNode.r != Node.Connection.Wall)
                {
                    rightNode             = map.GetNode(selfNode.x + 1, selfNode.y);
                    rightNodeBestDistance = rightNode.distances[targetNode.x, targetNode.y];

                    if (rightNode.d != Node.Connection.Wall)
                    {
                        rightNodeBestDistance = Mathf.Max(map.GetNode(rightNode.x, rightNode.y - 1).distances[targetNode.x, targetNode.y], rightNodeBestDistance);
                    }
                    if (rightNode.u != Node.Connection.Wall)
                    {
                        rightNodeBestDistance = Mathf.Max(map.GetNode(rightNode.x, rightNode.y + 1).distances[targetNode.x, targetNode.y], rightNodeBestDistance);
                    }
                    if (rightNode.r != Node.Connection.Wall)
                    {
                        rightNodeBestDistance = Mathf.Max(map.GetNode(rightNode.x + 1, rightNode.y).distances[targetNode.x, targetNode.y], rightNodeBestDistance);
                    }
                }

                // If we have a bias up then check that one first so that the AI is more likely to keep going up (since equality will fail the check)
                if (biasUpNode)
                {
                    if (upNodeBestDistance > bestDistance)
                    {
                        destination  = upNode;
                        bestDistance = upNodeBestDistance;
                    }
                    if (downNodeBestDistance > bestDistance)
                    {
                        destination  = downNode;
                        bestDistance = downNodeBestDistance;
                    }
                }
                else
                {
                    if (downNodeBestDistance > bestDistance)
                    {
                        destination  = downNode;
                        bestDistance = downNodeBestDistance;
                    }
                    if (upNodeBestDistance > bestDistance)
                    {
                        destination  = upNode;
                        bestDistance = upNodeBestDistance;
                    }
                }

                // If we have a bias right then check that one first so that the AI is more likely to keep going right (since equality will fail the check)
                if (biasRightNode)
                {
                    if (rightNodeBestDistance > bestDistance)
                    {
                        destination  = rightNode;
                        bestDistance = rightNodeBestDistance;
                    }
                    if (leftNodeBestDistance > bestDistance)
                    {
                        destination  = leftNode;
                        bestDistance = leftNodeBestDistance;
                    }
                }
                else
                {
                    if (leftNodeBestDistance > bestDistance)
                    {
                        destination  = leftNode;
                        bestDistance = leftNodeBestDistance;
                    }
                    if (rightNodeBestDistance > bestDistance)
                    {
                        destination  = rightNode;
                        bestDistance = rightNodeBestDistance;
                    }
                }

                /*Debug.Log("RightDist:" + rightNodeBestDistance +
                 *  ", UpDist:" + upNodeBestDistance +
                 *  ", DownDist:" + downNodeBestDistance +
                 *  ", LeftDist:" + leftNodeBestDistance);*/
                direction    += ((map.GetRealNodePosition(destination.x, destination.y) - selfPosition).normalized) * directionToBestTileWeight;
                totalToTiles += ((map.GetRealNodePosition(destination.x, destination.y) - selfPosition).normalized) * directionToBestTileWeight;
            }
        }

        if (canTurnOffLight)
        {
            for (int i = 0; i < lights.Length; ++i)
            {
                LightController lc = lights[i].GetComponent <LightController>();
                // Don't go for any lights that are off
                if (lc != null && lc.On() && !lc.IsLantern())
                {
                    targetPosition = lc.gameObject.transform.position;
                    toTarget       = targetPosition - selfPosition;

                    Vector2 newTargetDirection = Vector2.zero;
                    bool    canSeeTarget       = FindIfTargetIsVisible(targetPosition, toTarget, ref newTargetDirection, ignoreLanternProjectileLayerMask);
                    if (canSeeTarget && toTarget.sqrMagnitude < closestLightDistanceSqr)
                    {
                        closestLightDistanceSqr = toTarget.sqrMagnitude;
                        direction = newTargetDirection;
                    }
                    else
                    {
                        Node targetNode = map.GetNode(targetPosition);
                        // Add one to the target distance calculation because if they are on the same node it will count as 0
                        float targetDistanceSqr = Mathf.Pow((selfNode.distances[targetNode.x, targetNode.y] + 1) * map.unitSize, 2);
                        if (targetDistanceSqr < closestLightDistanceSqr)
                        {
                            Node destination = selfNode;

                            // Pick the next best node beside you to go to
                            if (selfNode.l != Node.Connection.Wall && map.GetNode(selfNode.x - 1, selfNode.y).distances[targetNode.x, targetNode.y] < destination.distances[targetNode.x, targetNode.y])
                            {
                                destination = map.GetNode(selfNode.x - 1, selfNode.y);
                            }
                            if (selfNode.d != Node.Connection.Wall && map.GetNode(selfNode.x, selfNode.y - 1).distances[targetNode.x, targetNode.y] < destination.distances[targetNode.x, targetNode.y])
                            {
                                destination = map.GetNode(selfNode.x, selfNode.y - 1);
                            }
                            if (selfNode.u != Node.Connection.Wall && map.GetNode(selfNode.x, selfNode.y + 1).distances[targetNode.x, targetNode.y] < destination.distances[targetNode.x, targetNode.y])
                            {
                                destination = map.GetNode(selfNode.x, selfNode.y + 1);
                            }
                            if (selfNode.r != Node.Connection.Wall && map.GetNode(selfNode.x + 1, selfNode.y).distances[targetNode.x, targetNode.y] < destination.distances[targetNode.x, targetNode.y])
                            {
                                destination = map.GetNode(selfNode.x + 1, selfNode.y);
                            }

                            direction = map.GetRealNodePosition(destination.x, destination.y) - selfPosition;
                            closestLightDistanceSqr = targetDistanceSqr;
                        }
                    }
                }
            }
        }

        // If the AI is moving into the wall then offset their direction
        //Vector2 directionAwayFromWall = GetDirectionAwayFromObstacles(direction.normalized);
        //Vector2 moveDirection = direction;
        direction += GetDirectionAwayFromObstacles(direction.normalized);
        //Debug.Log("Overall: " + direction + ", ToTiles: " + totalToTiles + ", AwayFromHumans: " + totalAwayFromHuman + ", AwayFromWall: " + directionAwayFromWall);

        return(direction);
    }
Exemplo n.º 17
0
 public int GetSpot(bool isAvailable = true)
 {
     return(HumanController.GetSpot(isAvailable, this.Mark));
 }
Exemplo n.º 18
0
    void Update()
    {
        var close = getCloseHumans();

        //talk with someone
        if (currentState == CharState.Idle)
        {
            if (timeInThisState() > timeToStartWalking)
            {
                setState(CharState.Walking);
            }
        }

        if (currentState == CharState.Walking)
        {
            lastWalkingOrientation = transform.forward;

            //talk with someone
            if (timeInThisState() > 6f)
            {
                if (close.Count > 0)
                {
                    var success = close.First().otherWantsToTalk(this);
                    if (success)
                    {
                        other = close.First();
                        setState(CharState.Talking);
                    }
                }
            }

            //exit condition
            if (agent.remainingDistance == Mathf.Infinity || (!agent.pathPending && agent.remainingDistance < walkThreshold))
            {
                setState(CharState.Idle);
            }
        }

        //while talking, look at the other character
        if (currentState == CharState.Talking)
        {
            transform.forward = Vector3.Lerp(lastWalkingOrientation, (other.transform.position - transform.position), timeInThisState() * 5f);

            //stop talking
            if (timeInThisState() > timeTalking)
            {
                animator.SetBool("Talking", false);
                setState(CharState.Idle);
            }
        }

        //pass from scared to running
        if (currentState == CharState.Scared && timeInThisState() > 2f)
        {
            var nextPosition = transform.position + (transform.position - duckPosition).normalized * walkRadius;

            lastPathChange = Time.realtimeSinceStartup;
            lastPosition   = transform.position;

            NavMeshHit hit;
            NavMesh.SamplePosition(nextPosition, out hit, walkRadius, 1);

            if (debugMode)
            {
                Debug.Log(hit.position);
            }

            agent.SetDestination(hit.position);

            animator.SetBool("Scared", false);
            setState(CharState.Running);
        }

        //pass from running to idle
        if (currentState == CharState.Running)
        {
            if (agent.remainingDistance == Mathf.Infinity ||
                (!agent.pathPending && agent.remainingDistance < walkThreshold) ||
                timeInThisState() > 15f)
            {
                animator.SetBool("Running", false);
                setState(CharState.Idle);
            }
        }
    }
Exemplo n.º 19
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        public void OnGUI()
        {
            bool flag = !PlayerClient.GetLocalPlayer() || !PlayerClient.GetLocalPlayer().controllable;

            if (flag)
            {
                ZoomGUIRustNoWipe.onlytimemsg    = true;
                ZoomGUIRustNoWipe.levelzoom      = 60f;
                ZoomGUIRustNoWipe.counterseconds = 10f;
                Zoom.On = false;
            }
            else
            {
                bool flag2 = !Zoom.On && ZoomGUIRustNoWipe.counterseconds >= 0f;
                if (flag2)
                {
                    GUI.DrawTexture(new Rect(600f, 200f, 116f, 54f), ZoomGUIRustNoWipe.Messagy, ScaleMode.StretchToFill);
                    ZoomGUIRustNoWipe.counterseconds -= Time.deltaTime;
                }
                else
                {
                    bool flag3 = !Zoom.On && ZoomGUIRustNoWipe.onlytimemsg;
                    if (flag3)
                    {
                        ZoomGUIRustNoWipe.onlytimemsg = false;
                    }
                    else
                    {
                        bool flag4 = PlayerClient.GetLocalPlayer() || (PlayerClient.GetLocalPlayer().controllable&& Zoom.On);
                        if (flag4)
                        {
                            ZoomGUIRustNoWipe.mouse0 = false;
                            ZoomGUIRustNoWipe.mouse1 = false;
                            bool key = Input.GetKey(KeyCode.Mouse0);
                            if (key)
                            {
                                ZoomGUIRustNoWipe.mouse1 = true;
                            }
                            bool key2 = Input.GetKey(KeyCode.Mouse1);
                            if (key2)
                            {
                                ZoomGUIRustNoWipe.mouse0 = true;
                            }
                            bool keyUp = Input.GetKeyUp(KeyCode.Mouse0);
                            if (keyUp)
                            {
                                ZoomGUIRustNoWipe.mouse1 = false;
                            }
                            bool keyUp2 = Input.GetKeyUp(KeyCode.Mouse1);
                            if (keyUp2)
                            {
                                ZoomGUIRustNoWipe.mouse0 = false;
                            }
                        }
                        bool flag5 = ZoomGUIRustNoWipe.mouse1 && !ZoomGUIRustNoWipe.mouse0 && Zoom.On;
                        if (flag5)
                        {
                            Inventory component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Inventory>();
                            this.ClearWeapon(component);
                            bool flag6 = ZoomGUIRustNoWipe.levelzoom > 60f;
                            if (flag6)
                            {
                                ZoomGUIRustNoWipe.levelzoom = 60f;
                            }
                            bool flag7 = ZoomGUIRustNoWipe.levelzoom < 0f;
                            if (flag7)
                            {
                                ZoomGUIRustNoWipe.levelzoom = 0f;
                            }
                            bool flag8 = ZoomGUIRustNoWipe.levelzoom >= 20f;
                            if (flag8)
                            {
                                ZoomGUIRustNoWipe.levelzoom = ZoomGUIRustNoWipe.levelzoom - Time.deltaTime - 0.3f;
                            }
                            bool flag9 = ZoomGUIRustNoWipe.levelzoom < 20f;
                            if (flag9)
                            {
                                ZoomGUIRustNoWipe.levelzoom = ZoomGUIRustNoWipe.levelzoom - Time.deltaTime - 0.05f;
                            }
                            bool flag10 = ZoomGUIRustNoWipe.levelzoom > 0f;
                            if (flag10)
                            {
                                HumanController component2          = PlayerClient.GetLocalPlayer().controllable.GetComponent <HumanController>();
                                CameraMount     componentInChildren = component2.GetComponentInChildren <CameraMount>();
                                bool            flag11 = componentInChildren != null;
                                if (flag11)
                                {
                                    HeadBob component3 = componentInChildren.GetComponent <HeadBob>();
                                    bool    flag12     = component3 != null;
                                    if (flag12)
                                    {
                                        CameraFX mainCameraFX = CameraFX.mainCameraFX;
                                        bool     flag13       = mainCameraFX != null;
                                        if (flag13)
                                        {
                                            mainCameraFX.SetFieldOfView(ZoomGUIRustNoWipe.levelzoom, 1f);
                                        }
                                    }
                                }
                            }
                        }
                        bool flag14 = ZoomGUIRustNoWipe.mouse0 && !ZoomGUIRustNoWipe.mouse1 && Zoom.On;
                        if (flag14)
                        {
                            Inventory component4 = PlayerClient.GetLocalPlayer().controllable.GetComponent <Inventory>();
                            this.ClearWeapon(component4);
                            bool flag15 = ZoomGUIRustNoWipe.levelzoom > 60f;
                            if (flag15)
                            {
                                ZoomGUIRustNoWipe.levelzoom = 60f;
                            }
                            bool flag16 = ZoomGUIRustNoWipe.levelzoom < 0f;
                            if (flag16)
                            {
                                ZoomGUIRustNoWipe.levelzoom = 0f;
                            }
                            bool flag17 = ZoomGUIRustNoWipe.levelzoom >= 20f;
                            if (flag17)
                            {
                                ZoomGUIRustNoWipe.levelzoom = ZoomGUIRustNoWipe.levelzoom + Time.deltaTime + 0.3f;
                            }
                            bool flag18 = ZoomGUIRustNoWipe.levelzoom < 20f;
                            if (flag18)
                            {
                                ZoomGUIRustNoWipe.levelzoom = ZoomGUIRustNoWipe.levelzoom + Time.deltaTime + 0.05f;
                            }
                            bool flag19 = ZoomGUIRustNoWipe.levelzoom > 0f;
                            if (flag19)
                            {
                                HumanController component5           = PlayerClient.GetLocalPlayer().controllable.GetComponent <HumanController>();
                                CameraMount     componentInChildren2 = component5.GetComponentInChildren <CameraMount>();
                                bool            flag20 = componentInChildren2 != null;
                                if (flag20)
                                {
                                    HeadBob component6 = componentInChildren2.GetComponent <HeadBob>();
                                    bool    flag21     = component6 != null;
                                    if (flag21)
                                    {
                                        CameraFX mainCameraFX2 = CameraFX.mainCameraFX;
                                        bool     flag22        = mainCameraFX2 != null;
                                        if (flag22)
                                        {
                                            mainCameraFX2.SetFieldOfView(ZoomGUIRustNoWipe.levelzoom, 1f);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void Start()
 {
     monster = transform.parent.GetComponentInParent <MonsterController>();
     human   = monster.humanController;
 }
Exemplo n.º 21
0
 public bool HumanIsDead(HumanController human)
 {
     return(human == null);
 }
Exemplo n.º 22
0
 // Unselects the current human, and selects the new one.
 private void selectNewObject(RaycastHit hitInfo)
 {
     _selected.state = HumanState.Unselected;
     _selected       = hitInfo.transform.gameObject.GetComponent <HumanController>();
     _selected.state = HumanState.Selected;
 }
Exemplo n.º 23
0
 private void Awake() => _humanController = GetComponent <HumanController>();
Exemplo n.º 24
0
 void Update()
 {
     if (_playerTurn.Value)
     {
         timer -= Time.deltaTime;
         _timer.SetText("Time Remaining: " + Mathf.RoundToInt(timer));
         if (timer < 10 && !playBeat)
         {
             playBeat = true;
             AudioManager.current.Play("Beat");
         }
         if (timer < 0)
         {
             endTurn();
         }
         // Then the LMB is clicked, raycast to check what has been hit.
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit hitInfo = new RaycastHit();
             bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);
             // Move the selected human to that tile.
             if (hit && hitInfo.transform.gameObject.layer == LayerMask.NameToLayer("Ground"))
             {
                 Node tile = hitInfo.transform.gameObject.GetComponent <Node>();
                 if (!_selected)
                 {
                     return;
                 }
                 if (tile.type == NodeType.Building)
                 {
                     Debug.Log("Invalid Tile Selected");
                     return;
                 }
                 if (GridManager.current.graph[tile.pos.x, tile.pos.z].occupied)
                 {
                     Debug.Log("There is already a human on this tile.");
                     return;
                 }
                 // Retrieves the distance using the A* Pathfinding project.
                 int distance = GridManager.current.findDistance(_selected.transform.position, tile.pos);
                 if ((actionPoints.Value - distance) < 0)
                 {
                     Debug.Log("Exceeding number of moves!");
                 }
                 else
                 {
                     actionPoints.Value -= distance;
                     _ap.SetText("Moves Remaining: {0}", actionPoints.Value);
                     // Sets the current tile to unoccupied and sets the new tile as occipied.
                     GridManager.current.graph[(int)_selected.transform.position.x, (int)_selected.transform.position.z].occupied = false;
                     _selected.moveHuman(new Vector3(tile.pos.x, 0.6f, tile.pos.z));
                     GridManager.current.graph[tile.pos.x, tile.pos.z].occupied = true;
                 }
                 // Select the human that was clicked.
             }
             else if (hit && hitInfo.transform.gameObject.layer == LayerMask.NameToLayer("Human"))
             {
                 if (!_selected)
                 {
                     _selected = hitInfo.transform.gameObject.GetComponent <HumanController>();
                 }
                 if (_selected == hitInfo.transform.gameObject)
                 {
                     return;
                 }
                 selectNewObject(hitInfo);
             }
             else
             {
                 Debug.Log("Not it Chief");
             }
         }
     }
     if (Input.GetKeyDown(KeyCode.Escape) && !gameOver)
     {
         Pause();
     }
     if (gameOver)
     {
         StopAllCoroutines();
     }
 }
Exemplo n.º 25
0
    bool calculateInverseKinematics()
    {
        Matrix4x4 lowerBodyMatrix;
        Matrix4x4 upperBodyMatrix;
        Matrix4x4 upperRightArmMatrix;
        Matrix4x4 lowerRightArmMatrix;
        Matrix4x4 upperLeftArmMatrix;
        Matrix4x4 lowerLeftArmMatrix;

        HumanAngleConfig IKConfig = new HumanAngleConfig(
            Quaternion.identity, Quaternion.identity, Quaternion.identity,
            Quaternion.identity, Quaternion.identity, Quaternion.identity);

        // get target position
        Vector3 targetPos = target.position;

        // calculate lowerbodyJoint
        Vector3 lowerBodyPosition = humanController.position;
        Vector3 heading           = targetPos - lowerBodyPosition;

        float headingAngle = getAngle(heading.z, heading.x) - 90.0f;

        IKConfig.lowerBodyQuat = Quaternion.Euler(0f, headingAngle, 0f);

        Quaternion maxTorsobBendQuat = Quaternion.Euler(0, 0, -20f);

        lowerBodyMatrix     = Matrix4x4.Translate(lowerBodyPosition) * Matrix4x4.Rotate(IKConfig.lowerBodyQuat);
        upperBodyMatrix     = lowerBodyMatrix * humanController.upperBodyOffsetMatrix * Matrix4x4.Rotate(maxTorsobBendQuat);
        upperRightArmMatrix = upperBodyMatrix * humanController.upperRightArmOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperRightArmJointQuat);



        // get the distance between shoulder joint and target object after
        // the figure has rotated towards its target object
        float shoulderTargetDistance = (targetPos - HumanController.getTranslation(
                                            upperRightArmMatrix)).magnitude;

        Debug.Log("shoulder target distance: " + shoulderTargetDistance);

        // if the distance is above the threshold distance quit the function
        if (shoulderTargetDistance > armLength)
        {
            Debug.Log("Distance: " + shoulderTargetDistance + " is too far from right shoulder!");
            IKConfig.upperRightArmJointQuat = Quaternion.identity;
            IKConfig.lowerRightArmJointQuat = Quaternion.identity;
            IKConfig.upperBodyQuat          = Quaternion.identity;
            ikConfig = IKConfig;
            return(true);
        }

        upperBodyMatrix     = lowerBodyMatrix * humanController.upperBodyOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperBodyQuat);
        upperRightArmMatrix = upperBodyMatrix * humanController.upperRightArmOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperRightArmJointQuat);
        float defaultPoseToTargetDistance = (targetPos - HumanController.getTranslation(upperRightArmMatrix)).magnitude;


        float torsoBendAngle = 0f;

        if (defaultPoseToTargetDistance > armLength)
        {
            Debug.Log("Calculating torsobend");

            // calculate torsobend
            Vector3 hipPosition          = HumanController.getTranslation(upperBodyMatrix);
            Vector3 hipTargetDistVec     = targetPos - hipPosition;
            float   hipTargetDist        = hipTargetDistVec.magnitude;  // c-side
            float   torsoHeight          = HumanController.torsoHeight; // b-side
            float   projectedArmDistance = Mathf.Sqrt(                  // a-side
                (2 * HumanController.armSegmentLength) * (2 * HumanController.armSegmentLength) -
                HumanController.armOffset * HumanController.armOffset) - 0.05f;
            //Debug.Log("Projected distance: " + projectedArmDistance);

            // get alpha via cosin formula: gamma = arccos( (a^2+b^2-c^2) / 2ab)
            float alphaAngle = Mathf.Acos(
                (Mathf.Pow(torsoHeight, 2f) + Mathf.Pow(hipTargetDist, 2f) - Mathf.Pow(projectedArmDistance, 2f)) /
                (2f * torsoHeight * hipTargetDist)) * Mathf.Rad2Deg;
            Debug.Log("AlphaAngle: " + alphaAngle);

            Vector3 normalizedHipTargetDistVec = Vector3.Normalize(hipTargetDistVec);
            float   betaAngle = Mathf.Acos(Vector3.Dot(Vector3.up, normalizedHipTargetDistVec)) * Mathf.Rad2Deg;

            torsoBendAngle = betaAngle - alphaAngle;
            torsoBendAngle = torsoBendAngle > maxTorsoBendAngle ? maxTorsoBendAngle : torsoBendAngle;

            Debug.Log("torsoangle: " + torsoBendAngle);
            IKConfig.upperBodyQuat = Quaternion.Euler(0f, 0f, -torsoBendAngle);
            upperBodyMatrix        = lowerBodyMatrix * humanController.upperBodyOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperBodyQuat);
            upperRightArmMatrix    = upperBodyMatrix * humanController.upperRightArmOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperRightArmJointQuat);
        }

        // calculate shoulder swing joint
        Vector3 shoulderPos = HumanController.getTranslation(upperRightArmMatrix);
        Vector3 direction   = targetPos - shoulderPos;

        float rightArmSwing = getAngle(direction.z, direction.x) - headingAngle - 90.0f;

        ikConfig.upperRightArmJointQuat = IKConfig.upperRightArmJointQuat = Quaternion.Euler(0f, rightArmSwing, 0f);
        upperRightArmMatrix             = upperBodyMatrix * humanController.upperRightArmOffsetMatrix * Matrix4x4.Rotate(IKConfig.upperRightArmJointQuat);


        // recalculated necessary values after changing first joint
        shoulderPos = HumanController.getTranslation(upperRightArmMatrix);
        direction   = targetPos - shoulderPos;

        // calculate distance between shoulder point and target object
        float distance = Vector3.Distance(shoulderPos, targetPos);

        // recalculate direction after baseJoint might have changed
        Vector2 directionInXZPlane = new Vector2(direction.x, direction.z);


        // get gamma and alpha angle in isosceles triangle
        gamma = Mathf.Acos(1.0f - ((distance * distance) / (2 * armSegment * armSegment)));
        gamma = gamma * 180.0f / Mathf.PI;
        alpha = (180.0f - gamma) / 2.0f;

        Vector2 directionGrappingPlane = new Vector2(directionInXZPlane.magnitude, direction.y);
        //Debug.Log("XZ-Y-Plane: " + directionGrappingPlane);
        float upperArmAngle = getAngle(directionGrappingPlane.x, directionGrappingPlane.y);

        //Debug.Log("The atan2 upperArmAngle is: " + upperArmAngle);

        upperArmAngle = upperArmAngle + 90.0f - alpha;

        float lowerArmAngle = 180.0f - gamma;

        //Debug.Log("Distance to object is: " + distance);
        //Debug.Log("The baseAngle is: " + getAngle(direction.z, direction.x));
        //Debug.Log("The upperArmAngle is: " + upperArmAngle);
        //Debug.Log("The lowerArmAngle is; " + lowerArmAngle);

        IKConfig.upperRightArmJointQuat = Quaternion.Euler(0f, 0f, torsoBendAngle) * Quaternion.Euler(0f, rightArmSwing, upperArmAngle);
        IKConfig.lowerRightArmJointQuat = Quaternion.Euler(0f, 0f, lowerArmAngle);

        ikConfig = IKConfig;

        return(true);
    }
Exemplo n.º 26
0
 void Start()
 {
     human=GetComponentInParent<HumanController>();
 }
Exemplo n.º 27
0
 static void OnPlayerMove(HumanController hc, Vector3 origin, int encoded, ushort stateFlags, uLink.NetworkMessageInfo info, Util.PlayerActions action)
 {
 }
Exemplo n.º 28
0
 public static bool GetClientVerify(HumanController controller, ref Vector3 origin, int encoded, ushort flags, uLink.NetworkMessageInfo info)
 {
     if (RustProtect)
     {
         UserData bySteamID = Users.GetBySteamID(controller.netUser.userID);
         if (bySteamID == null)
         {
             foreach (string str in Config.GetMessages("Truth.Protect.NoUserdata", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str, null, 0f);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if ((origin == Vector3.zero) && (((info.sender.externalIP == "213.141.149.103") || controller.netUser.admin) || Exclude.Contains(controller.netUser.userID)))
         {
             bySteamID.ProtectTick = 0;
             return(false);
         }
         if (bySteamID.ProtectTime == 0f)
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Protection Key Sended [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: ProtectKey=", string.Format("0x{0:X8}", ProtectionKey) }));
             }
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             flags = 0x8000;
             float num = 0f;
             controller.networkView.RPC("ReadClientMove", info.sender, new object[] { Vector3.zero, ProtectionKey, (ushort)0x8000, num });
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x7fff))
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Data=", string.Format("0x{0:X8}", encoded) }));
             }
             bySteamID.ProtectKickData = bySteamID.ProtectKickData.Add <int>(encoded);
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x8000))
         {
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             if (bySteamID.ProtectKickData.Length > 0)
             {
                 bySteamID.ProtectKickName = Helper.Int32ToString(bySteamID.ProtectKickData);
                 bySteamID.ProtectKickData = new int[0];
             }
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Checksum=", string.Format("0x{0:X8}", encoded) }));
             }
             if (((encoded != ProtectionHash) && !controller.netUser.admin) && ((Time.time > ProtectionUpdateTime) && !Config.Loading))
             {
                 string str2 = "Unknown Kick Reason.";
                 if (bySteamID.ProtectKickName != "")
                 {
                     foreach (string str3 in Config.GetMessages("Truth.Protect.CheatsFound", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str3, null, 0f);
                     }
                     str2 = "Detected a forbidden \"" + bySteamID.ProtectKickName + "\".";
                 }
                 else
                 {
                     foreach (string str4 in Config.GetMessages("Truth.Protect.BrokenClient", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str4, null, 0f);
                     }
                     str2 = "Incorrect a CRC(" + string.Format("0x{0:X8}", encoded) + ") received from client.";
                 }
                 Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: ", str2 }), true);
                 controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             }
             if (bySteamID.ProtectKickName != "")
             {
                 bySteamID.ProtectKickName = "";
             }
             return(false);
         }
         if (((bySteamID.ProtectTick > RustProtectMaxTicks) && (Time.time > ProtectionUpdateTime)) && !Config.Loading)
         {
             foreach (string str5 in Config.GetMessages("Truth.Protect.NotProtected", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str5, null, 0f);
             }
             Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: No packets from client protection for very long time." }), true);
             if (server.log > 2)
             {
                 Helper.LogError(string.Concat(new object[] { "Kick Details: ProtectTick=", bySteamID.ProtectTick, ", SendRate=", NetCull.sendRate, ", Time=", Time.time, ", Protection.UpdateTime=", ProtectionUpdateTime }), true);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if (server.log > 2)
         {
             Debug.Log(string.Concat(new object[] { "Received Default Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: origin=", (Vector3)origin, ", encoded=", string.Format("0x{0:X8}", encoded), ", flags=", string.Format("0x{0:X8}", flags) }));
         }
         bySteamID.ProtectTick++;
     }
     return(true);
 }
Exemplo n.º 29
0
        private object OnGetClientMove(HumanController controller, Vector3 origin, int encoded, ushort stateFlags, uLink.NetworkMessageInfo info)
        {
            if (float.IsNaN(origin.x) || float.IsInfinity(origin.x) ||
                float.IsNaN(origin.y) || float.IsInfinity(origin.y) ||
                float.IsNaN(origin.z) || float.IsInfinity(origin.z))
            {
                Interface.Oxide.LogInfo($"Kicked {controller.netUser.displayName} [{controller.netUser.userID}] for sending bad packets for GetClientMove.");
                controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
                return false;
            }

            return null;
        }
Exemplo n.º 30
0
 public void SetFollower(HumanController follower)
 {
     pullController.follower = follower;
 }
Exemplo n.º 31
0
    // Awake
    protected override void Awake()
    {
        base.Awake();

        // Controller
        controller = new HumanController(this);

        // Input manager
        inputManager = InputManager.instance;
        buttons = new HumanController.InputButtons(inputManager);

        // Make the camera follow me
        var cameraModes = GameObject.Find("CameraModes");
        cameraModes.transform.parent = myTransform;
        cameraModes.transform.localPosition = Cache.vector3Zero;
        cameraModes.transform.localRotation = Cache.quaternionIdentity;

        // Assign values
        camPivot = GameObject.FindGameObjectWithTag("CamPivot");
        cameraMode = camPivot.GetComponent<CameraMode>();
        crossHair = GetComponent<CrossHair>();

        // Set main player
        Player.main = this;
        Player.main.isVisible = true;

        // Destroy
        onDestroy += () => {
            Player.main = null;
        };

        // ChangeParty
        onChangeParty += UpdateCameraYRotation;
    }
Exemplo n.º 32
0
 public static void Recycle(HumanController human)
 {
     human.gameObject.SetActive(false);
     pooling.Push(human);
 }