Exemplo n.º 1
0
        private static void OnSwitchToWeaponFailure(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!Sync.IsServer)
            {
                sync.m_switchWeaponCounter--;
            }

            var handler = sync.SwitchToWeaponFailureHandler;

            if (handler != null)
            {
                handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId);
            }
        }
Exemplo n.º 2
0
        public void RequestSwitchToWeapon(MyDefinitionId?weapon, MyObjectBuilder_EntityBase weaponObjectBuilder, long weaponEntityId)
        {
            if (!Sync.IsServer)
            {
                m_switchWeaponCounter++;
            }

            var msg = new SwitchToWeaponMsg();

            msg.ControlledEntityId  = SyncedEntityId;
            msg.Weapon              = weapon;
            msg.WeaponObjectBuilder = weaponObjectBuilder;
            msg.WeaponEntityId      = weaponEntityId;

            Sync.Layer.SendMessageToServer(ref msg);
        }
Exemplo n.º 3
0
        private static void OnSwitchToWeaponRequest(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!sync.Entity.CanSwitchToWeapon(msg.Weapon))
            {
                Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure);
                return;
            }

            // Allocate a new entity id for the new gun, if needed
            if (msg.WeaponObjectBuilder != null && msg.WeaponObjectBuilder.EntityId == 0)
            {
                msg.WeaponObjectBuilder          = (MyObjectBuilder_EntityBase)msg.WeaponObjectBuilder.Clone();
                msg.WeaponObjectBuilder.EntityId = msg.WeaponEntityId == 0 ? MyEntityIdentifier.AllocateId() : msg.WeaponEntityId;
            }
            OnSwitchToWeaponSuccess(sync, ref msg, Sync.Clients.LocalClient);
            Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
        }
Exemplo n.º 4
0
        private static void OnSwitchToWeaponSuccess(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!Sync.IsServer)
            {
                // Update the counter only if we are waiting for it
                if (sync.m_switchWeaponCounter > 0)
                {
                    sync.m_switchWeaponCounter--;
                }
            }

            var handler = sync.SwitchToWeaponSuccessHandler;

            if (handler != null)
            {
                handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId);
            }
        }
        private static void OnSwitchToWeaponFailure(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!Sync.IsServer)
            {
                sync.m_switchWeaponCounter--;
            }

            var handler = sync.SwitchToWeaponFailureHandler;
            if (handler != null)
                handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId);
        }
        private static void OnSwitchToWeaponSuccess(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!Sync.IsServer)
            {
                // Update the counter only if we are waiting for it
                if (sync.m_switchWeaponCounter > 0)
                {
                    sync.m_switchWeaponCounter--;
                }
            }

            var handler = sync.SwitchToWeaponSuccessHandler;
            if (handler != null)
                handler(msg.Weapon, msg.WeaponObjectBuilder, msg.WeaponEntityId);
        }
        private static void OnSwitchToWeaponRequest(MySyncControllableEntity sync, ref SwitchToWeaponMsg msg, MyNetworkClient sender)
        {
            if (!sync.Entity.CanSwitchToWeapon(msg.Weapon))
            {
                Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Failure);
                return;
            }

            // Allocate a new entity id for the new gun, if needed
            if (msg.WeaponObjectBuilder != null && msg.WeaponObjectBuilder.EntityId == 0)
            {
                msg.WeaponObjectBuilder = (MyObjectBuilder_EntityBase)msg.WeaponObjectBuilder.Clone();
                msg.WeaponObjectBuilder.EntityId = msg.WeaponEntityId == 0 ? MyEntityIdentifier.AllocateId() : msg.WeaponEntityId;
            }
            OnSwitchToWeaponSuccess(sync, ref msg, Sync.Clients.LocalClient);
            Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
        }
        public void RequestSwitchToWeapon(MyDefinitionId? weapon, MyObjectBuilder_EntityBase weaponObjectBuilder, long weaponEntityId)
        {
            if (!Sync.IsServer)
            {
                m_switchWeaponCounter++;
            }

            var msg = new SwitchToWeaponMsg();
            msg.ControlledEntityId = SyncedEntityId;
            msg.Weapon = weapon;
            msg.WeaponObjectBuilder = weaponObjectBuilder;
            msg.WeaponEntityId = weaponEntityId;

            Sync.Layer.SendMessageToServer(ref msg);
        }