本文整理汇总了C#中VRage.Network.EndpointId类的典型用法代码示例。如果您正苦于以下问题:C# EndpointId类的具体用法?C# EndpointId怎么用?C# EndpointId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EndpointId类属于VRage.Network命名空间,在下文中一共展示了EndpointId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Serialize
public override bool Serialize(BitStream stream, EndpointId forClient, uint timestamp, byte packetId, int maxBitPosition)
{
bool lowPrecisionOrientation = true;
bool applyWhenReading = true;
SetSupport(FindSupportDelegate());
if (stream.Writing)
{
bool moving = IsMoving(Entity);
stream.WriteBool(moving);
SerializeVelocities(stream, Entity, MyEntityPhysicsStateGroup.EffectiveSimulationRatio, applyWhenReading, moving);
SerializeTransform(stream, Entity, null, lowPrecisionOrientation, applyWhenReading, moving, timestamp);
}
else
{
bool moving = stream.ReadBool();
// reading
SerializeServerVelocities(stream, Entity, MyEntityPhysicsStateGroup.EffectiveSimulationRatio, moving, ref Entity.m_serverLinearVelocity, ref Entity.m_serverAngularVelocity);
applyWhenReading = SerializeServerTransform(stream, Entity, null, moving, timestamp, lowPrecisionOrientation,
ref Entity.m_serverPosition, ref Entity.m_serverOrientation, ref Entity.m_serverWorldMatrix, m_positionValidation);
if (applyWhenReading && moving)
{
Entity.PositionComp.SetWorldMatrix(Entity.m_serverWorldMatrix, null, true);
Entity.SetSpeedsAccordingToServerValues();
}
}
SerializeFriction(stream, Entity);
SerializeActive(stream, Entity);
return true;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:33,代码来源:MySmallObjectPhysicsStateGroup.cs
示例2: ClientWrite
protected override void ClientWrite(VRage.Library.Collections.BitStream stream,EndpointId forClient, uint timestamp, int maxBitPosition)
{
base.ClientWrite(stream,forClient,timestamp,maxBitPosition);
stream.Write(Entity.WorldMatrix.Translation);
MyShipController controller = MySession.Static.ControlledEntity as MyShipController;
stream.WriteBool(m_grid != null && controller != null);
if (m_grid != null && controller != null)
{
stream.WriteBool(m_grid.IsStatic);
if (m_grid.IsStatic == false)
{
stream.WriteBool(controller != null);
if (controller != null)
{
stream.WriteInt64(controller.EntityId);
Vector2 rotation = controller.RotationIndicator;
stream.WriteFloat(rotation.X);
stream.WriteFloat(rotation.Y);
stream.WriteHalf(controller.RollIndicator);
Vector3 position = controller.MoveIndicator;
stream.WriteHalf(position.X);
stream.WriteHalf(position.Y);
stream.WriteHalf(position.Z);
Vector3D gridPosition = m_grid.PositionComp.GetPosition();
MyGridPhysicsStateGroup.WriteSubgrids(m_grid, stream, ref forClient, timestamp, maxBitPosition, m_lowPositionOrientation, ref gridPosition, ref m_currentSentPosition);
}
}
}
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:35,代码来源:MyGridPositionVerificationStateGroup.cs
示例3: MyEventContext
private MyEventContext(EndpointId sender, MyClientStateBase clientState, bool validate)
{
Sender = sender;
ClientState = clientState;
IsValidationRequired = validate;
m_validationFailed = false;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyEventContext.cs
示例4: MyMultiplayerServerBase
/// <summary>
/// Initializes a new instance of the MyMultiplayerServerBase class.
/// </summary>
/// <param name="localClientEndpoint">Local client endpoint (for single player or lobby host) or null (for dedicated server)</param>
public MyMultiplayerServerBase(MySyncLayer syncLayer, EndpointId? localClientEndpoint)
: base(syncLayer)
{
Debug.Assert(MyEntities.GetEntities().Count == 0, "Multiplayer server must be created before any entities are loaded!");
var replication = new MyReplicationServer(this, () => MySandboxGame.Static.UpdateTime, localClientEndpoint);
if (MyFakes.MULTIPLAYER_REPLICATION_TEST)
{
replication.MaxSleepTime = MyTimeSpan.FromSeconds(30);
}
SetReplicationLayer(replication);
ClientLeft += (steamId, e) => ReplicationLayer.OnClientLeft(new EndpointId(steamId));
MyEntities.OnEntityCreate += CreateReplicableForObject;
MyEntityComponentBase.OnAfterAddedToContainer += CreateReplicableForObject;
MyExternalReplicable.Destroyed += DestroyReplicable;
foreach (var entity in MyEntities.GetEntities())
{
CreateReplicableForObject(entity);
var components = entity.Components;
if (components != null)
{
foreach (var comp in components)
CreateReplicableForObject(comp);
}
}
syncLayer.TransportLayer.Register(MyMessageId.RPC, ReplicationLayer.ProcessEvent);
syncLayer.TransportLayer.Register(MyMessageId.REPLICATION_READY, ReplicationLayer.ReplicableReady);
syncLayer.TransportLayer.Register(MyMessageId.CLIENT_UPDATE, ReplicationLayer.OnClientUpdate);
syncLayer.TransportLayer.Register(MyMessageId.CLIENT_READY, (p) => ClientReady(p));
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:37,代码来源:MyMultiplayerServerBase.cs
示例5: ClientWrite
protected override void ClientWrite(VRage.Library.Collections.BitStream stream, EndpointId forClient, uint timestamp, int maxBitPosition)
{
base.ClientWrite(stream, forClient,timestamp,maxBitPosition);
stream.WriteBool(m_character != null);
if (m_character != null)
{
var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup<MyCharacterPhysicsStateGroup>();
long? supportId = null;
if (physGroup != null)
{
physGroup.SetSupport(physGroup.FindSupportDelegate());
supportId = physGroup.GetSupportId();
}
stream.WriteBool(supportId.HasValue);
if (supportId.HasValue)
{
stream.WriteInt64(supportId.Value);
}
Vector3 position = m_character.MoveIndicator;
stream.WriteHalf(position.X);
stream.WriteHalf(position.Y);
stream.WriteHalf(position.Z);
Vector2 rotate = m_character.RotationIndicator;
stream.WriteFloat(rotate.X);
stream.WriteFloat(rotate.Y);
stream.WriteFloat(m_character.RollIndicator);
// Movement state, 2B
stream.WriteUInt16((ushort)m_character.GetNetworkMovementState());
// Movement flag.
stream.WriteUInt16((ushort)m_character.PreviousMovementFlags);
// Flags, 6 bits
bool hasJetpack = m_character.JetpackComp != null;
stream.WriteBool(hasJetpack ? m_character.JetpackComp.TurnedOn : false);
stream.WriteBool(hasJetpack ? m_character.JetpackComp.DampenersTurnedOn : false);
stream.WriteBool(m_character.LightEnabled); // TODO: Remove
stream.WriteBool(m_character.ZoomMode == MyZoomModeEnum.IronSight);
stream.WriteBool(m_character.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
stream.WriteBool(m_character.TargetFromCamera);
stream.WriteFloat(m_character.HeadLocalXAngle);
stream.WriteFloat(m_character.HeadLocalYAngle);
if ((hasJetpack && m_character.JetpackComp.TurnedOn) == false)
{
MatrixD matrix = m_character.WorldMatrix;
stream.WriteQuaternionNorm(Quaternion.CreateFromForwardUp(matrix.Forward, matrix.Up));
}
}
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:57,代码来源:MyCharacterPositionVerificationStateGroup.cs
示例6: Serialize
public override bool Serialize(BitStream stream, EndpointId forClient,uint timeStamp, byte packetId, int maxBitPosition)
{
base.Serialize(stream, forClient,timeStamp, packetId, maxBitPosition);
if (stream.Writing)
{
// Head and spine stuff, 36 - 152b (4.5B - 19 B)
stream.WriteHalf(Entity.HeadLocalXAngle); // 2B
stream.WriteHalf(Entity.HeadLocalYAngle); // 2B
// TODO: Spine has only one angle (bending forward backward)
// Getting EULER angles from Matrix seems good way to get it (z-component)
stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.SpineBone)); // 1b / 30b
stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.HeadBone)); // 1b / 30b
// Movement state, 2B
stream.WriteUInt16((ushort)Entity.GetCurrentMovementState());
// Movement flag.
stream.WriteUInt16((ushort)Entity.MovementFlags);
// Flags, 6 bits
bool hasJetpack = Entity.JetpackComp != null;
stream.WriteBool(hasJetpack ? Entity.JetpackComp.TurnedOn : false);
stream.WriteBool(hasJetpack ? Entity.JetpackComp.DampenersTurnedOn : false);
stream.WriteBool(Entity.LightEnabled); // TODO: Remove
stream.WriteBool(Entity.ZoomMode == MyZoomModeEnum.IronSight);
stream.WriteBool(Entity.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
stream.WriteBool(Entity.TargetFromCamera);
stream.WriteNormalizedSignedVector3(Entity.MoveIndicator, 8);
float speed = Entity.Physics.CharacterProxy != null ? Entity.Physics.CharacterProxy.Speed : 0.0f;
stream.WriteFloat(speed);
stream.WriteFloat(Entity.RotationIndicator.X);
stream.WriteFloat(Entity.RotationIndicator.Y);
stream.WriteFloat(Entity.RollIndicator);
}
else
{
Vector3 move;
MyCharacterNetState charNetState = ReadCharacterState(stream);
if (!IsControlledLocally && !Entity.Closed)
{
Entity.SetStateFromNetwork(ref charNetState);
}
}
return true;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:51,代码来源:MyCharacterPhysicsStateGroup.cs
示例7: OnAskInfo
private static void OnAskInfo()
{
EndpointId sender;
if (MyEventContext.Current.IsLocallyInvoked)
sender = new EndpointId(Sync.MyId);
else
sender = MyEventContext.Current.Sender;
bool isRunning = MyMultiplayer.Static.ScenarioStartTime > DateTime.MinValue;
bool canJoin = !isRunning || MySession.Static.Settings.CanJoinRunning;
MyMultiplayer.RaiseStaticEvent(s => MySyncScenario.OnAnswerInfo, isRunning, canJoin, sender);
int index = (int)MyGuiScreenScenarioMpBase.Static.TimeoutCombo.GetSelectedIndex();
MyMultiplayer.RaiseStaticEvent(s => MySyncScenario.OnSetTimeoutClient, index, sender);
bool canJoinRunning = MySession.Static.Settings.CanJoinRunning;
MyMultiplayer.RaiseStaticEvent(s => MySyncScenario.OnSetJoinRunningClient, canJoinRunning, sender);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:18,代码来源:MySyncScenario.cs
示例8: Serialize
public override bool Serialize(BitStream stream, EndpointId forClient, uint timestamp, byte packetId, int maxBitPosition)
{
bool lowPrecisionOrientation = true;
bool applyWhenReading = true;
if (stream.Writing)
{
bool moving = IsMoving(Entity);
stream.WriteBool(moving);
SerializeVelocities(stream, Entity, MyEntityPhysicsStateGroup.EffectiveSimulationRatio, applyWhenReading, moving);
SerializeTransform(stream, Entity, null, lowPrecisionOrientation, applyWhenReading, moving, timestamp);
}
else
{
bool moving = stream.ReadBool();
// reading
SerializeServerVelocities(stream, Entity, MyEntityPhysicsStateGroup.EffectiveSimulationRatio, moving, ref Entity.m_serverLinearVelocity, ref Entity.m_serverAngularVelocity);
float positionTolerancy = Math.Max(Entity.PositionComp.MaximalSize * 0.1f, 0.1f);
float smallSpeed = 0.1f;
if (Entity.m_serverLinearVelocity == Vector3.Zero || Entity.m_serverLinearVelocity.Length() < smallSpeed)
{
positionTolerancy = Math.Max(Entity.PositionComp.MaximalSize * 0.5f, 1.0f);
}
applyWhenReading = SerializeServerTransform(stream, Entity, null, moving, timestamp, lowPrecisionOrientation, positionTolerancy,
ref Entity.m_serverPosition, ref Entity.m_serverOrientation, ref Entity.m_serverWorldMatrix, m_positionValidation);
if (applyWhenReading && moving)
{
Entity.PositionComp.SetWorldMatrix(Entity.m_serverWorldMatrix, null, true);
Entity.SetSpeedsAccordingToServerValues();
}
}
SerializeFriction(stream, Entity);
SerializeActive(stream, Entity);
return true;
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:38,代码来源:MySmallObjectPhysicsStateGroup.cs
示例9:
void IReplicationServerCallback.SendStateSync(BitStream stream, EndpointId endpoint,bool reliable)
{
SyncLayer.TransportLayer.SendMessage(MyMessageId.SERVER_STATE_SYNC, stream, reliable, endpoint);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:4,代码来源:MyMultiplayerServerBase.cs
示例10: DispatchBlockingEvent
internal override bool DispatchBlockingEvent(BitStream stream, CallSite site, EndpointId recipient, IMyNetObject eventInstance, IMyNetObject blockedNetObj, float unreliablePriority)
{
Debug.Fail("Client should not call blocking events");
// For client this code is old. Only server can dispatch blocking events.
return DispatchEvent(stream, site, recipient, eventInstance, unreliablePriority);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:6,代码来源:MyReplicationClient.cs
示例11: DispatchEvent
internal override bool DispatchEvent(BitStream stream, CallSite site, EndpointId target, IMyNetObject instance, float unreliablePriority)
{
Debug.Assert(site.HasServerFlag, String.Format("Event '{0}' does not have server flag, it can't be invoked on server!", site));
if (site.HasServerFlag)
{
m_callback.SendEvent(stream, site.IsReliable);
//Client.SendMessageToServer(stream, site.Reliability, PacketPriorityEnum.LOW_PRIORITY, MyChannelEnum.Replication);
}
else if (site.HasClientFlag)
{
// Invoke locally only when it has ClientFlag and no ServerFlag
return true;
}
return false;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:16,代码来源:MyReplicationClient.cs
示例12: ProcessEvent
internal override void ProcessEvent(BitStream stream, CallSite site, object obj, IMyNetObject sendAs, EndpointId source)
{
// Client blindly invokes everything received from server (without validation)
Invoke(site, stream, obj, source, null, false);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:5,代码来源:MyReplicationClient.cs
示例13: ClientWrite
protected virtual void ClientWrite(VRage.Library.Collections.BitStream stream, EndpointId forClient, uint timestamp, int maxBitPosition)
{
MatrixD matrix = Entity.WorldMatrix;
stream.WriteQuaternionNorm(Quaternion.CreateFromForwardUp(matrix.Forward, matrix.Up));
stream.Write(matrix.Translation);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:6,代码来源:MyEntityPositionVerificationStateGroup.cs
示例14: Serialize
public bool Serialize(VRage.Library.Collections.BitStream stream, EndpointId forClient, uint timestamp, byte packetId, int maxBitPosition)
{
if (stream.Writing)
{
if (Sync.IsServer)
{
ServerWrite(stream, forClient.Value);
}
else
{
ClientWrite(stream, forClient, timestamp,maxBitPosition);
}
}
else
{
if (Sync.IsServer)
{
ServerRead(stream, forClient.Value,timestamp);
}
else
{
ClientRead(stream);
}
}
return true;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:27,代码来源:MyEntityPositionVerificationStateGroup.cs
示例15: Serialize
public bool Serialize(BitStream stream, EndpointId forClient, uint timestamp, byte packetId, int maxBitPosition)
{
if (stream.Writing)
{
InventoryClientData clientData = m_clientInventoryUpdate[forClient.Value];
bool needsSplit = false;
if (clientData.FailedIncompletePackets.Count > 0)
{
InventoryDeltaInformation failedPacket = clientData.FailedIncompletePackets[0];
clientData.FailedIncompletePackets.RemoveAtFast(0);
InventoryDeltaInformation reSendPacket = WriteInventory(ref failedPacket, stream, packetId, maxBitPosition, out needsSplit);
if (needsSplit)
{
//resend split doesnt generate new id becaose it was part of allreadt sent message
clientData.FailedIncompletePackets.Add(CreateSplit(ref failedPacket, ref reSendPacket));
}
if (reSendPacket.HasChanges)
{
clientData.SendPackets[packetId] = reSendPacket;
}
}
else
{
InventoryDeltaInformation difference = CalculateInventoryDiff(ref clientData);
difference.MessageId = clientData.CurrentMessageId;
clientData.MainSendingInfo = WriteInventory(ref difference, stream, packetId, maxBitPosition,out needsSplit);
if (needsSplit)
{
//split generate new id becaose its different message
clientData.CurrentMessageId++;
InventoryDeltaInformation split = CreateSplit(ref difference, ref clientData.MainSendingInfo);
split.MessageId = clientData.CurrentMessageId;
clientData.FailedIncompletePackets.Add(split);
}
if (clientData.MainSendingInfo.HasChanges)
{
clientData.SendPackets[packetId] = clientData.MainSendingInfo;
clientData.CurrentMessageId++;
}
clientData.Dirty = false;
}
}
else
{
ReadInventory(stream);
}
return true;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:55,代码来源:MyEntityInventoryStateGroup.cs
示例16: OnRespawnRequest
static void OnRespawnRequest(RespawnMsg msg)
{
EndpointId sender;
if (MyEventContext.Current.IsLocallyInvoked)
sender = new EndpointId(Sync.MyId);
else
sender = MyEventContext.Current.Sender;
Debug.Assert(Sync.IsServer, "This method can only be called on the server!");
Debug.Assert(Sync.Players.RespawnComponent != null, "The respawn component is not set! Cannot handle respawn request!");
if (Sync.Players.RespawnComponent == null)
{
return;
}
PlayerId playerId = new PlayerId(sender.Value, msg.PlayerSerialId);
bool respawnSuccessful = Sync.Players.RespawnComponent.HandleRespawnRequest(
msg.JoinGame,
msg.NewIdentity,
msg.RespawnEntityId,
msg.RespawnShipId,
playerId,
msg.SpawnPosition,
msg.BotDefinitionId
);
if (respawnSuccessful)
{
MyIdentity identity = Sync.Players.TryGetPlayerIdentity(playerId);
Debug.Assert(identity != null, "Could not find identity of respawning player!");
if (identity != null && !identity.FirstSpawnDone)
{
MyMultiplayer.RaiseStaticEvent(s => MyPlayerCollection.OnIdentityFirstSpawn, identity.IdentityId);
identity.PerformFirstSpawn();
}
}
else
{
if (MyEventContext.Current.IsLocallyInvoked)
OnRespawnRequestFailure(msg);
else
MyMultiplayer.RaiseStaticEvent(s => MyPlayerCollection.OnRespawnRequestFailure, msg, sender);
}
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:45,代码来源:MyPlayerCollection.cs
示例17: ProcessEvent
protected override void ProcessEvent(BitStream stream, NetworkId networkId, NetworkId blockedNetId, uint eventId, EndpointId sender)
{
LastMessageFromServer = DateTime.UtcNow;
// Check if any of them is not blocked already.
bool anyContainsEvents = m_eventBuffer.ContainsEvents(networkId) || m_eventBuffer.ContainsEvents(blockedNetId);
if (this.IsBlocked(networkId, blockedNetId) || anyContainsEvents)
{
m_eventBuffer.EnqueueEvent(stream, networkId, blockedNetId, eventId, sender);
// Only enqueue barrier if blocking network id is set
if(blockedNetId.IsValid)
m_eventBuffer.EnqueueBarrier(blockedNetId, networkId);
}
else
{
base.ProcessEvent(stream, networkId, blockedNetId, eventId, sender);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:18,代码来源:MyReplicationClient.cs
示例18: WriteSubgrids
public static bool WriteSubgrids(MyCubeGrid masterGrid, BitStream stream, ref EndpointId forClient, uint timestamp, int maxBitPosition, bool lowPrecisionOrientation,ref Vector3D basePos, ref int currentSentPosition)
{
bool fullyWritten = true;
var g = MyCubeGridGroups.Static.PhysicalDynamic.GetGroup(masterGrid);
if (g == null)
{
stream.WriteBool(false);
}
else
{
m_groups.Clear();
int i = 0;
foreach (var node in g.Nodes)
{
i++;
if (i < currentSentPosition)
{
continue;
}
var target = MyMultiplayer.Static.ReplicationLayer.GetProxyTarget((IMyEventProxy)node.NodeData);
int pos = stream.BitPosition;
if (node.NodeData != masterGrid && node.NodeData.Physics != null && !node.NodeData.Physics.IsStatic && target != null)
{
stream.WriteBool(true);
// ~26.5 bytes per grid, not bad
NetworkId networkId = MyMultiplayer.Static.ReplicationLayer.GetNetworkIdByObject(target);
stream.WriteNetworkId(networkId); // ~2 bytes
bool moving = IsMovingSubGrid(node.NodeData);
stream.WriteBool(moving);
SerializeTransform(stream, node.NodeData, basePos, lowPrecisionOrientation, false, moving, timestamp, null, null); // 12.5 bytes
SerializeVelocities(stream, node.NodeData, EffectiveSimulationRatio, false, moving); // 12 byte
UpdateGridMaxSpeed(node.NodeData, Sync.IsServer);
m_groups.Add(node.NodeData);
currentSentPosition++;
}
if (stream.BitPosition > maxBitPosition)
{
stream.SetBitPositionWrite(pos);
fullyWritten = false;
currentSentPosition--;
break;
}
if (i == g.Nodes.Count)
{
currentSentPosition = 0;
}
}
stream.WriteBool(false);
}
return fullyWritten;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:62,代码来源:MyGridPhysicsStateGroup.cs
示例19: Serialize
public override bool Serialize(BitStream stream, EndpointId forClient,uint timestamp, byte packetId, int maxBitPosition)
{
// Client does not care about slave grids, he always synced group through controlled object
Debug.Assert(stream.Reading || !Sync.IsServer || Entity == GetMasterGrid(Entity), "Writing data from SlaveGrid!");
bool apply = !IsControlledLocally;
bool moving = false;
if (stream.Writing)
{
moving = IsMoving(Entity);
stream.WriteBool(moving);
}
else
{
moving = stream.ReadBool();
}
// Serialize this grid
apply = SerializeTransform(stream, Entity, null, m_lowPrecisionOrientation, apply,moving, timestamp, m_positionValidation, MoveHandler);
SerializeVelocities(stream, Entity, EffectiveSimulationRatio, apply, moving,VelocityHandler);
// Serialize other grids in group
Vector3D basePos = Entity.WorldMatrix.Translation;
if (stream.Writing)
{
bool fullyWritten = true;
UpdateGridMaxSpeed(Entity, Sync.IsServer);
var g = MyCubeGridGroups.Static.PhysicalDynamic.GetGroup(Entity);
if (g == null)
{
stream.WriteBool(false);
}
else
{
m_groups.Clear();
int i = 0;
foreach (var node in g.Nodes)
{
i++;
if (ResponsibleForUpdate(node.NodeData, forClient))
{
continue;
}
if(i < m_currentSentPosition)
{
continue;
}
var target = MyMultiplayer.Static.ReplicationLayer.GetProxyTarget((IMyEventProxy)node.NodeData);
int pos = stream.BitPosition;
if (node.NodeData != Entity && !node.NodeData.IsStatic && target != null)
{
stream.WriteBool(true);
// ~26.5 bytes per grid, not bad
NetworkId networkId = MyMultiplayer.Static.ReplicationLayer.GetNetworkIdByObject(target);
stream.WriteNetworkId(networkId); // ~2 bytes
moving = IsMoving(node.NodeData);
stream.WriteBool(moving);
SerializeTransform(stream, node.NodeData, basePos, m_lowPrecisionOrientation, apply, moving, timestamp, null, null); // 12.5 bytes
SerializeVelocities(stream, node.NodeData, EffectiveSimulationRatio, apply, moving); // 12 byte
UpdateGridMaxSpeed(node.NodeData, Sync.IsServer);
m_groups.Add(node.NodeData);
m_currentSentPosition++;
}
if (stream.BitPosition > maxBitPosition)
{
stream.SetBitPositionWrite(pos);
fullyWritten = false;
m_currentSentPosition--;
break;
}
if (i == g.Nodes.Count)
{
m_currentSentPosition = 0;
}
}
stream.WriteBool(false);
}
stream.WriteBool(fullyWritten);
if (fullyWritten)
{
SerializeRopeData(stream, apply, gridsGroup: m_groups);
}
return fullyWritten;
//.........这里部分代码省略.........
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:101,代码来源:MyGridPhysicsStateGroup.cs
示例20: ClientWrite
protected override void ClientWrite(VRage.Library.Collections.BitStream stream, EndpointId forClient, uint timestamp, int maxBitPosition)
{
base.ClientWrite(stream, forClient,timestamp,maxBitPosition);
stream.WriteBool(m_character != null);
if (m_character != null)
{
stream.WriteBool(m_supportPhysics != null);
if (m_supportPhysics != null)
{
stream.WriteInt64(m_supportPhysics.Entity.EntityId);
stream.Write(m_supportPhysics.Entity.PositionComp.GetPosition());
}
Vector3 position = m_character.MoveIndicator;
stream.WriteHalf(position.X);
stream.WriteHalf(position.Y);
stream.WriteHalf(position.Z);
Vector2 rotate = m_character.RotationIndicator;
stream.WriteFloat(rotate.X);
stream.WriteFloat(rotate.Y);
stream.WriteFloat(m_character.RollIndicator);
// Movement state, 2B
stream.WriteUInt16((ushort)m_character.GetNetworkMovementState());
// Movement flag.
stream.WriteUInt16((ushort)m_character.PreviousMovementFlags);
// Flags, 6 bits
bool hasJetpack = m_character.JetpackComp != null;
stream.WriteBool(hasJetpack ? m_character.JetpackComp.TurnedOn : false);
stream.WriteBool(hasJetpack ? m_character.JetpackComp.DampenersTurnedOn : false);
stream.WriteBool(m_character.LightEnabled); // TODO: Remove
stream.WriteBool(m_character.ZoomMode == MyZoomModeEnum.IronSight);
stream.WriteBool(m_character.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
stream.WriteBool(m_character.TargetFromCamera);
stream.WriteFloat(m_character.HeadLocalXAngle);
stream.WriteFloat(m_character.HeadLocalYAngle);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:44,代码来源:MyCharacterPositionVerificationStateGroup.cs
注:本文中的VRage.Network.EndpointId类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论