private Order ReadOrder(NetDataReader reader) { int playerIndex = reader.GetInt(); OrderType orderType = (OrderType)reader.GetInt(); var order = new Order(playerIndex, orderType); byte argumentCount = reader.GetByte(); for (int i = 0; i < argumentCount; i++) { OrderArgumentType argumentType = (OrderArgumentType)reader.GetInt(); switch (argumentType) { case OrderArgumentType.Integer: order.AddIntegerArgument(reader.GetInt()); break; case OrderArgumentType.Float: order.AddFloatArgument(reader.GetFloat()); break; case OrderArgumentType.Boolean: order.AddBooleanArgument(reader.GetBool()); break; case OrderArgumentType.ObjectId: order.AddObjectIdArgument(reader.GetUInt()); break; case OrderArgumentType.Position: order.AddPositionArgument(new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat())); break; case OrderArgumentType.ScreenPosition: order.AddScreenPositionArgument(new Point2D(reader.GetInt(), reader.GetInt())); break; case OrderArgumentType.ScreenRectangle: order.AddScreenRectangleArgument(new Rectangle(reader.GetInt(), reader.GetInt(), reader.GetInt(), reader.GetInt())); break; default: throw new NotImplementedException("We don't know the other argument types"); } } return(order); }
public object Deserialize(NetDataReader stream) { var objToSerialize = new Vec2(); { objToSerialize.X = stream.GetFloat(); } { objToSerialize.Y = stream.GetFloat(); } return(objToSerialize); }
public void Deserialize(NetDataReader reader) { coreEnergyCap = reader.GetDouble(); corePowerGen = reader.GetDouble(); reactorPowerGen = reader.GetDouble(); walkPower = reader.GetDouble(); jumpEnergy = reader.GetDouble(); thrustPowerPerAcc = reader.GetDouble(); warpKeepingPowerPerSpeed = reader.GetDouble(); warpStartPowerPerSpeed = reader.GetDouble(); miningPower = reader.GetDouble(); replicatePower = reader.GetDouble(); researchPower = reader.GetDouble(); droneEjectEnergy = reader.GetDouble(); droneEnergyPerMeter = reader.GetDouble(); coreLevel = reader.GetInt(); thrusterLevel = reader.GetInt(); miningSpeed = reader.GetFloat(); replicateSpeed = reader.GetFloat(); walkSpeed = reader.GetFloat(); jumpSpeed = reader.GetFloat(); maxSailSpeed = reader.GetFloat(); maxWarpSpeed = reader.GetFloat(); buildArea = reader.GetFloat(); droneCount = reader.GetInt(); droneSpeed = reader.GetFloat(); droneMovement = reader.GetInt(); inventorySize = reader.GetInt(); }
public void ReceiveCollision(NetPeer peer, NetDataReader reader) { var userId = reader.GetString(); var collidedId = reader.GetString(); var collsionX = reader.GetFloat(); var collsionY = reader.GetFloat(); var collsionZ = reader.GetFloat(); var colPos = new Vector3(collsionX, collsionY, collsionZ); if (OnReceivePlayerCollision != null) { OnReceivePlayerCollision(userId, collidedId, colPos); } }
public void ReceiveAnimation(NetPeer peer, NetDataReader reader) { var userId = reader.GetString(); var HP = reader.GetFloat(); var IsGrounded = reader.GetBool(); var Movement = reader.GetFloat(); var Dir = reader.GetFloat(); var Flap = reader.GetBool(); var PumpProgress = reader.GetFloat(); if (OnReceiveAnimationPlayerUpdate != null) { OnReceiveAnimationPlayerUpdate(userId, HP, IsGrounded, Movement, Dir, Flap, PumpProgress); } }
public UpdateVariableData(NetDataReader reader, NetPeer sender) : base(sender) { variabeleDataType = (VariableDataType)reader.GetShort(); variableName = reader.GetString(); objectID = reader.GetLong(); switch (variabeleDataType) { case VariableDataType.Bool: this.variableDataBool = reader.GetBool(); break; case VariableDataType.Float: this.variableDataFloat = reader.GetFloat(); break; case VariableDataType.Long: this.variableDataLong = reader.GetLong(); break; case VariableDataType.String: this.variableDataString = reader.GetString(); break; case VariableDataType.Vector2: this.variableDataVector2 = reader.GetVector2(); break; } }
public void Deserialize(NetDataReader reader) { Id = reader.GetByte(); Position = reader.GetVector2(); Rotation = reader.GetFloat(); Tick = reader.GetUShort(); }
public void Deserialize(NetDataReader reader) { Id = reader.GetUShort(); Keys = (MovementKeys)reader.GetByte(); Rotation = reader.GetFloat(); ServerTick = reader.GetUShort(); }
public void Read(NetDataReader reader) { origin = reader.GetVector3(); force = reader.GetVector3(); forceFallof = reader.GetFloat(); bodyPartFactor = reader.GetFloatArray(); }
public void Deserialize(NetDataReader reader) { type = (BuffType)reader.GetByte(); dataId = reader.GetInt(); level = reader.GetShort(); buffRemainsDuration = reader.GetFloat(); }
public void Deserialize(NetDataReader reader) { Id = reader.GetByte(); Position.x = reader.GetFloat(); Position.y = reader.GetFloat(); Position.z = reader.GetFloat(); Rotation.x = reader.GetFloat(); Rotation.y = reader.GetFloat(); Rotation.z = reader.GetFloat(); Rotation.w = reader.GetFloat(); Yaw = reader.GetFloat(); Pitch = reader.GetFloat(); }
public override void OnRead(NetDataReader reader, bool initialState) { base.OnRead(reader, initialState); if (isOwner) { reader.GetBool(); reader.GetBool(); reader.GetFloat(); reader.GetFloat(); return; } _SpawnedLight = reader.GetBool(); _Landed = reader.GetBool(); _JumpTimer = reader.GetFloat(); _Timer = reader.GetFloat(); }
public void ReceiveAnimation(NetPeer peer, NetDataReader reader) { string UserId = reader.GetString(); if (!animationPool.ContainsKey(UserId)) { animationPool.Add(UserId, new AnimationState() { }); } animationPool[UserId].HP = reader.GetFloat(); animationPool[UserId].IsGrounded = reader.GetBool(); animationPool[UserId].Movement = reader.GetFloat(); animationPool[UserId].Dir = reader.GetFloat(); animationPool[UserId].Flap = reader.GetBool(); animationPool[UserId].PumpProgress = reader.GetFloat(); }
public void ReceiveCollision(NetPeer peer, NetDataReader reader) { string userId = reader.GetString(); string collidedId = reader.GetString(); float x = reader.GetFloat(), y = reader.GetFloat(), z = reader.GetFloat(); if (peerPool.ContainsKey(collidedId)) { var cmd = SendCommand(5); cmd.Put(userId); cmd.Put(collidedId); cmd.Put(x); cmd.Put(y); cmd.Put(z); peerPool[collidedId].Send(cmd, DeliveryMethod.ReliableOrdered); } }
public void Deserialize(NetDataReader reader) { this.levelId = reader.GetString(); this.songName = reader.GetString(); this.songSubName = reader.GetString(); this.songAuthorName = reader.GetString(); this.levelAuthorName = reader.GetString(); this.beatsPerMinute = reader.GetFloat(); this.songDuration = reader.GetFloat(); this.characteristic = reader.GetString(); this.difficulty = (BeatmapDifficulty)reader.GetVarUInt(); this.coverImage = reader.GetBytesWithLength(); //if (this.coverImage == null || this.coverImage.Length == 0) //Plugin.Log?.Debug($"Received a PreviewBeatmapPacket with an empty coverImage."); }
public static NO_Status GetStatus(this NetDataReader reader) { short statusId = reader.GetShort(); int value = reader.GetInt(); float time = reader.GetFloat(); return(new NO_Status(statusId, value, time)); }
public void RestoreNetworkState(NetDataReader reader) { Owner.Transform.Position = new Vector2(reader.GetFloat(), reader.GetFloat()); curVelocity = new Vector2(reader.GetFloat(), reader.GetFloat()); Owner.Transform.Scale = new Vector2(reader.GetFloat(), reader.GetFloat()); Owner.Transform.Rotation = reader.GetFloat(); }
internal override void Deserialize(NetDataReader reader) { Card.CastLock = reader.GetBool(); TypingTimer = reader.GetFloat(); Player1.Deserialize(reader); Player2.Deserialize(reader); }
public void Deserialize(NetDataReader reader) { EntityState ent = new EntityState(); DeliveryTime = reader.GetFloat(); Tick = reader.GetInt(); States = new EntityState[1]; ent.Deserialize(reader); States[0] = ent; }
public void ReceiveRedZone(NetPeer peer, NetDataReader reader) { //Debug.Log("Received Red Zone..."); var redZoneDistance = reader.GetFloat(); if (OnReceiveRedZone != null) { OnReceiveRedZone(redZoneDistance); } }
public override void OnRead(NetDataReader reader, bool initialState) { if (isOwner) { reader.GetBool(); reader.GetBool(); reader.GetFloat(); return; } pickedUp = reader.GetBool(); PickupCollider.enabled = reader.GetBool(); chargeTimeCurrent = reader.GetFloat(); if (!pickedUp && transform.parent != null) { transform.SetParent(null, true); Debug.Log("Something went wrong. It's fixed now tho!"); } }
public void WriteReadFloat() { var ndw = new NetDataWriter(); ndw.Put(3.1415f); var ndr = new NetDataReader(ndw.Data); var readFloat = ndr.GetFloat(); Assert.AreEqual(readFloat, 3.1415f); }
public virtual void ReadData(NetDataReader reader) { position.x = reader.GetFloat(); position.y = reader.GetFloat(); position.z = reader.GetFloat(); rotation.x = reader.GetFloat(); rotation.y = reader.GetFloat(); rotation.z = reader.GetFloat(); rotation.w = reader.GetFloat(); }
public void Deserialize(NetDataReader reader) { objectId = reader.GetPackedUInt(); connectionId = reader.GetPackedLong(); position = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); rotation = Quaternion.Euler(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); }
public void OnNetworkReceive(NetPeer peer, NetDataReader reader) { _newBallPosX = reader.GetFloat(); var pos = _clientBall.transform.position; _oldBallPosX = pos.x; pos.x = _newBallPosX; _clientBall.transform.position = pos; _lerpTime = 0f; }
private float DeserializePositionAxis(NetDataReader reader, SyncPositionOptions syncOptions, float defaultValue) { switch (syncOptions) { case SyncPositionOptions.Sync: return(reader.GetFloat()); default: case SyncPositionOptions.NotSync: break; } return(defaultValue); }
public void Deserialize(NetDataReader reader) { hashAssetId = reader.GetInt(); objectId = reader.GetPackedUInt(); isOwner = reader.GetBool(); position = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); rotation = Quaternion.Euler(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); }
public virtual void Deserialize(NetDataReader reader) { typeId = reader.GetString(); assetId = reader.GetString(); objectId = reader.GetUShort(); position = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); rotation = new Quaternion(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat()); }
public void OnNetworkReceive(NetPeer peer, NetDataReader reader) { // Debug.Log("OnNetworkReceive"); if (reader.Data == null) { return; } Debug.Log($"OnNetworkReceive: reader.Data.Length == {reader.Data.Length}"); if (reader.Data.Length >= 4) { NetworkTags networkTag = (NetworkTags)reader.GetInt(); if (networkTag == NetworkTags.NT_S_Send_Players_Pos_Array) { int lengthArr = (reader.Data.Length - 4) / (sizeof(long) + sizeof(float) * 3); Debug.Log("Got positions array data num : " + lengthArr); for (int i = 0; i < lengthArr; i++) { long playerid = reader.GetLong(); if (!netPlayersDictionary.ContainsKey(playerid)) { netPlayersDictionary.Add(playerid, new NetPlayer()); } netPlayersDictionary[playerid].X = reader.GetFloat(); netPlayersDictionary[playerid].Y = reader.GetFloat(); netPlayersDictionary[playerid].Z = reader.GetFloat(); // Debug.Log("playerid: " + playerid + " Pose updated Ok"); } } } }
private TransformResult DeserializeResult(NetDataReader reader) { TransformResult result = new TransformResult(); result.position = new Vector3( DeserializePositionAxis(reader, syncPositionX, syncingTransform.position.x), DeserializePositionAxis(reader, syncPositionY, syncingTransform.position.y), DeserializePositionAxis(reader, syncPositionZ, syncingTransform.position.z)); result.rotation = Quaternion.Euler( DeserializeRotationAxis(reader, syncRotationX, syncingTransform.rotation.eulerAngles.x), DeserializeRotationAxis(reader, syncRotationY, syncingTransform.rotation.eulerAngles.y), DeserializeRotationAxis(reader, syncRotationZ, syncingTransform.rotation.eulerAngles.z)); result.timestamp = reader.GetFloat(); return(result); }