Ejemplo n.º 1
0
    public static void SerializeEffectsToStartToStream(ref IBitStream stream, List <ClientEffectStartData> effectStartList)
    {
        sbyte effectStartNum = (sbyte)effectStartList.Count;

        stream.Serialize(ref effectStartNum);
        for (int i = 0; i < effectStartNum; i++)
        {
            ClientEffectStartData effectStart = effectStartList[i];

            uint effectGUID = (uint)effectStart.m_effectGUID;
            stream.Serialize(ref effectGUID);
            List <ServerClientUtils.SequenceStartData> seqStartList = effectStart.m_sequenceStartDataList;
            sbyte seqStartNum = (sbyte)seqStartList.Count;
            stream.Serialize(ref seqStartNum);
            for (int j = 0; j < seqStartNum; j++)
            {
                seqStartList[j].SequenceStartData_SerializeToStream(ref stream);
            }
            sbyte casterActorIndex = (sbyte)(effectStart.m_caster?.ActorIndex ?? ActorData.s_invalidActorIndex);
            stream.Serialize(ref casterActorIndex);
            sbyte targetActorIndex = (sbyte)(effectStart.m_effectTarget?.ActorIndex ?? ActorData.s_invalidActorIndex);
            stream.Serialize(ref targetActorIndex);
            if (targetActorIndex != ActorData.s_invalidActorIndex)
            {
                sbyte statusNum = (sbyte)effectStart.m_statuses.Count;
                stream.Serialize(ref statusNum);
                for (int j = 0; j < statusNum; j++)
                {
                    byte statusType = (byte)effectStart.m_statuses[j];
                    stream.Serialize(ref statusType);
                }
            }
            if (targetActorIndex != ActorData.s_invalidActorIndex)
            {
                sbyte statusOnTurnStartNum = (sbyte)effectStart.m_statusesOnTurnStart.Count;
                stream.Serialize(ref statusOnTurnStartNum);
                for (int j = 0; j < statusOnTurnStartNum; j++)
                {
                    byte statusType = (byte)effectStart.m_statusesOnTurnStart[j];
                    stream.Serialize(ref statusType);
                }
            }
            bool hasAbsorb      = effectStart.m_absorb != 0;
            bool hasExpectedHoT = effectStart.m_expectedHoT != 0;
            byte bitField       = ServerClientUtils.CreateBitfieldFromBools(
                effectStart.m_isBuff,
                effectStart.m_isDebuff,
                effectStart.m_hasMovementDebuff,
                hasAbsorb,
                hasExpectedHoT,
                false, false, false);
            stream.Serialize(ref bitField);
            if (hasAbsorb)
            {
                short absorb = (short)effectStart.m_absorb;
                stream.Serialize(ref absorb);
            }
            if (hasExpectedHoT)
            {
                short expectedHoT = (short)effectStart.m_expectedHoT;
                stream.Serialize(ref expectedHoT);
            }
        }
    }
