コード例 #1
0
    public void Serialize(EB.BitStream bs)
    {
        int numElements = 0;

        if (!bs.isReading)
        {
            numElements = _list.Count;
        }
        bs.Serialize(ref numElements);

        if (bs.isReading)
        {
            for (int i = 0; i < numElements; i++)
            {
                T element = new T();
                element.Serialize(bs);
                _list.Add(element);
            }
        }
        else
        {
            for (int i = 0; i < numElements; i++)
            {
                _list[i].Serialize(bs);
            }
        }
    }
コード例 #2
0
    public void Serialize(EB.BitStream bs)
    {
        int numKeys = 0;

        if (!bs.isReading)
        {
            numKeys = _dictionary.Count;
        }
        bs.Serialize(ref numKeys);

        object[] keysAndValues = new object[numKeys * 2];

        if (!bs.isReading)
        {
            int i = 0;
            foreach (string key in _dictionary.Keys)
            {
                keysAndValues[i]     = key;
                keysAndValues[i + 1] = _dictionary[key];
                i += 2;
            }
        }

        EB.Replication.Manager.SerializeVarAgs(bs, ref keysAndValues);

        if (bs.isReading)
        {
            for (int i = 0; i < keysAndValues.Length; i += 2)
            {
                _dictionary.Add((string)keysAndValues[0], (object)keysAndValues[1]);
            }
        }
    }
コード例 #3
0
    public override void Serialize(EB.BitStream bs)
    {
        base.Serialize(bs);

        // Takes care of reading and writing
        bs.Serialize(ref isAggroStarting);
    }
コード例 #4
0
    // called from replication view, frequency of call determined by update interval
    public void OnSerializeView(EB.BitStream bs)
    {
        Vector2 position          = new Vector2();
        Vector2 velocity          = new Vector2();
        float   distToDestination = NetworkTransform.DistanceUnlimited;

        if (bs.isWriting)
        {
            //DebugSystem.Log("Writing Writing " + name + " " + Network.time + " " + _networkLocomotionComponentViewRPC.isMine);
            CalculatePositionAndVelocityToSend(ref position, ref velocity, ref distToDestination);
        }

        float yaw = transform.rotation.eulerAngles.y;

        //fixme: xxxxxxxxxxxxxxxxxxxxxxxxx
        double networkTime = System.DateTime.Now.Second;

        // double networkTime = Network.time;

        bs.Serialize(ref position.x);
        bs.Serialize(ref position.y);
        bs.Serialize(ref velocity.x);
        bs.Serialize(ref velocity.y);
        bs.Serialize(ref yaw);
        bs.Serialize(ref distToDestination);
        bs.Serialize(ref networkTime);

        if (bs.isReading)
        {
            //DebugSystem.Log("Reading Reading " + name + " " + Network.time + " " + _networkLocomotionComponentViewRPC.isMine);
            Quaternion rotation = Quaternion.Euler(0f, yaw, 0f);
            SetTransformInterpolated(position, velocity, rotation, distToDestination, networkTime);
        }
    }
コード例 #5
0
    public virtual void Serialize(EB.BitStream bs)
    {
        if (bs.isReading)
        {
            bool hasInstigator = true;
            bs.Serialize(ref hasInstigator);

            if (hasInstigator)
            {
                EB.Replication.ViewId instigatorViewID = new EB.Replication.ViewId();
                bs.Serialize(ref instigatorViewID);
                instigator = Replication.GetObjectFromViewId(instigatorViewID);
            }
            else
            {
                instigator = null;
            }

            bool hasTarget = true;
            bs.Serialize(ref hasTarget);

            if (hasTarget)
            {
                EB.Replication.ViewId targetViewID = new EB.Replication.ViewId();
                bs.Serialize(ref targetViewID);
                target = Replication.GetObjectFromViewId(targetViewID);
            }
            else
            {
                target = null;
            }
        }
        else
        {
            bool hasInstigator = instigator != null;
            bs.Serialize(ref hasInstigator);

            if (hasInstigator)
            {
                EB.Replication.ViewId instigatorViewID = instigator.GetComponent <ReplicationView>().viewId;
                bs.Serialize(ref instigatorViewID);
            }

            bool hasTarget = target != null;
            bs.Serialize(ref hasTarget);

            if (hasTarget)
            {
                EB.Replication.ViewId targetViewID = target.GetComponent <ReplicationView>().viewId;
                bs.Serialize(ref targetViewID);
            }
        }
    }