Exemple #1
0
    public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
    {
        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);
    }
    public override void Serialize(NetworkWriter writer)
    {
        base.Serialize(writer);
        writer.WriteUInt16(componentTypeToComponentID[ComponentType]);
        writer.WriteByte(interactionTypeToInteractionID[InteractionType]);
        writer.WriteUInt32(ProcessorObject);

        if (InteractionType == typeof(PositionalHandApply))
        {
            writer.WriteUInt32(TargetObject);
            writer.WriteVector2(TargetVector);
        }
        else if (InteractionType == typeof(HandApply))
        {
            writer.WriteUInt32(TargetObject);
            writer.WriteInt32((int)TargetBodyPart);
        }
        else if (InteractionType == typeof(AimApply))
        {
            writer.WriteVector2(TargetVector);
            writer.WriteBoolean(MouseButtonState == MouseButtonState.PRESS);
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            writer.WriteUInt32(TargetObject);
            writer.WriteUInt32(UsedObject);
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            writer.WriteUInt32(UsedObject);
            writer.WriteUInt32(Storage);
            writer.WriteInt32(SlotIndex);
            writer.WriteInt32((int)NamedSlot);
        }
    }
Exemple #3
0
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteString(Name);
     writer.WriteBoolean(IsUniCloth);
     writer.WriteVector2(WorldPosition);
 }
        public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
        {
            context.RefSerializer.SerializeReference(ref writer, "triggerEntity", TriggeredEntity);
            context.RefSerializer.SerializeReference(ref writer, "PreTriggeredEntity", PreTriggeredEntity);

            writer.WriteBoolean("IsAllowTrigger", IsAllowTrigger);
        }
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteUInt32(ProcessorObject);
     writer.WriteVector2(TargetVector);
     writer.WriteBoolean(MouseButtonState == MouseButtonState.PRESS);
 }
        bool WriteParameters(NetworkWriter writer, bool forceAll = false)
        {
            ulong dirtyBits = forceAll ? (~0ul) : NextDirtyBits();

            writer.WritePackedUInt64(dirtyBits);
            for (int i = 0; i < parameters.Length; i++)
            {
                if ((dirtyBits & (1ul << i)) == 0)
                {
                    continue;
                }

                AnimatorControllerParameter par = parameters[i];
                if (par.type == AnimatorControllerParameterType.Int)
                {
                    int newIntValue = _animator.GetInteger(par.nameHash);
                    writer.WritePackedInt32(newIntValue);
                }
                else if (par.type == AnimatorControllerParameterType.Float)
                {
                    float newFloatValue = _animator.GetFloat(par.nameHash);
                    writer.WriteSingle(newFloatValue);
                }
                else if (par.type == AnimatorControllerParameterType.Bool)
                {
                    bool newBoolValue = _animator.GetBool(par.nameHash);
                    writer.WriteBoolean(newBoolValue);
                }
            }
            return(dirtyBits != 0);
        }
Exemple #7
0
 public override void Serialize(ref NetworkWriter writer)
 {
     writer.WriteInt32("intValue", intValue);
     writer.WriteBoolean("boolValue", boolValue);
     writer.WriteFloat("floatValue", floatValue);
     writer.WriteString("stringValue", stringValue);
 }
Exemple #8
0
 public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
 {
     writer.WriteInt32("tick", tick);
     writer.WriteVector3Q("velocity", velocity, 2);
     writer.WriteInt32("action", (int)action);
     writer.WriteInt32("actionStartTick", actionStartTick);
     writer.WriteInt32("phase", (int)locoState);
     writer.WriteInt32("phaseStartTick", locoStartTick);
     writer.WriteVector3Q("position", position, 2);
     writer.WriteInt32("boostingInAirCount", boostingInAirCount);
     writer.WriteBoolean("releasedJumpInAir", releasedJump == 1);
     writer.WriteBoolean("boosting", boosting == 1);
     writer.WriteByte("cameraProfile", (byte)cameraProfile);
     writer.WriteInt32("damageTick", damageTick);
     writer.WriteVector3Q("damageDirection", damageDirection);
 }
