Esempio n. 1
0
    public void GenerateEntitySnapshot(int entityId, ref NetworkWriter writer)
    {
        var data = m_replicatedData[entityId];

        GameDebug.Assert(data.serializableArray != null, "Failed to generate snapshot. Serializablearray is null");

        foreach (var entry in data.serializableArray)
        {
            entry.Serialize(ref writer);
        }

        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
        foreach (var entry in data.predictedArray)
        {
            entry.Serialize(ref writer);
        }
        writer.ClearFieldSection();

        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyNotPredicting);
        foreach (var entry in data.interpolatedArray)
        {
            entry.Serialize(ref writer);
        }
        writer.ClearFieldSection();
    }
Esempio n. 2
0
    public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
    {
        if (predictedHandlers != null)
        {
            writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);

            for (var i = 0; i < predictedHandlers.Length; i++)
            {
                predictedHandlers[i].Serialize(ref writer, refSerializer);
            }

            writer.ClearFieldSection();
        }

        if (interpolatedHandlers != null)
        {
            writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyNotPredicting);

            for (var i = 0; i < interpolatedHandlers.Length; i++)
            {
                interpolatedHandlers[i].Serialize(ref writer, refSerializer);
            }

            writer.ClearFieldSection();
        }
    }
Esempio n. 3
0
            public override void Serialize(ref NetworkWriter writer)
            {
                base.Serialize(ref writer);
                writer.WriteVector3("position", position);
                writer.WriteInt32("health", health);
                writer.WriteBoolean("flag", flag);
                writer.WriteString("message", message);

                writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
                writer.WriteFloat("predictedData", predictedData);
                writer.ClearFieldSection();

                writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyNotPredicting);
                writer.WriteFloat("nonpredictedData", nonpredictedData);
                writer.ClearFieldSection();
            }
Esempio n. 4
0
    public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
    {
        writer.WriteInt32("playerId", playerId);
        writer.WriteString("playerName", playerName);
        writer.WriteInt32("teamIndex", teamIndex);
        writer.WriteInt32("score", score);
        refSerializer.SerializeReference(ref writer, "controlledEntity", controlledEntity);

        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
        writer.WriteBoolean("displayCountDown", displayCountDown);
        writer.WriteInt32("countdown", countDown);
        writer.WriteBoolean("displayScoreBoard", displayScoreBoard);
        writer.WriteBoolean("displayGameScore", displayGameScore);
        writer.WriteBoolean("displayGameResult", displayGameResult);
        writer.WriteString("gameResult", gameResult);

        writer.WriteBoolean("displayGoal", displayGoal);
        writer.WriteVector3Q("goalPosition", goalPosition, 2);
        writer.WriteUInt32("goalDefendersColor", goalDefendersColor);
        writer.WriteUInt32("goalAttackersColor", goalAttackersColor);
        writer.WriteUInt32("goalAtackers", goalAttackers);
        writer.WriteUInt32("goalDefenders", goalDefenders);
        writer.WriteString("goalString", goalString);
        writer.WriteString("actionString", actionString);
        writer.WriteFloatQ("goalCompletion", goalCompletion, 2);
        writer.ClearFieldSection();
    }
Esempio n. 5
0
    public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
    {
        var behaviour = context.entityManager.GetComponentObject <PlayerState>(context.entity);

        writer.WriteInt32("playerId", behaviour.playerId);
        writer.WriteString("playerName", behaviour.playerName);
        writer.WriteInt32("teamIndex", behaviour.teamIndex);
        writer.WriteInt32("score", behaviour.score);
        context.refSerializer.SerializeReference(ref writer, "controlledEntity", behaviour.controlledEntity);

        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
        writer.WriteBoolean("displayScoreBoard", behaviour.displayScoreBoard);
        writer.WriteBoolean("displayGameScore", behaviour.displayGameScore);
        writer.WriteBoolean("displayGameResult", behaviour.displayGameResult);
        writer.WriteString("gameResult", behaviour.gameResult);

        writer.WriteBoolean("displayGoal", behaviour.displayGoal);
        writer.WriteVector3Q("goalPosition", behaviour.goalPosition, 2);
        writer.WriteUInt32("goalDefendersColor", behaviour.goalDefendersColor);
        writer.WriteUInt32("goalAttackersColor", behaviour.goalAttackersColor);
        writer.WriteUInt32("goalAtackers", behaviour.goalAttackers);
        writer.WriteUInt32("goalDefenders", behaviour.goalDefenders);
        writer.WriteString("goalString", behaviour.goalString);
        writer.WriteString("actionString", behaviour.actionString);
        writer.WriteFloatQ("goalCompletion", behaviour.goalCompletion, 2);
        writer.ClearFieldSection();
    }
