예제 #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();
        }
    }
예제 #3
0
    void ReadAndDoUpdateAction(NetIncomingMessage inInputStream, int inNetworkId)
    {
        //need object
        NetGameObject gameObject = NetworkManagerClient.sInstance.GetGameObject(inNetworkId);

        //gameObject MUST be found, because create was ack'd if we're getting an update...
        //and read state
        gameObject.Read(inInputStream);
    }
예제 #4
0
    void ReadAndDoUpdateAction(NetIncomingMessage inInputStream, int inNetworkId)
    {
        //need object
        NetGameObject gameObject = NetworkManagerClient.sInstance.GetGameObject(inNetworkId, core.World.DefaultWorldIndex);

        if (gameObject != null)
        {
            gameObject.IsCreate = false;

            //gameObject MUST be found, because create was ack'd if we're getting an update...
            //and read state
            gameObject.Read(inInputStream);
        }
        else
        {
            Debug.LogError($"ReadAndDoUpdateAction cannot find network object {inNetworkId}");
        }
    }