Exemple #9
0
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteUInt64(BookshelfID);
     writer.WriteBoolean(IsNewBookshelf);
     writer.WriteString(AdminId);
     writer.WriteString(AdminToken);
 }
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteString(Userid);
     writer.WriteString(AdminToken);
     writer.WriteString(NextGameMode);
     writer.WriteBoolean(IsSecret);
 }
Exemple #11
0
        public static void WritePlayerInputs(this NetworkWriter writer, PlayerInputs inputs)
        {
            writer.WriteVector2(inputs.MoveDirections);
            writer.WriteVector2(inputs.LookDirections);

            writer.WriteBoolean(inputs.Jump);
            writer.WriteInt32(inputs.InputNum);
        }
 public void Serialize(ref NetworkWriter writer, IEntityReferenceSerializer refSerializer)
 {
     writer.WriteInt32("phase", (int)phase);
     writer.WriteInt32("phaseStart", phaseStartTick);
     writer.WriteInt32("ammoInClip", ammoInClip);
     writer.WriteBoolean("reloadRequested", reloadRequested == 1);
     writer.WriteFloatQ("fireRate", fireRate, 2);
 }
Exemple #13
0
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteUInt32(Weapon);
     writer.WriteVector2(Direction);
     writer.WriteInt32((int)DamageZone);
     writer.WriteUInt32(Shooter);
     writer.WriteBoolean(IsSuicideShot);
 }
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteString(AntagName);
     writer.WriteString(AntagSound);
     writer.WriteColor(TextColor);
     writer.WriteColor(BackgroundColor);
     writer.WriteBoolean(PlaySound);
 }
Exemple #15
0
        public void Serialize(ref SerializeContext context, ref NetworkWriter writer)
        {
            writer.WriteVector3("position", position);
            writer.WriteBoolean("exploded", exploded == 1);
            writer.WriteInt32("bouncetick", bouncetick);

            //Added
            writer.WriteVector3("velocity", velocity);
        }
Exemple #16
0
 public override void Serialize(NetworkWriter writer)
 {
     writer.WriteString(SoundName);
     writer.WriteVector3(Position);
     writer.WriteBoolean(Polyphonic);
     writer.WriteUInt32(TargetNetId);
     writer.WriteString(JsonConvert.SerializeObject(ShakeParameters));
     writer.WriteString(JsonConvert.SerializeObject(AudioSourceParameters));
 }
Exemple #17
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();
    }
Exemple #18
0
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteString(Userid);
     writer.WriteString(AdminToken);
     writer.WriteString(UserToKick);
     writer.WriteString(Reason);
     writer.WriteBoolean(IsBan);
     writer.WriteInt32(BanMinutes);
 }
