public void ServerDestroyID(NetIdentity identity)
 {
     if (!isServer())
     {
         return;
     }
     ServerSend.DestroyID(identity);
 }
Пример #2
0
 public void Start()
 {
     identity = GetComponentInParent <NetIdentity>();
     if (identity != null)
     {
         evtCollision = identity.RegisterEvent(OnReportCollision);
     }
 }
Пример #3
0
 public void Start()
 {
     identity = GetComponent <NetIdentity>();
     if (identity != null)
     {
         evtCollision = identity.RegisterEvent(OnTriggerMusic);
     }
 }
Пример #4
0
 public void StartNetwork(NetIdentity identity)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Start Network ");
     }
     this.identity = identity;
 }
 private void Start()
 {
     identity = GetComponentInParent <NetIdentity>();
     if (identity != null)
     {
         evtCollisionAudio = identity.RegisterEvent(OnReceiveCollisionAudio);
     }
 }
Пример #6
0
 public void StartNetwork(NetIdentity identity)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Start Network ");
     }
     this.identity = identity;
     evtPlug       = identity.RegisterEvent(OnPlug);
 }
Пример #7
0
    protected override void Awake()
    {
        base.Awake();

        cMeshRender = GetComponent <MeshRenderer>();
        rbody       = GetComponent <Rigidbody>();

        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnStartClient, OnStartClient);
    }
        /// <summary>
        /// Connect to a relay server
        /// </summary>
        public static T ConnectRelay <T>(SteamId serverId, int virtualport = 0) where T : ConnectionInterface, new()
        {
            var         t        = new T();
            NetIdentity identity = serverId;

            t.Connection = Internal.ConnectP2P(ref identity, virtualport);
            SetConnectionInterface(t.Connection.Id, t);
            return(t);
        }
Пример #9
0
 public void Start()
 {
     audioSource = GetComponent <AudioSource>();
     identity    = GetComponent <NetIdentity>();
     if (identity != null)
     {
         evtCollision = identity.RegisterEvent(OnPlayEasterEggAudio);
     }
 }
Пример #10
0
 private void Start()
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Started ");
     }
     identity = GetComponent <NetIdentity>();
     evtHit   = identity.RegisterEvent(OnHit);
 }
        public static T ConnectRelay <T>(SteamId serverId, int virtualport = 0)
            where T : ConnectionInterface, new()
        {
            T           t           = Activator.CreateInstance <T>();
            NetIdentity netIdentity = serverId;

            t.Connection = SteamNetworkingSockets.Internal.ConnectP2P(ref netIdentity, virtualport);
            SteamNetworkingSockets.SetConnectionInterface(t.Connection.Id, t);
            return(t);
        }
Пример #12
0
        /// <summary>
        /// Connect to a relay server
        /// </summary>
        public static T ConnectRelay <T>(SteamId serverId, int virtualport = 0) where T : ConnectionManager, new()
        {
            var         t        = new T();
            NetIdentity identity = serverId;
            var         options  = Array.Empty <NetKeyValue>();

            t.Connection = Internal.ConnectP2P(ref identity, virtualport, options.Length, options);
            SetConnectionManager(t.Connection.Id, t);
            return(t);
        }
Пример #13
0
        public override void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime,
                                       int channel)
        {
            base.OnMessage(connection, identity, data, size, messageNum, recvTime, channel);

            foreach (var connected in Connected.Where(connected => connected != connection))
            {
                connected.SendMessage(data, size);
            }

            NetworkManager.NetworkServerListener.OnMessageReceived(connection, identity, data, size, messageNum, recvTime, channel);
        }
Пример #14
0
 public void RpcTakeDamage(string inNetId)
 {
     NetworkIdentity[] netArry = FindObjectsOfType <NetworkIdentity>();
     foreach (NetworkIdentity NetIdentity in netArry)
     {
         if (NetIdentity.netId.ToString() == inNetId)
         {
             //Take Damage SyncVar?
             NetIdentity.GetComponent <PlayerAnimationController>().TakeDamage();
         }
     }
 }
