Exemplo n.º 1
0
    public override void SetAimDirection(Vector3 newAim)
    {
        if (Vector3.op_Equality(newAim, Vector3.get_zero()))
        {
            return;
        }
        AttackEntity attackEntity = this.GetAttackEntity();

        if (Object.op_Implicit((Object)attackEntity))
        {
            newAim = attackEntity.ModifyAIAim(newAim, this.GetAimSwayScalar());
        }
        if (this.isMounted)
        {
            BaseMountable mounted     = this.GetMounted();
            Vector3       eulerAngles = ((Component)mounted).get_transform().get_eulerAngles();
            Quaternion    quaternion1 = Quaternion.LookRotation(newAim, ((Component)mounted).get_transform().get_up());
            Quaternion    quaternion2 = Quaternion.LookRotation(((Component)this).get_transform().InverseTransformDirection(Quaternion.op_Multiply(Quaternion.Euler(((Quaternion) ref quaternion1).get_eulerAngles()), Vector3.get_forward())), ((Component)this).get_transform().get_up());
            Vector3       vector3     = BaseMountable.ConvertVector(((Quaternion) ref quaternion2).get_eulerAngles());
            Quaternion    quaternion3 = Quaternion.LookRotation(((Component)this).get_transform().TransformDirection(Quaternion.op_Multiply(Quaternion.Euler(Mathf.Clamp((float)vector3.x, (float)mounted.pitchClamp.x, (float)mounted.pitchClamp.y), Mathf.Clamp((float)vector3.y, (float)mounted.yawClamp.x, (float)mounted.yawClamp.y), (float)eulerAngles.z), Vector3.get_forward())), ((Component)this).get_transform().get_up());
            newAim = BaseMountable.ConvertVector(((Quaternion) ref quaternion3).get_eulerAngles());
        }
        this.eyes.rotation = this.isMounted ? Quaternion.Slerp(this.eyes.rotation, Quaternion.Euler(newAim), Time.get_smoothDeltaTime() * 70f) : Quaternion.Lerp(this.eyes.rotation, Quaternion.LookRotation(newAim, ((Component)this).get_transform().get_up()), Time.get_deltaTime() * 25f);
        Quaternion rotation = this.eyes.rotation;

        this.viewAngles     = ((Quaternion) ref rotation).get_eulerAngles();
        this.ServerRotation = this.eyes.rotation;
    }
Exemplo n.º 2
0
        void OnEntityMounted(BaseMountable entity, BasePlayer player)
        {
            if (entity == null | player == null)
            {
                return;
            }

            if (!permission.UserHasPermission(player.UserIDString, perm))
            {
                return;
            }

            if (GetPlayer(player))
            {
                RemoveVehicleByPlayer(player);
            }

            if (onlyDriver)
            {
                if (!(entity.ShortPrefabName == "miniheliseat" | entity.ShortPrefabName == "standingdriver" | entity.ShortPrefabName == "smallboatdriver"))
                {
                    return;
                }
            }

            VehicleCache vehicle = new VehicleCache();

            vehicle.player = player;
            vehicle.entity = entity;
            vehicles.Add(vehicle);

            CreateUI(vehicle);
        }
Exemplo n.º 3
0
    public override void SeatClippedWorld(BaseMountable mountable)
    {
        BasePlayer mounted = mountable.GetMounted();

        if (mounted == null)
        {
            return;
        }
        if (this.IsDriver(mounted))
        {
            this.steering = 0f;
            this.gasPedal = 0f;
        }
        Vector3 vector3 = this.myRigidBody.velocity;
        float   single  = Mathf.InverseLerp(4f, 20f, vector3.magnitude);

        if (single > 0f)
        {
            mounted.Hurt(single * 100f, DamageType.Blunt, this, false);
        }
        if (mounted != null && mounted.isMounted)
        {
            base.SeatClippedWorld(mountable);
        }
    }