Ejemplo n.º 2
0
    public void SerializeToStream(ref IBitStream stream)
    {
        byte bitField1 = ServerClientUtils.CreateBitfieldFromBools(
            m_hasDamage,
            m_hasHealing,
            m_hasTechPointGain,
            m_hasTechPointLoss,
            m_hasTechPointGainOnCaster,
            m_hasKnockback,
            m_targetInCoverWrtDamage,
            m_canBeReactedTo);

        stream.Serialize(ref bitField1);

        byte bitField2 = ServerClientUtils.CreateBitfieldFromBools(
            m_damageBoosted,
            m_damageReduced,
            m_updateCasterLastKnownPos,
            m_updateTargetLastKnownPos,
            m_updateEffectHolderLastKnownPos,
            m_updateOtherLastKnownPos,
            m_isPartOfHealOverTime,
            m_triggerCasterVisOnHitVisualOnly);

        stream.Serialize(ref bitField2);

        if (m_hasDamage)
        {
            short finalDamage = (short)m_finalDamage;
            stream.Serialize(ref finalDamage);
        }
        if (m_hasHealing)
        {
            short finalHealing = (short)m_finalHealing;
            stream.Serialize(ref finalHealing);
        }
        if (m_hasTechPointGain)
        {
            short finalTechPointsGain = (short)m_finalTechPointsGain;
            stream.Serialize(ref finalTechPointsGain);
        }
        if (m_hasTechPointLoss)
        {
            short finalTechPointsLoss = (short)m_finalTechPointsLoss;
            stream.Serialize(ref finalTechPointsLoss);
        }
        if (m_hasTechPointGainOnCaster)
        {
            short finalTechPointGainOnCaster = (short)m_finalTechPointGainOnCaster;
            stream.Serialize(ref finalTechPointGainOnCaster);
        }
        if (m_hasKnockback)
        {
            short actorIndex = (short)(m_knockbackSourceActor?.ActorIndex ?? ActorData.s_invalidActorIndex);
            stream.Serialize(ref actorIndex);
        }
        if (m_hasDamage && m_targetInCoverWrtDamage || m_hasKnockback)
        {
            float damageHitOriginX = m_damageHitOrigin.x;
            float damageHitOriginZ = m_damageHitOrigin.z;
            stream.Serialize(ref damageHitOriginX);
            stream.Serialize(ref damageHitOriginZ);
        }
        if (m_updateEffectHolderLastKnownPos)
        {
            short effectHolderActor = (short)(m_effectHolderActor?.ActorIndex ?? ActorData.s_invalidActorIndex);
            stream.Serialize(ref effectHolderActor);
        }
        if (m_updateOtherLastKnownPos)
        {
            byte otherActorsToUpdateVisibilityNum = (byte)(m_otherActorsToUpdateVisibility?.Count ?? 0);
            stream.Serialize(ref otherActorsToUpdateVisibilityNum);
            for (int i = 0; i < otherActorsToUpdateVisibilityNum; i++)
            {
                short actorIndex = (short)m_otherActorsToUpdateVisibility[i].ActorIndex;
                stream.Serialize(ref actorIndex);
            }
        }

        bool hasEffectsToStart          = !m_effectsToStart.IsNullOrEmpty();
        bool hasEffectsToRemove         = !m_effectsToRemove.IsNullOrEmpty();
        bool hasBarriersToAdd           = !m_barriersToAdd.IsNullOrEmpty();
        bool hasBarriersToRemove        = !m_barriersToRemove.IsNullOrEmpty();
        bool hasSequencesToEnd          = !m_sequencesToEnd.IsNullOrEmpty();
        bool hasReactions               = !m_reactions.IsNullOrEmpty();
        bool hasPowerupsToRemove        = !m_powerupsToRemove.IsNullOrEmpty();
        bool hasPowerupsToSteal         = !m_powerupsToSteal.IsNullOrEmpty();
        bool hasDirectPowerupHits       = !m_directPowerupHits.IsNullOrEmpty();
        bool hasGameModeEvents          = !m_gameModeEvents.IsNullOrEmpty();
        bool isCharacterSpecificAbility = m_isCharacterSpecificAbility;
        bool hasOverconIds              = !m_overconIds.IsNullOrEmpty();
        byte bitField3 = ServerClientUtils.CreateBitfieldFromBools(
            hasEffectsToStart,
            hasEffectsToRemove,
            hasBarriersToRemove,
            hasSequencesToEnd,
            hasReactions,
            hasPowerupsToRemove,
            hasPowerupsToSteal,
            hasDirectPowerupHits);
        byte bitField4 = ServerClientUtils.CreateBitfieldFromBools(
            hasGameModeEvents,
            isCharacterSpecificAbility,
            hasBarriersToAdd,
            hasOverconIds,
            false, false, false, false);

        stream.Serialize(ref bitField3);
        stream.Serialize(ref bitField4);

        if (hasEffectsToStart)
        {
            AbilityResultsUtils.SerializeEffectsToStartToStream(ref stream, m_effectsToStart);
        }
        if (hasEffectsToRemove)
        {
            AbilityResultsUtils.SerializeIntListToStream(ref stream, m_effectsToRemove);
        }
        if (hasBarriersToAdd)
        {
            AbilityResultsUtils.SerializeBarriersToStartToStream(ref stream, m_barriersToAdd);
        }
        if (hasBarriersToRemove)
        {
            AbilityResultsUtils.SerializeIntListToStream(ref stream, m_barriersToRemove);
        }
        if (hasSequencesToEnd)
        {
            AbilityResultsUtils.SerializeSequenceEndDataListToStream(ref stream, m_sequencesToEnd);
        }
        if (hasReactions)
        {
            AbilityResultsUtils.SerializeClientReactionResultsToStream(ref stream, m_reactions);
        }
        if (hasPowerupsToRemove)
        {
            AbilityResultsUtils.SerializeIntListToStream(ref stream, m_powerupsToRemove);
        }
        if (hasPowerupsToSteal)
        {
            AbilityResultsUtils.SerializePowerupsToStealToStream(ref stream, m_powerupsToSteal);
        }
        if (hasDirectPowerupHits)
        {
            AbilityResultsUtils.SerializeClientMovementResultsListToStream(ref stream, m_directPowerupHits);
        }
        if (hasGameModeEvents)
        {
            AbilityResultsUtils.SerializeClientGameModeEventListToStream(ref stream, m_gameModeEvents);
        }
        if (hasOverconIds)
        {
            AbilityResultsUtils.SerializeIntListToStream(ref stream, m_overconIds);
        }
        m_isCharacterSpecificAbility = isCharacterSpecificAbility;
    }