Exemple #19
0
        public static void WriteBattleViewEventCommandAgent(this NetworkWriter writer, PBS.Battle.View.Events.CommandAgent obj)
        {
            writer.WriteString(obj.pokemonUniqueID);
            writer.WriteBoolean(obj.canMegaEvolve);
            writer.WriteBoolean(obj.canZMove);
            writer.WriteBoolean(obj.canDynamax);
            writer.WriteBoolean(obj.isDynamaxed);
            writer.WriteList(obj.moveslots);
            writer.WriteList(obj.zMoveSlots);
            writer.WriteList(obj.dynamaxMoveSlots);

            List <int> commandInts = new List <int>();

            for (int i = 0; i < obj.commandTypes.Count; i++)
            {
                commandInts.Add((int)obj.commandTypes[i]);
            }
            writer.WriteList(commandInts);
        }
 public static void Serialize(this NetworkWriter writer, MessageGameInfo value)
 {
     writer.WriteSingle(value.VictimVision);
     writer.WriteInt32(value.VictimLives);
     writer.WriteSingle(value.VictimSpeed);
     writer.WriteSingle(value.HunterVision);
     writer.WriteSingle(value.HunterKillCooldown);
     writer.WriteSingle(value.HunterSpeed);
     writer.WriteInt32(value.Hunters);
     writer.WriteBoolean(value.DisplayHunters);
     writer.WriteSingle(value.VictimTaskDistance);
     writer.WriteSingle(value.HunterKillDistance);
     writer.WriteSingle(value.HunterVisionOnCooldown);
     writer.WriteInt32(value.VictimCommonTasks);
     writer.WriteInt32(value.VictimLongTasks);
     writer.WriteInt32(value.VictimShortTasks);
     writer.WriteSingle(value.TimeLimit);
     writer.WriteColor(value.DefaultColor);
     writer.WriteBoolean(value.TasksBalancedDamage);
 }
            private int GetSizeEntityEquip(NetworkWriter dummyWriter)
            {
                dummyWriter.WriteInt32(_equipableSyncMethod.Count);
                for (int i = 0; i < _equipablesToSync.Count; i++)
                {
                    dummyWriter.WriteBoolean(_equipableSyncMethod[i]);
                    dummyWriter.WriteEntityEquipable(_equipablesToSync[i]);
                }

                return(dummyWriter.Length);
            }
 public override void Serialize(NetworkWriter writer)
 {
     base.Serialize(writer);
     writer.WriteUInt16(soID);
     writer.WriteInt32(SpriteLocation);
     writer.WriteInt32(ComponentLocation);
     writer.WriteUInt32(NetObject);
     writer.WriteBoolean(showAlert);
     writer.WriteUInt16(RequestGameAction.componentTypeToComponentID[ComponentType]);
     writer.WriteInt32((int)ProposedAction);
 }
Exemple #23
0
 public void Serialize(ref NetworkWriter networkWriter, IEntityReferenceSerializer refSerializer)
 {
     refSerializer.SerializeReference(ref networkWriter, "owner", projectileOwner);
     networkWriter.WriteUInt16("typeId", (ushort)projectileTypeRegistryId);
     networkWriter.WriteInt32("startTick", startTick);
     networkWriter.WriteVector3Q("startPosition", startPos, 2);
     networkWriter.WriteVector3Q("endPosition", endPos, 2);
     networkWriter.WriteBoolean("impacted", impacted == 1);
     networkWriter.WriteVector3Q("impactPosition", impactPos, 2);
     networkWriter.WriteVector3Q("impactNormal", impactNormal, 2);
 }
            private void RegisterEntityEquip(SyncableVariable var, NetworkWriter writer)
            {
                writer.WriteInt32(_equipableSyncMethod.Count);
                for (int i = 0; i < _equipablesToSync.Count; i++)
                {
                    writer.WriteBoolean(_equipableSyncMethod[i]);
                    writer.WriteEntityEquipable(_equipablesToSync[i]);
                }

                _equipableSyncMethod.Clear();
                _equipablesToSync.Clear();
            }
Exemple #25
0
        public override void Serialize(NetworkWriter writer)
        {
            base.Serialize(writer);

            writer.WriteGameObject(Entity);
            writer.WriteInt32(Settings.PortalHeight);
            writer.WriteSingle(Settings.PortalOpenTime);
            writer.WriteSingle(Settings.PortalCloseTime);
            writer.WriteSingle(Settings.PortalSuspenseTime);
            writer.WriteBoolean(Settings.EntityRotate);
            writer.WriteInt32((int)Type);
        }
 public void Serialize(ref NetworkWriter networkWriter, IEntityReferenceSerializer refSerializer)
 {
     networkWriter.WriteInt32("tick", checkTick);
     networkWriter.WriteInt32("renderTick", renderTick);
     networkWriter.WriteFloatQ("moveYaw", moveYaw, 0);
     networkWriter.WriteFloatQ("moveMagnitude", moveMagnitude, 2);
     networkWriter.WriteFloat("lookYaw", lookYaw);
     networkWriter.WriteFloat("lookPitch", lookPitch);
     networkWriter.WriteBoolean("jump", jump);
     networkWriter.WriteBoolean("boost", boost);
     networkWriter.WriteBoolean("sprint", sprint);
     networkWriter.WriteBoolean("primaryFire", primaryFire);
     networkWriter.WriteBoolean("secondaryFire", secondaryFire);
     networkWriter.WriteBoolean("abilityA", abilityA);
     networkWriter.WriteBoolean("reload", reload);
     networkWriter.WriteBoolean("melee", melee);
     networkWriter.WriteBoolean("use", use);
 }