Exemplo n.º 4
0
        void OnEntityDismounted(BaseMountable entity, BasePlayer player)
        {
            // What the player is mounting is not the MiniCopter for this mission
            if (entity == null || MiniCopter == null)
            {
                return;
            }

            if (!entity.HasParent() || MiniCopter.GetInstanceID() != entity.parentEntity.Get(true).GetInstanceID())
            {
                return;
            }

            if (Driver && Driver.userID == player.userID)
            {
                RemovePlayer(Driver, true);
                Driver = null;
            }

            if (Passengers.FirstOrDefault(x => x.userID == player.userID) != null)
            {
                RemovePlayer(player, true);
                Passengers.Remove(player);
            }
        }
Exemplo n.º 5
0
    public override void SeatClippedWorld(BaseMountable mountable)
    {
        BasePlayer mounted = mountable.GetMounted();

        if (Object.op_Equality((Object)mounted, (Object)null))
        {
            return;
        }
        if (this.IsDriver(mounted))
        {
            this.steering = 0.0f;
            this.gasPedal = 0.0f;
        }
        Vector3 velocity = this.myRigidBody.get_velocity();
        float   num      = Mathf.InverseLerp(4f, 20f, ((Vector3) ref velocity).get_magnitude());

        if ((double)num > 0.0)
        {
            mounted.Hurt(num * 100f, DamageType.Blunt, (BaseEntity)this, false);
        }
        if (!Object.op_Inequality((Object)mounted, (Object)null) || !mounted.isMounted)
        {
            return;
        }
        base.SeatClippedWorld(mountable);
    }
 void OnEntityDismounted(BaseMountable entity, BasePlayer player)
 {
     if (config.flyHackPause > 0 && entity is MiniCopter)
     {
         player.PauseFlyHackDetection(config.flyHackPause);
     }
 }
Exemplo n.º 7
0
        public static void swapseats(ConsoleSystem.Arg arg)
        {
            int        num        = 0;
            BasePlayer basePlayer = arg.Player();

            if (basePlayer == null)
            {
                return;
            }
            if (basePlayer.SwapSeatCooldown())
            {
                return;
            }
            BaseMountable mounted = basePlayer.GetMounted();

            if (mounted == null)
            {
                return;
            }
            BaseVehicle component = mounted.GetComponent <BaseVehicle>();

            if (component == null)
            {
                component = mounted.VehicleParent();
            }
            if (component == null)
            {
                return;
            }
            component.SwapSeats(basePlayer, num);
        }
Exemplo n.º 8
0
 public override void SetAimDirection(Vector3 newAim)
 {
     if (!(newAim == Vector3.zero))
     {
         float num = UnityEngine.Time.time - lastAimSetTime;
         lastAimSetTime = UnityEngine.Time.time;
         AttackEntity attackEntity = GetAttackEntity();
         if ((bool)attackEntity)
         {
             newAim = attackEntity.ModifyAIAim(newAim, GetAimSwayScalar());
         }
         if (base.isMounted)
         {
             BaseMountable baseMountable = GetMounted();
             Vector3       eulerAngles   = baseMountable.transform.eulerAngles;
             Quaternion    quaternion    = Quaternion.Euler(Quaternion.LookRotation(newAim, baseMountable.transform.up).eulerAngles);
             Vector3       eulerAngles2  = Quaternion.LookRotation(base.transform.InverseTransformDirection(quaternion * Vector3.forward), base.transform.up).eulerAngles;
             eulerAngles2 = BaseMountable.ConvertVector(eulerAngles2);
             Quaternion quaternion2 = Quaternion.Euler(Mathf.Clamp(eulerAngles2.x, baseMountable.pitchClamp.x, baseMountable.pitchClamp.y), Mathf.Clamp(eulerAngles2.y, baseMountable.yawClamp.x, baseMountable.yawClamp.y), eulerAngles.z);
             newAim = BaseMountable.ConvertVector(Quaternion.LookRotation(base.transform.TransformDirection(quaternion2 * Vector3.forward), base.transform.up).eulerAngles);
         }
         eyes.rotation  = (base.isMounted ? Quaternion.Slerp(eyes.rotation, Quaternion.Euler(newAim), num * 70f) : Quaternion.Lerp(eyes.rotation, Quaternion.LookRotation(newAim, base.transform.up), num * 25f));
         viewAngles     = eyes.rotation.eulerAngles;
         ServerRotation = eyes.rotation;
     }
 }