Ejemplo n.º 3
0
    // was empty
    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        uint setBits    = uint.MaxValue;
        var  initialPos = writer.Position;

        if (!forceAll)
        {
            setBits = syncVarDirtyBits;
            writer.WritePackedUInt32(setBits);
        }

        writer.Write((sbyte)m_actorIndex);

        if (IsBitDirty(setBits, DirtyBit.FacingDirection))
        {
            writer.Write((short)VectorUtils.HorizontalAngle_Deg(m_facingDirAfterMovement));
        }

        if (IsBitDirty(setBits, DirtyBit.MoveFromBoardSquare))
        {
            writer.Write((short)(MoveFromBoardSquare?.x ?? -1));
            writer.Write((short)(MoveFromBoardSquare?.y ?? -1));
        }

        if (IsBitDirty(setBits, DirtyBit.InitialMoveStartSquare))
        {
            writer.Write((short)(InitialMoveStartSquare?.x ?? -1));
            writer.Write((short)(InitialMoveStartSquare?.y ?? -1));
        }

        if (IsBitDirty(setBits, DirtyBit.LineData))
        {
            writer.Write(ServerClientUtils.CreateBitfieldFromBools(m_movementLine != null,
                                                                   m_numNodesInSnaredLine != 0, false, false, false, false, false, false));
            if (m_movementLine != null)
            {
                LineData.SerializeLine(m_movementLine, writer);
            }

            if (m_numNodesInSnaredLine != 0)
            {
                writer.Write((sbyte)m_numNodesInSnaredLine);
            }
        }

        if (IsBitDirty(setBits, DirtyBit.MovementCameraBound))
        {
            writer.Write((short)MovementCameraBounds.center.x);
            writer.Write((short)MovementCameraBounds.center.z);
            writer.Write((short)MovementCameraBounds.size.x);
            writer.Write((short)MovementCameraBounds.size.z);
        }

        if (IsBitDirty(setBits, DirtyBit.Respawn))
        {
            writer.Write((short)(RespawnPickedSquare?.x ?? -1));
            writer.Write((short)(RespawnPickedSquare?.y ?? -1));

            writer.Write(false);             // TODO respawningThisTurn

            writer.Write((short)m_respawnAvailableSquares.Count);
            foreach (var square in m_respawnAvailableSquares)
            {
                writer.Write((short)square.x);
                writer.Write((short)square.y);
            }
        }

        if (IsBitDirty(setBits, DirtyBit.QueuedAbilities) || IsBitDirty(setBits, DirtyBit.AbilityRequestDataForTargeter))
        {
            SerializeAbilityRequestData(writer);
        }

        if (IsBitDirty(setBits, DirtyBit.QueuedAbilities))
        {
            short queuedAbilitiesBitmask = 0;
            for (var index = 0; index < 14; ++index)
            {
                var flag = (short)(1 << index);
                if (m_queuedAbilities[index])
                {
                    queuedAbilitiesBitmask |= flag;
                }
            }

            writer.Write(queuedAbilitiesBitmask);
        }

        if (IsBitDirty(setBits, DirtyBit.ToggledOnAbilities))
        {
            short toggledOnAbilitiesBitmask = 0;
            for (var index = 0; index < 14; ++index)
            {
                var flag = (short)(1 << index);
                if (m_abilityToggledOn[index])
                {
                    toggledOnAbilitiesBitmask |= flag;
                }
            }

            writer.Write(toggledOnAbilitiesBitmask);
        }

        return(initialPos != writer.Position);
    }