Esempio n. 6
0
    public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
    {
        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
        var state = entityManager.GetComponentData <T>(entity);

        state.Serialize(ref writer, refSerializer);
        writer.ClearFieldSection();
    }
Esempio n. 7
0
    public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
    {
        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);

        writer.WriteInt16("activeAbility", (short)activeAbility);

        writer.ClearFieldSection();

        for (var i = 0; i < abilityEntities.Length; i++)
        {
            refSerializer.SerializeReference(ref writer, "ability", abilityEntities[i]);
        }
    }
Esempio n. 8
0
    public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
    {
        var behaviour = context.entityManager.GetComponentObject <PlayerState>(context.entity);

        writer.WriteInt32("playerId", behaviour.playerId);
        writer.WriteString("playerName", behaviour.playerName);
        writer.WriteInt32("teamIndex", behaviour.teamIndex);
        writer.WriteInt32("score", behaviour.score);
        context.refSerializer.SerializeReference(ref writer, "controlledEntity", behaviour.controlledEntity);

        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
        writer.WriteBoolean("displayScoreBoard", behaviour.displayScoreBoard);
        writer.WriteBoolean("displayGameScore", behaviour.displayGameScore);
        writer.WriteBoolean("displayGameResult", behaviour.displayGameResult);
        writer.WriteString("gameResult", behaviour.gameResult);

        writer.ClearFieldSection();
    }
Esempio n. 9
0
    public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
    {
        writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyNotPredicting);
        writer.WriteVector3Q("position", position, 2);
        writer.WriteFloatQ("rotation", rotation, 0);
        writer.WriteFloatQ("aimYaw", aimYaw, 0);
        writer.WriteFloatQ("aimPitch", aimPitch, 0);
        writer.WriteFloatQ("moveYaw", moveYaw, 0);

        writer.WriteInt32("charLocoState", (int)charLocoState);
        writer.WriteInt32("charLocoTick", charLocoTick);
        writer.WriteInt32("characterAction", (int)charAction);
        writer.WriteInt32("characterActionTick", charActionTick);
        writer.WriteBoolean("sprinting", sprinting == 1);
        writer.WriteFloatQ("sprintWeight", sprintWeight, 2);
        writer.WriteInt32("damageTick", damageTick);
        writer.WriteFloatQ("damageDirection", damageDirection, 1);

        writer.WriteFloatQ("moveAngleLocal", moveAngleLocal, 0);
        writer.WriteFloatQ("shootPoseWeight", shootPoseWeight);
        writer.WriteVector2Q("locomotionVector", locomotionVector);
        writer.WriteFloatQ("locomotionPhase", locomotionPhase);
        writer.WriteFloatQ("banking", banking);
        writer.WriteFloatQ("landAnticWeight", landAnticWeight, 2);
        writer.WriteFloatQ("turnStartAngle", turnStartAngle, 0);
        writer.WriteInt16("turnDirection", turnDirection);
        writer.WriteFloatQ("squashTime", squashTime, 2);
        writer.WriteFloatQ("squashWeight", squashWeight, 2);
        writer.WriteFloatQ("inAirTime", inAirTime, 2);
        writer.WriteFloatQ("jumpTime", jumpTime, 2);
        writer.WriteFloatQ("simpleTime", simpleTime, 2);
        writer.WriteVector2Q("footIkOffset", footIkOffset, 2);
        writer.WriteVector3Q("footIkNormalLeft", footIkNormalLeft, 2);
        writer.WriteVector3Q("footIkNormaRight", footIkNormaRight, 2);
        writer.ClearFieldSection();
    }
Esempio n. 10
0
 public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
 {
     writer.SetFieldSection(NetworkWriter.FieldSectionType.OnlyPredicting);
     State.Serialize(ref writer, refSerializer);
     writer.ClearFieldSection();
 }