Пример #1
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            // Call out and see if we should reject
            var loginSpecific  = Interface.Call("CanClientLogin", connection);
            var loginCovalence = Interface.Call("CanUserLogin", connection.UserName, id, ip);
            var canLogin       = loginSpecific ?? loginCovalence;

            // Check if player can login
            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                // Reject the user with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin is string?canLogin.ToString() : "Connection was rejected", 10f);   // TODO: Localization
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            // Call the approval hooks
            var approvedSpecific  = Interface.Call("OnUserApprove", connection, approval, acceptor);
            var approvedCovalence = Interface.Call("OnUserApproved", connection.UserName, id, ip);

            return(approvedSpecific ?? approvedCovalence);
        }
Пример #2
0
    public override InventoryItem.MergeResult TryCombine(IInventoryItem otherItem)
    {
        PlayerInventory inventory = base.inventory as PlayerInventory;

        if ((inventory != null) && (otherItem.inventory == inventory))
        {
            ItemDataBlock datablock = otherItem.datablock;
            if ((datablock != null) && datablock.isResearchable)
            {
                BlueprintDataBlock block2;
                if (!inventory.AtWorkBench())
                {
                    Notice.Popup("", "You must be at a workbench to do this.", 4f);
                    return(InventoryItem.MergeResult.Failed);
                }
                if (!BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(otherItem.datablock, out block2))
                {
                    Notice.Popup("", "You can't research this.. No Blueprint Available!...", 4f);
                    return(InventoryItem.MergeResult.Failed);
                }
                if (inventory.KnowsBP(block2))
                {
                    Notice.Popup("", "You already know how to make this!", 4f);
                    return(InventoryItem.MergeResult.Failed);
                }
                return(InventoryItem.MergeResult.Combined);
            }
            Notice.Popup("", "You can't research this", 4f);
        }
        return(InventoryItem.MergeResult.Failed);
    }
Пример #3
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            var id = connection.UserID.ToString();

            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // Migrate user from 'player' group to 'default'
            if (permission.UserHasGroup(id, "player"))
            {
                permission.AddUserGroup(id, "default");
                permission.RemoveUserGroup(id, "player");
                Interface.Oxide.LogWarning($"Migrated '{id}' to the new 'default' group");
            }

            // Call out and see if we should reject
            var canlogin = (string)Interface.CallHook("CanClientLogin", connection) ?? Interface.CallHook("CanUserLogin", connection.UserName, id);

            if (canlogin is string)
            {
                Notice.Popup(connection.netUser.networkPlayer, "", canlogin.ToString(), 10f);
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", connection, approval, acceptor) ?? Interface.CallHook("OnUserApproved", connection.UserName, id));
        }
Пример #4
0
 public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments)
 {
     if (ChatArguments != null)
     {
         string strText = "";
         for (int i = 0; i < ChatArguments.Length; i++)
         {
             strText = strText + ChatArguments[i] + " ";
         }
         if (strText == string.Empty)
         {
             Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Please enter a valid message.");
         }
         else
         {
             char ch = '☢';
             foreach (PlayerClient client in PlayerClient.All)
             {
                 Notice.Popup(client.netPlayer, ch.ToString(), strText, 5f);
             }
         }
     }
     else
     {
         Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Announce Usage:  /announce \"message\"");
     }
 }
Пример #5
0
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            string strText = string.Join(" ", ChatArguments).Trim(new char[] { ' ', '"' });

            if (strText == string.Empty)
            {
                Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Announce Usage:  /announce your message here");
            }
            else
            {
                char ch = '☢';
                foreach (PlayerClient client in PlayerClient.All)
                {
                    Notice.Popup(client.netPlayer, ch.ToString(), strText, 5f);
                }
            }
        }
Пример #6
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // "Already connected" fix
            var netUser = NetUser.FindByUserID(connection.UserID);

            if (netUser != null)
            {
                Interface.Oxide.LogInfo($"Kicking existing {netUser.displayName} ({netUser.userID}) player (already connected fix)");
                netUser.Kick(NetError.AlreadyConnectedToAnotherServer, false);
            }

            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            Covalence.PlayerManager.PlayerJoin(connection.UserID, connection.UserName); // TODO: Handle this automatically

            // Call out and see if we should reject
            var loginSpecific  = Interface.Call("CanClientLogin", connection);
            var loginCovalence = Interface.Call("CanUserLogin", connection.UserName, id, ip);
            var canLogin       = loginSpecific ?? loginCovalence; // TODO: Fix 'RustLegacyCore' hook conflict when both return

            // Check if player can login
            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                // Reject the player with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin is string?canLogin.ToString() : "Connection was rejected", 10f);   // TODO: Localization
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            // Call the approval hooks
            var approvedSpecific  = Interface.Call("OnUserApprove", connection, approval, acceptor);
            var approvedCovalence = Interface.Call("OnUserApproved", connection.UserName, id, ip);

            return(approvedSpecific ?? approvedCovalence); // TODO: Fix 'RustLegacyCore' hook conflict when both return
        }