Exemplo n.º 9
0
 void OnEntityDismounted(BaseMountable entity, BasePlayer player)
 {
     if (pilots.ContainsKey(player.userID))
     {
         pilots.Remove(player.userID);
     }
 }
Exemplo n.º 10
0
        private object CanMountEntity(BaseMountable mountable, BasePlayer player)
        {
            CarController controller = mountable.GetComponent <CarController>();

            if (controller != null)
            {
                if (player.isMounted)
                {
                    return(false);
                }

                if (controller.isDying)
                {
                    return(false);
                }

                CarController.MountPoint mountPoint = controller.GetClosestMountPoint(player.transform.position);
                if (mountPoint != null && !mountPoint.Entity.IsMounted())
                {
                    mountPoint.MountPlayer(player);
                    return(false);
                }
            }

            return(null);
        }
        public static void NavigateToMountableLoc(NPCHumanContext c, HumanNavigateToOperator.OperatorType mountableType)
        {
            NavMeshHit navMeshHit;

            if (mountableType == HumanNavigateToOperator.OperatorType.MountableChair && ConVar.AI.npc_ignore_chairs)
            {
                return;
            }
            BaseMountable chairTarget = c.ChairTarget;

            if (chairTarget == null)
            {
                return;
            }
            Vector3 vector3 = chairTarget.transform.position;

            if (NavMesh.SamplePosition(vector3, out navMeshHit, 10f, c.Human.NavAgent.areaMask))
            {
                vector3 = navMeshHit.position;
            }
            if (Mathf.Approximately(vector3.sqrMagnitude, 0f))
            {
                return;
            }
            HumanNavigateToOperator.MakeUnstuck(c);
            c.Human.StoppingDistance = 0.05f;
            c.Human.Destination      = vector3;
            c.Human.SetTargetPathStatus(0.05f);
        }
        public static void NavigateToMountableLoc(
            NPCHumanContext c,
            HumanNavigateToOperator.OperatorType mountableType)
        {
            if (mountableType == HumanNavigateToOperator.OperatorType.MountableChair && ConVar.AI.npc_ignore_chairs)
            {
                return;
            }
            BaseMountable chairTarget = (BaseMountable)c.ChairTarget;

            if (Object.op_Equality((Object)chairTarget, (Object)null))
            {
                return;
            }
            Vector3    position = ((Component)chairTarget).get_transform().get_position();
            NavMeshHit navMeshHit;

            if (NavMesh.SamplePosition(position, ref navMeshHit, 10f, c.Human.NavAgent.get_areaMask()))
            {
                position = ((NavMeshHit) ref navMeshHit).get_position();
            }
            if (Mathf.Approximately(((Vector3) ref position).get_sqrMagnitude(), 0.0f))
            {
                return;
            }
            HumanNavigateToOperator.MakeUnstuck(c);
            c.Human.StoppingDistance = 0.05f;
            c.Human.Destination      = position;
            c.Human.SetTargetPathStatus(0.05f);
        }
Exemplo n.º 13
0
        public static void swapseats(ConsoleSystem.Arg arg)
        {
            int        targetSeat = 0;
            BasePlayer player     = arg.Player();

            if (Object.op_Equality((Object)player, (Object)null) || player.SwapSeatCooldown())
            {
                return;
            }
            BaseMountable mounted = player.GetMounted();

            if (Object.op_Equality((Object)mounted, (Object)null))
            {
                return;
            }
            BaseVehicle baseVehicle = (BaseVehicle)((Component)mounted).GetComponent <BaseVehicle>();

            if (Object.op_Equality((Object)baseVehicle, (Object)null))
            {
                baseVehicle = mounted.VehicleParent();
            }
            if (Object.op_Equality((Object)baseVehicle, (Object)null))
            {
                return;
            }
            baseVehicle.SwapSeats(player, targetSeat);
        }