Пример #15
0
 private void Start()
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Started ");
     }
     identity = GetComponentInParent <NetIdentity>();
     if (identity != null)
     {
         evtImpact = identity.RegisterEvent(OnImpact);
     }
 }
Пример #16
0
        protected override void Start()
        {
            base.Start();
            var lowestBound = QSBPlayerManager.GetSyncObjects <PlayerTransformSync>()
                              .Where(x => x.NetId.Value <= NetId.Value).OrderBy(x => x.NetId.Value).Last();

            NetIdentity.SetRootIdentity(lowestBound.NetIdentity);

            SectorSync = gameObject.AddComponent <SectorSync.SectorSync>();

            DontDestroyOnLoad(gameObject);
            QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
        }
        void Update()
        {
            if (!Server.active)
            {
                return;
            }

            if (Time.time - lastUpdateTime > VisibilityUpdateInterval)
            {
                NetIdentity.RebuildObservers(false);
                lastUpdateTime = Time.time;
            }
        }
Пример #18
0
    protected override void Awake()
    {
        rbody = GetComponent <Rigidbody>();

        movespeedPow = movementSpeed * movementSpeed;

        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnNetworkCreate, OnNetworkCreate);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnStartServer, OnStartServer);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnStartAuthority, OnStartAuthority);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnGiveAuthority, OnGiveAuthority);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnStartClient, OnStartClient);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnStateUpdate, OnStateUpdate);
        NetIdentity.RegisterEventHandler(TinyNetIdentity.TinyNetComponentEvents.OnNetworkDestroy, OnNetworkDestroy);
    }
        /// <summary>
        /// Connect to a relay server.
        /// </summary>
        public static ConnectionManager ConnectRelay(SteamId serverId, int virtualport, IConnectionManager iface)
        {
            NetIdentity identity   = serverId;
            var         options    = Array.Empty <NetKeyValue>();
            var         connection = Internal.ConnectP2P(ref identity, virtualport, options.Length, options);

            var t = new ConnectionManager
            {
                Connection = connection,
                Interface  = iface
            };

            SetConnectionManager(t.Connection.Id, t);
            return(t);
        }
Пример #20
0
 public static void Spawn(NetIdentity id)
 {
     using (Packet packet = new Packet((int)ServerPackets.Spawn)){
         packet.Write(id.prefabID);
         packet.Write(id.id);
         packet.Write(id.ownerId);
         packet.Write(id.transform.position);
         packet.Write(id.behaviours.Length);
         for (int i = 0; i < id.behaviours.Length; i++)
         {
             packet.Write(id.behaviours[i].id);
         }
         SendTcpDataToAll(packet);
     }
 }
Пример #21
0
        public void OnMessageReceived(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum,
                                      long recvTime, int channel)
        {
            var received     = _messagePackager.Unpack(data, size);
            var receivedType = received.GetType();

            if (!_packetConsumers.ContainsKey(receivedType))
            {
                return;
            }

            var consumer = _packetConsumers[receivedType];

            consumer.Consume(connection, received);

            _networkManager.RelayMessage(data, size, connection);
        }
Пример #22
0
        public override void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel)
        {
            byte[] bytes = new byte[size];
            Marshal.Copy(data, bytes, 0, size);

            using (MemoryStream stream = new MemoryStream())
            {
                stream.Write(bytes, 0, size);
                stream.Position = 0;

                if (_binaryFormatter.Deserialize(stream) is PlayerMessage message)
                {
                    message.Sender.Connection = connection;
                    OnMessageReceived?.Invoke(message);
                }
            }
        }
        /// <summary>
        /// Connect to a relay server
        /// </summary>
        public static T ConnectRelay <T>(SteamId serverId, int virtualport = 0) where T : ConnectionManager, new()
        {
            var         t        = new T();
            NetIdentity identity = serverId;
            var         options  = new NetKeyValue[]
            {
                new NetKeyValue()
                {
                    Value      = NetConfig.IP_AllowWithoutAuth,
                    DataType   = NetConfigType.Int32,
                    Int32Value = SteamNetworkingUtils.AllowWithoutAuth
                }
            };

            t.Connection = Internal.ConnectP2P(ref identity, virtualport, options.Length, options);
            SetConnectionManager(t.Connection.Id, t);
            return(t);
        }