Пример #7
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", connection) ?? Interface.CallHook("CanUserLogin", connection.UserName, connection.UserID.ToString());

            if (canlogin != null)
            {
                Notice.Popup(connection.netUser.networkPlayer, "", canlogin.ToString(), 10f);
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", connection, approval, acceptor) ?? Interface.CallHook("OnUserApproved", connection.UserName, connection.UserID.ToString()));
        }
Пример #8
0
    public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Character shooterOrNull = itemInstance.character;

        if (shooterOrNull != null)
        {
            BodyPart    part;
            Ray         eyesRay     = shooterOrNull.eyesRay;
            bool        flag        = false;
            Collider    hitCollider = null;
            Vector3     zero        = Vector3.zero;
            Vector3     up          = Vector3.up;
            NetEntityID unassigned  = NetEntityID.unassigned;
            bool        flag2       = false;
            flag = this.Physics2SphereCast(eyesRay, 0.3f, this.GetRange(), 0x183e1411, out zero, out up, out hitCollider, out part);
            bool       flag3     = false;
            TakeDamage component = null;
            if (flag)
            {
                IDBase base2;
                TransformHelpers.GetIDBaseFromCollider(hitCollider, out base2);
                IDMain main = (base2 == null) ? null : base2.idMain;
                if (main != null)
                {
                    unassigned = NetEntityID.Get((MonoBehaviour)main);
                    flag2      = !unassigned.isUnassigned;
                    component  = main.GetComponent <TakeDamage>();
                    if ((component != null) && component.ShouldPlayHitNotification())
                    {
                        this.PlayHitNotification(zero, shooterOrNull);
                    }
                }
                flag3 = hitCollider.gameObject.CompareTag("Tree Collider");
                if (flag3)
                {
                    WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(zero);
                    if (!blockerForPoint.HasWood())
                    {
                        flag3 = false;
                        Notice.Popup("", "There's no wood left here", 2f);
                    }
                    else
                    {
                        blockerForPoint.ConsumeWood(this.efficiencies[2]);
                    }
                }
                this.DoMeleeEffects(eyesRay.origin, zero, Quaternion.LookRotation(up), hitCollider.gameObject);
                if ((vm != null) && ((component != null) || flag3))
                {
                    vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f);
                }
            }
            BitStream stream = new BitStream(false);
            if (flag2)
            {
                stream.WriteBoolean(flag2);
                stream.Write <NetEntityID>(unassigned, new object[0]);
                stream.WriteVector3(zero);
            }
            else
            {
                stream.WriteBoolean(false);
                stream.WriteVector3(zero);
            }
            stream.WriteBoolean(flag3);
            itemRep.ActionStream(1, RPCMode.Server, stream);
            this.EndSwingWorldAnimations(itemRep);
        }
    }
Пример #9
0
    public override void ItemPreFrame(ref HumanController.InputSample sample)
    {
        ViewModel viewModelInstance = base.viewModelInstance;

        if (sample.attack && (base.nextPrimaryAttackTime <= Time.time))
        {
            if (this.IsArrowDrawn())
            {
                float num = Time.time - this.completeDrawTime;
                if (num > 1f)
                {
                    base.datablock.Local_GetTired(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
                    this.tired = true;
                }
                if (num > base.datablock.tooTiredLength)
                {
                    base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
                }
            }
            else if (!this.IsArrowDrawn() && !this.IsArrowDrawing())
            {
                if (this.FindAmmo() == null)
                {
                    Notice.Popup("", "No Arrows!", 4f);
                    this.MakeReadyIn(2f);
                }
                else
                {
                    base.datablock.Local_ReadyArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
                }
            }
            else if (this.completeDrawTime < Time.time)
            {
                this.arrowDrawn = true;
            }
            if (this.IsArrowDrawingOrDrawn() && ((Time.time - (this.completeDrawTime - 1f)) > 0.5f))
            {
                sample.aim = true;
            }
        }
        else
        {
            if (this.IsArrowDrawn())
            {
                IInventoryItem item2 = this.FindAmmo();
                if (item2 == null)
                {
                    Notice.Popup("", "No Arrows!", 4f);
                    base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
                }
                else
                {
                    int count = 1;
                    if (item2.Consume(ref count))
                    {
                        base.inventory.RemoveItem(item2.slot);
                    }
                    base.datablock.Local_FireArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
                }
            }
            else if (this.IsArrowDrawingOrDrawn())
            {
                base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample);
            }
            sample.aim = false;
        }
        if (sample.aim)
        {
            sample.yaw   *= base.datablock.aimSensitivtyPercent;
            sample.pitch *= base.datablock.aimSensitivtyPercent;
        }
    }