Exemplo n.º 14
0
    public override void SetAimDirection(Vector3 newAim)
    {
        Quaternion quaternion;

        if (newAim == Vector3.zero)
        {
            return;
        }
        AttackEntity attackEntity = base.GetAttackEntity();

        if (attackEntity)
        {
            newAim = attackEntity.ModifyAIAim(newAim, this.GetAimSwayScalar());
        }
        if (base.isMounted)
        {
            BaseMountable mounted = base.GetMounted();
            Vector3       vector3 = mounted.transform.eulerAngles;
            quaternion = Quaternion.LookRotation(newAim, mounted.transform.up);
            Quaternion quaternion1 = Quaternion.Euler(quaternion.eulerAngles);
            Quaternion quaternion2 = Quaternion.LookRotation(base.transform.InverseTransformDirection(quaternion1 * Vector3.forward), base.transform.up);
            Vector3    vector31    = quaternion2.eulerAngles;
            vector31 = BaseMountable.ConvertVector(vector31);
            Quaternion quaternion3 = Quaternion.Euler(Mathf.Clamp(vector31.x, mounted.pitchClamp.x, mounted.pitchClamp.y), Mathf.Clamp(vector31.y, mounted.yawClamp.x, mounted.yawClamp.y), vector3.z);
            Quaternion quaternion4 = Quaternion.LookRotation(base.transform.TransformDirection(quaternion3 * Vector3.forward), base.transform.up);
            newAim = BaseMountable.ConvertVector(quaternion4.eulerAngles);
        }
        this.eyes.rotation  = (base.isMounted ? Quaternion.Slerp(this.eyes.rotation, Quaternion.Euler(newAim), UnityEngine.Time.smoothDeltaTime * 70f) : Quaternion.Lerp(this.eyes.rotation, Quaternion.LookRotation(newAim, base.transform.up), UnityEngine.Time.deltaTime * 25f));
        quaternion          = this.eyes.rotation;
        this.viewAngles     = quaternion.eulerAngles;
        this.ServerRotation = this.eyes.rotation;
    }
        object CanMountEntity(BasePlayer player, BaseMountable entity)
        {
            if (!(entity is MiniCopter) && !(entity.GetParentEntity() is MiniCopter))
            {
                return(null);
            }
            if (player.serverInput.IsDown(BUTTON.FIRE_PRIMARY) || player.serverInput.WasDown(BUTTON.FIRE_PRIMARY))
            {
                GetTargetEntity(player);
                return(false);
            }
            if (!IsBatEnabled())
            {
                return(null);
            }
            MiniCopter ent = entity.GetParentEntity() as MiniCopter;

            if (ent != null)
            {
                IOEntity ioe = GetBatteryConnected(ent);
                if (ioe != null)
                {
                    SendReply(player, GetMsg("Err - Diconnect Battery"), ioe.GetDisplayName());
                    return(false);
                }
            }
            return(null);
        }
