예제 #1
0
    void ReadAndDoCreateAction(NetIncomingMessage inInputStream, int inNetworkId)
    {
        UInt32 classID = inInputStream.ReadByte();

        //LogHelper.LogInfo($"replication {(core.GameObjectClassId)classID}");

        //we might already have this object- could happen if our ack of the create got dropped so server resends create request
        //( even though we might have created )

        NetGameObject gameObject = NetworkManagerClient.sInstance.GetGameObject(inNetworkId, core.World.DefaultWorldIndex);

        if (gameObject == null)
        {
            //create the object and map it...
            gameObject = GameObjectRegistry.sInstance.CreateGameObject(classID, false);
            gameObject.SetNetworkId(inNetworkId);
            NetworkManagerClient.sInstance.AddToNetworkIdToGameObjectMap(gameObject, core.World.DefaultWorldIndex);
            gameObject.IsCreate = true;

            //it had really be the rigth type...
            //Assert(gameObject.GetClassId() == fourCCName);
            //Debug.Log($"ReadAndDoCreateAction networkID {inNetworkId}");
        }
        else
        {
            gameObject.IsCreate = false;
        }

        //and read state
        gameObject.Read(inInputStream);
        if (gameObject.IsCreate)
        {
            gameObject.CompleteCreate();
        }
    }
예제 #2
0
    void ReadAndDoCreateAction(NetIncomingMessage inInputStream, int inNetworkId)
    {
        //need 4 cc
        uint32_t fourCCName = inInputStream.ReadUInt32();

        //we might already have this object- could happen if our ack of the create got dropped so server resends create request
        //( even though we might have created )

        bool          is_create  = false;
        NetGameObject gameObject = NetworkManagerClient.sInstance.GetGameObject(inNetworkId);

        if (gameObject == null)
        {
            //create the object and map it...
            gameObject = GameObjectRegistry.sInstance.CreateGameObject(fourCCName);
            gameObject.SetNetworkId(inNetworkId);
            NetworkManagerClient.sInstance.AddToNetworkIdToGameObjectMap(gameObject);
            is_create = true;

            //it had really be the rigth type...
            //Assert(gameObject.GetClassId() == fourCCName);
        }

        //and read state
        gameObject.Read(inInputStream);
        if (is_create)
        {
            gameObject.CompleteCreate();
        }
    }
        public void RegisterGameObject(NetGameObject inGameObject, byte worldId)
        {
            if (CheckWorldId(inGameObject.WorldId) == false)
            {
                Log.Error($"RegisterGameObject error worldId{inGameObject.WorldId}");
                return;
            }

            //assign network id
            int newNetworkId = GetNewNetworkId(worldId);

            inGameObject.SetNetworkId(newNetworkId);
            inGameObject.WorldId = worldId;

            //add mapping from network id to game object
            mNetworkIdToGameObjectMap[worldId][newNetworkId] = inGameObject;

            //tell all client proxies this is new...
            foreach (var pair in mAddressToClientMap)
            {
                if (pair.Value.IsStartedPlay && pair.Value.GetWorldId() == worldId)
                {
                    pair.Value.GetReplicationManagerServer().ReplicateCreate(newNetworkId, inGameObject.GetAllStateMask());
                }
            }
        }
예제 #4
0
        public void RegisterGameObject(NetGameObject inGameObject, byte worldId)
        {
            //assign network id
            int newNetworkId = GetNewNetworkId();

            inGameObject.SetNetworkId(newNetworkId);
            inGameObject.WorldId = worldId;

            //add mapping from network id to game object
            mNetworkIdToGameObjectMap[newNetworkId] = inGameObject;

            //tell all client proxies this is new...
            foreach (var pair in mAddressToClientMap)
            {
                if (pair.Value.GetWorldId() == worldId)
                {
                    pair.Value.GetReplicationManagerServer().ReplicateCreate(newNetworkId, inGameObject.GetAllStateMask());
                }
            }
        }