Пример #10
0
    public override void ItemPreFrame(ref HumanController.InputSample sample)
    {
        ViewModel viewModel = base.viewModelInstance;

        if (!sample.attack || base.nextPrimaryAttackTime > Time.time)
        {
            if (this.IsArrowDrawn())
            {
                IInventoryItem inventoryItem = this.FindAmmo();
                if (inventoryItem != null)
                {
                    int num = 1;
                    if (inventoryItem.Consume(ref num))
                    {
                        base.inventory.RemoveItem(inventoryItem.slot);
                    }
                    T t = this.datablock;
                    t.Local_FireArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
                }
                else
                {
                    Notice.Popup("", "No Arrows!", 4f);
                    T t1 = this.datablock;
                    t1.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
                }
            }
            else if (this.IsArrowDrawingOrDrawn())
            {
                T t2 = this.datablock;
                t2.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
            }
            sample.aim = false;
        }
        else
        {
            if (this.IsArrowDrawn())
            {
                float single = Time.time - this.completeDrawTime;
                if (single > 1f)
                {
                    T t3 = this.datablock;
                    t3.Local_GetTired(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
                    this.tired = true;
                }
                if (single > (T)this.datablock.tooTiredLength)
                {
                    T t4 = this.datablock;
                    t4.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
                }
            }
            else if (!this.IsArrowDrawn() && !this.IsArrowDrawing())
            {
                if (this.FindAmmo() != null)
                {
                    T t5 = this.datablock;
                    t5.Local_ReadyArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample);
                }
                else
                {
                    Notice.Popup("", "No Arrows!", 4f);
                    this.MakeReadyIn(2f);
                }
            }
            else if (this.completeDrawTime < Time.time)
            {
                this.arrowDrawn = true;
            }
            if (this.IsArrowDrawingOrDrawn() && Time.time - (this.completeDrawTime - 1f) > 0.5f)
            {
                sample.aim = true;
            }
        }
        if (sample.aim)
        {
            sample.yaw   = sample.yaw * (T)this.datablock.aimSensitivtyPercent;
            sample.pitch = sample.pitch * (T)this.datablock.aimSensitivtyPercent;
        }
    }
Пример #11
0
    public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        BodyPart  bodyPart;
        IDBase    dBase;
        IDMain    dMain;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        Ray         ray         = character.eyesRay;
        bool        flag        = false;
        Collider    collider    = null;
        Vector3     vector3     = Vector3.zero;
        Vector3     vector31    = Vector3.up;
        NetEntityID netEntityID = NetEntityID.unassigned;
        bool        flag1       = false;

        flag = this.Physics2SphereCast(ray, 0.3f, this.GetRange(), 406721553, out vector3, out vector31, out collider, out bodyPart);
        bool       flag2     = false;
        TakeDamage component = null;

        if (flag)
        {
            TransformHelpers.GetIDBaseFromCollider(collider, out dBase);
            if (!dBase)
            {
                dMain = null;
            }
            else
            {
                dMain = dBase.idMain;
            }
            IDMain dMain1 = dMain;
            if (dMain1)
            {
                netEntityID = NetEntityID.Get(dMain1);
                flag1       = !netEntityID.isUnassigned;
                component   = dMain1.GetComponent <TakeDamage>();
                if (component && component.ShouldPlayHitNotification())
                {
                    this.PlayHitNotification(vector3, character);
                }
            }
            flag2 = collider.gameObject.CompareTag("Tree Collider");
            if (flag2)
            {
                WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(vector3);
                if (blockerForPoint.HasWood())
                {
                    blockerForPoint.ConsumeWood(this.efficiencies[2]);
                }
                else
                {
                    flag2 = false;
                    Notice.Popup("", "There's no wood left here", 2f);
                }
            }
            this.DoMeleeEffects(ray.origin, vector3, Quaternion.LookRotation(vector31), collider.gameObject);
            if (vm && (component || flag2))
            {
                vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f);
            }
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        if (!flag1)
        {
            bitStream.WriteBoolean(false);
            bitStream.WriteVector3(vector3);
        }
        else
        {
            bitStream.WriteBoolean(flag1);
            bitStream.Write <NetEntityID>(netEntityID, new object[0]);
            bitStream.WriteVector3(vector3);
        }
        bitStream.WriteBoolean(flag2);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        this.EndSwingWorldAnimations(itemRep);
    }