Exemplo n.º 16
0
 bool CheckAnyRestrictionsMatched(List <Item> items, BasePlayer player, BaseMountable mountedEntity, bool alreadyMounted)
 {
     try {
         if (mountedEntity.ShortPrefabName != null)
         {
             string entityName = new Regex(@"\W").Replace(mountedEntity.ShortPrefabName, "");
             List <RestrictionSet> restrictionSets        = config.RestrictionSets;
             List <RestrictionSet> matchedRestrictionSets = restrictionSets.FindAll(restrictionSet => restrictionSet.restrictedItems != null &&
                                                                                    (restrictionSet.entityNames == null || restrictionSet.entityNames.Contains(entityName)) &&
                                                                                    restrictionSet.restrictedItems.FindAll(itemName => items.Exists(item => item.info.shortname == itemName)).Count > restrictionSet.maximumAllowed);
             if (matchedRestrictionSets.Count > 0)
             {
                 matchedRestrictionSets.ForEach(restrictionSet => player.ChatMessage(GetMessage(restrictionSet.langKey, player.UserIDString)));
                 return(true);
             }
         }
     } catch (Exception e) {
         ConfigExceptions++;
         Puts("Error - one or more restriction configurations is probably invalid {0}", e.ToString());
         if (ConfigExceptions >= 10)
         {
             Puts("Fatal Error - Max exceptions of 10 has been reached. Unsubscribing hooks. Fix configuration and reload plugin");
             Unsubscribe(nameof(CanMountEntity));
             Unsubscribe(nameof(CanWearItem));
         }
     }
     return(false);
 }
Exemplo n.º 17
0
 void OnEntityDismounted(BaseMountable entity, BasePlayer player)
 {
     if (GetPlayer(player))
     {
         RemoveVehicleByPlayer(player);
     }
 }