Пример #24
0
 private void OnEnable()
 {
     identity = GetComponentInParent <NetIdentity>();
     evtPull  = identity.RegisterEvent(OnPull);
     if (NetGame.isServer)
     {
         if (joint == null)
         {
             joint = CreateJoint();
         }
         anchor      = axis.TransformPoint(Vector3.forward);
         totalTravel = 0f;
         if (groundedIgnoreCollider != null)
         {
             IgnoreCollision.Ignore(base.transform, groundedIgnoreCollider);
         }
     }
 }
            public override unsafe void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel)
            {
                // We're only sending strings, so it's fine to read this like this
                var str = UTF8Encoding.UTF8.GetString((byte *)data, size);

                Console.WriteLine($"[SOCKET][{connection}[{identity}][{messageNum}][{recvTime}][{channel}] \"{str}\"");

                if (str.Contains("Hello, How are you"))
                {
                    connection.SendMessage("I'm great thanks, how about yourself?");
                }

                if (str.Contains("bye"))
                {
                    connection.SendMessage("See you later, hater.");
                    connection.Flush();
                    connection.Close(true, 10, "Said Bye");
                }
            }
Пример #26
0
 public override void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel)
 {
     if (steamToMirrorIds.TryGetValue(connection.Id, out int connectionId))
     {
         if (transport.debug)
         {
             Debug.Log($"We got a message from {identity} / connectionId: {connectionId}");
         }
         base.OnMessage(connection, identity, data, size, messageNum, recvTime, channel);
         byte[] mIn = new byte[size];
         Marshal.Copy(data, mIn, 0, size);
         ArraySegment <byte> mOut = new ArraySegment <byte>(mIn);
         transport.OnServerDataReceived.Invoke(connectionId, mOut, channel);
     }
     else
     {
         Debug.Log($"Server.OnMessage: Unable to get steam connection.Id to mirror id mapping: connection.Id: {connection.Id}");
     }
 }
Пример #27
0
    public void Start()
    {
        Human   componentInParent       = GetComponentInParent <Human>();
        Ragdoll ragdoll                 = componentInParent.ragdoll;
        CollisionAudioSensor component  = ragdoll.partLeftFoot.transform.GetComponent <CollisionAudioSensor>();
        CollisionAudioSensor component2 = ragdoll.partRightFoot.transform.GetComponent <CollisionAudioSensor>();

        leftHand  = ragdoll.partLeftHand.transform;
        rightHand = ragdoll.partRightHand.transform;
        ragdoll.partLeftHand.sensor.onGrabTap  = HandGrabLeft;
        ragdoll.partRightHand.sensor.onGrabTap = HandGrabRight;
        CollisionAudioSensor[] componentsInChildren = GetComponentsInChildren <CollisionAudioSensor>();
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            componentsInChildren[i].id = -i;
        }
        identity = GetComponentInParent <NetIdentity>();
        if (identity != null)
        {
            evtHandGrab = identity.RegisterEvent(OnHandGrab);
        }
    }
        /// <summary>
        /// Connect to a relay server
        /// </summary>
        public static ConnectionManager ConnectRelay(SteamId serverId, int virtualport, IConnectionManager iface)
        {
            NetIdentity identity = serverId;
            var         options  = new NetKeyValue[]
            {
                new NetKeyValue()
                {
                    Value      = NetConfig.IP_AllowWithoutAuth,
                    DataType   = NetConfigType.Int32,
                    Int32Value = SteamNetworkingUtils.AllowWithoutAuth
                }
            };
            var connection = Internal.ConnectP2P(ref identity, virtualport, options.Length, options);

            var t = new ConnectionManager
            {
                Connection = connection,
                Interface  = iface
            };

            SetConnectionManager(t.Connection.Id, t);
            return(t);
        }
Пример #29
0
 public void StartNetwork(NetIdentity identity)
 {
 }
Пример #30
0
 private void Awake()
 {
     identity = GetComponentInParent <NetIdentity>();
     evtBeep  = identity.RegisterEvent(OnBeep);
 }