Exemple #27
0
        public static void WriteEntityEquipableAbility(this NetworkWriter writer, EntityEquipableAbility equipableAbility)
        {
            writer.WriteInt32(equipableAbility.Ability.AbilityID);
            writer.WriteBoolean(equipableAbility.OverrideTrigger);
            if (equipableAbility.OverrideTrigger)
            {
                writer.WriteAbilityTriggerData(equipableAbility.TriggerData);
            }
            writer.WriteBoolean(equipableAbility.OverrideCooldown);
            if (equipableAbility.OverrideCooldown)
            {
                writer.WriteDouble(equipableAbility.Cooldown);
            }

            int abilitiesResourcesInfluencesLength = equipableAbility.AbilitiesResourcesInfluences == null ? 0 : equipableAbility.AbilitiesResourcesInfluences.Length;

            writer.WriteInt32(abilitiesResourcesInfluencesLength);
            for (int i = 0; i < abilitiesResourcesInfluencesLength; i++)
            {
                writer.EntityEquipableAbilityResourcesInfluences(equipableAbility.AbilitiesResourcesInfluences[i]);
            }
        }
Exemple #28
0
        // TODO: This could be made more efficient. Especially when the subStates are all nulls.

        public static void WriteNetworkableTileDefinition(this NetworkWriter writer, TileDefinition definition)
        {
            writer.WriteString(definition.turf?.name ?? "");
            writer.WriteString(definition.fixture?.name ?? "");

            // Use C# serializer to serialize the object array, cos the Mirror one isn't powerful enough.

            // Can't serialize null values so put a boolean indicating array presence first
            if (definition.subStates == null || definition.subStates.All(obj => obj == null))
            {
                writer.WriteBoolean(false);
            }
            else
            {
                writer.WriteBoolean(true);

                using (var stream = new MemoryStream()) {
                    new BinaryFormatter().Serialize(stream, definition.subStates);
                    writer.WriteBytesAndSize(stream.ToArray());
                }
            }
        }
        public override bool OnSerialize(NetworkWriter writer, bool initialState)
        {
            bool dataWritten = base.OnSerialize(writer, initialState);

            if (initialState)
            {
                writer.WriteDouble(this.SecondsLeft);
                writer.WriteBoolean(this.IsTimerRunning);
                dataWritten = true;
            }

            return(dataWritten);
        }
Exemple #30
0
 // Pokemon
 public static void WriteBattleViewCompactPokemon(this NetworkWriter writer, PBS.Battle.View.WifiFriendly.Pokemon obj)
 {
     writer.WriteString(obj.uniqueID);
     writer.WriteString(obj.pokemonID);
     writer.WriteString(obj.nickname);
     writer.WriteInt32(obj.teamPos);
     writer.WriteInt32(obj.battlePos);
     writer.WriteInt32(obj.currentHP);
     writer.WriteInt32(obj.maxHP);
     writer.WriteBoolean(obj.isFainted);
     writer.WriteInt32(obj.level);
     writer.WriteInt32((int)obj.gender);
     writer.WriteString(obj.nonVolatileStatus);
     writer.WriteInt32((int)obj.dynamaxState);
 }