Exemplo n.º 18
0
        private void OnEntityMounted(BaseMountable entity, BasePlayer player)
        {
            var Entity = entity.GetParentEntity();

            if (Entity == null)
            {
                return;
            }
            var Prefab = Entity.PrefabName;

            if (!PrefabToPermission.ContainsKey(Prefab))
            {
                return;
            }

            if (_config.Disabled.Contains(Prefab))
            {
                return;
            }
            var Permission = PrefabToPermission[Prefab];

            if (!permission.UserHasPermission(player.UserIDString, Permission))
            {
                return;
            }
            Entity.gameObject.AddComponent <FuelVehicle>();
        }
        private static float IsInRange(NPCHumanContext c, BaseMountable mountable)
        {
            Vector3 vector3 = Vector3.op_Subtraction(((Component)mountable).get_transform().get_position(), c.Position);

            if (vector3.y > (double)mountable.maxMountDistance)
            {
                ref __Null local = ref vector3.y;
Exemplo n.º 20
0
    public override void AttemptMount(BasePlayer player)
    {
        if (this._mounted != null)
        {
            return;
        }
        if (!this.MountEligable())
        {
            return;
        }
        BaseMountable idealMountPoint = this.GetIdealMountPoint(player.eyes.position);

        if (idealMountPoint == null)
        {
            return;
        }
        if (idealMountPoint != this)
        {
            idealMountPoint.AttemptMount(player);
        }
        else
        {
            base.AttemptMount(player);
        }
        if (player.GetMountedVehicle() == this)
        {
            this.PlayerMounted(player, idealMountPoint);
        }
    }
Exemplo n.º 21
0
        void OnEntityDismounted(BaseMountable mountable, BasePlayer player)
        {
            var mini = mountable.GetComponentInParent <MiniCopter>() ?? null;

            if (mini != null)
            {
#if DEBUG
                Puts($"Player {player.userID.ToString()} dismounted seat id {mountable.net.ID.ToString()}");
#endif
                var id = mountable.net.ID - 2;
                for (int i = 0; i < 3; i++)
                {
                    // Find copter and seats in storedData
#if DEBUG
                    Puts($"Is this our copter with ID {id.ToString()}?");
#endif
                    if (storedData.playerminiID.ContainsValue(id))
                    {
#if DEBUG
                        Puts($"Removing {player.displayName}'s ID {player.userID} from currentMounts for seat {mountable.net.ID.ToString()} on {id}");
#endif
                        currentMounts.Remove(mountable.net.ID);
                        break;
                    }
                    id++;
                }
            }
            var myKey = currentMounts.FirstOrDefault(x => x.Value == player.userID).Key;
            currentMounts.Remove(myKey);
        }
Exemplo n.º 22
0
        void OnEntityMounted(BaseMountable mountable, BasePlayer player)
        {
            var mini = mountable.GetComponentInParent <MiniCopter>() ?? null;

            if (mini != null)
            {
#if DEBUG
                Puts($"Player {player.userID.ToString()} mounted seat id {mountable.net.ID.ToString()}");
#endif
                // Check this seat's ID to see if the copter is one of ours
                uint id = mountable.net.ID - 2; // max seat == copter.net.ID + 2, e.g. passenger seat id - 2 == copter id
                for (int i = 0; i < 3; i++)
                {
                    // Find copter in storedData
#if DEBUG
                    Puts($"Is this our copter with ID {id.ToString()}?");
#endif
                    if (storedData.playerminiID.ContainsValue(id))
                    {
#if DEBUG
                        Puts($"Removing {player.displayName}'s ID {player.userID} from currentMounts for seat {mountable.net.ID.ToString()} on {id}");
#endif
                        currentMounts.Remove(mountable.net.ID);
#if DEBUG
                        Puts($"Adding {player.displayName}'s ID {player.userID} to currentMounts for seat {mountable.net.ID.ToString()} on {id}");
#endif
                        currentMounts.Add(mountable.net.ID, player.userID);
                        break;
                    }
                    id++;
                }
            }
        }
Exemplo n.º 23
0
 public static bool Evaluate(
     BasePlayer self,
     Vector3 optionPosition,
     out Vector3 dir,
     out float dot)
 {
     BaseMountable mounted    = self.GetMounted();
     ref Vector3   local      = ref dir;
Exemplo n.º 24
0
 public virtual void PlayerDismounted(BasePlayer player, BaseMountable seat)
 {
     recentDrivers.Enqueue(player);
     if (!IsInvoking(clearRecentDriverAction))
     {
         Invoke(clearRecentDriverAction, 3f);
     }
 }
Exemplo n.º 25
0
        private void OnEntityDismounted(BaseMountable mountable, BasePlayer player)
        {
            CarController controller = mountable.GetComponent <CarController>();

            if (controller != null && controller.player == player)
            {
                controller.OnDriverExit();
            }
        }
Exemplo n.º 26
0
        private void OnEntityMounted(BaseMountable mountable, BasePlayer player)
        {
            CarController controller = mountable.VehicleParent()?.GetComponent <CarController>();

            if (controller != null && controller.player == null)
            {
                controller.OnDriverEnter(player);
            }
        }
Exemplo n.º 27
0
    public override void PrePlayerDismount(BasePlayer player, BaseMountable seat)
    {
        base.PrePlayerDismount(player, seat);
        CardTablePlayerStorage playerStorage = GetPlayerStorage(player.userID);

        if (playerStorage != null)
        {
            playerStorage.inventory.GetSlot(0)?.MoveToContainer(player.inventory.containerMain, -1, true, true);
        }
    }
Exemplo n.º 28
0
        private void OnEntityDismounted(BaseMountable mountable, BasePlayer player)
        {
            _MagicCarpet mc = mountable.GetComponent <_MagicCarpet>();

            if (!mc)
            {
                return;
            }
            mc.player = null;
        }
Exemplo n.º 29
0
        private void OnEntityDismounted(BaseMountable entity, BasePlayer player)
        {
            var FuelVehicle = entity.GetComponent <FuelVehicle>();

            if (!FuelVehicle)
            {
                return;
            }
            FuelVehicle.End(true);
        }
Exemplo n.º 30
0
        public static void DoAimbot()
        {
            Vector3 vector = GetEnemyVector();

            if (vector != Vector3.zero)
            {
                Quaternion rotation = Quaternion.LookRotation(vector, LocalPlayer.Entity.eyes.transform.up);
                LocalPlayer.Entity.input.SetViewVars(BaseMountable.ConvertVector(rotation.eulerAngles));
            }
        }