本文整理汇总了C#中Sandbox.Game.Multiplayer.MySyncGrid类的典型用法代码示例。如果您正苦于以下问题:C# MySyncGrid类的具体用法?C# MySyncGrid怎么用?C# MySyncGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySyncGrid类属于Sandbox.Game.Multiplayer命名空间,在下文中一共展示了MySyncGrid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnThrustTorqueReceived
private static void OnThrustTorqueReceived(MySyncGrid sync, ref ThrustAndTorqueMsg msg, MyNetworkClient sender)
{
sender.ClientFrameId = msg.ClientFrameId;
//if (false)
{
sync.Entity.GridSystems.ThrustSystem.ControlThrust = msg.Thrust;
sync.Entity.GridSystems.GyroSystem.ControlTorque = msg.Torque;
}
}
示例2: OnColorBlocksRequest
private static void OnColorBlocksRequest(MySyncGrid sync, ref ColorBlocksMsg msg, MyNetworkClient sender)
{
var handler = sync.BlocksColored;
if (handler != null) handler(msg.Min, msg.Max, ColorExtensions.UnpackHSVFromUint(msg.HSV), msg.PlaySound);
if (Sync.IsServer)
{
// Broadcast to clients, use result collection
Sync.Layer.SendMessageToAll(ref msg);
}
}
示例3: OnBonesReceived
private static void OnBonesReceived(MySyncGrid sync, ref BonesMsg msg, MyNetworkClient sender)
{
sync.Entity.Skeleton.DeserializePart(msg.MinBone, msg.MaxBone, sync.Entity.GridSize, msg.Bones);
Vector3I minCube = Vector3I.Zero;
Vector3I maxCube = Vector3I.Zero;
// To hit incident cubes
Vector3I min = msg.MinBone;// -Vector3I.One;
Vector3I max = msg.MaxBone;// +Vector3I.One;
sync.Entity.Skeleton.Wrap(ref minCube, ref min);
sync.Entity.Skeleton.Wrap(ref maxCube, ref max);
minCube -= Vector3I.One;
maxCube += Vector3I.One;
Vector3I pos;
for (pos.X = minCube.X; pos.X <= maxCube.X; pos.X++)
{
for (pos.Y = minCube.Y; pos.Y <= maxCube.Y; pos.Y++)
{
for (pos.Z = minCube.Z; pos.Z <= maxCube.Z; pos.Z++)
{
sync.Entity.SetCubeDirty(pos);
}
}
}
}
示例4: OnBuildBlocksAreaSuccess
private static void OnBuildBlocksAreaSuccess(MySyncGrid sync, ref BuildBlocksAreaSuccessMsg successMsg, MyNetworkClient sender)
{
Debug.Assert(sync.BlocksBuiltAreaSuccess != null, "Handler should not be null, build messages will be ignored!");
var handler = sync.BlocksBuiltAreaSuccess;
if (handler != null) handler(ref successMsg.Area, successMsg.EntityIdSeed, successMsg.FailList, successMsg.OwnerId);
}
示例5: OnRazeBlocksAreaSuccess
private static void OnRazeBlocksAreaSuccess(MySyncGrid sync, ref RazeBlocksAreaSuccessMsg successMsg, MyNetworkClient sender)
{
Debug.Assert(sync.BlocksRazeAreaSuccess != null, "Handler should not be null, Raze messages will be ignored!");
var handler = sync.BlocksRazeAreaSuccess;
if (handler != null) handler(ref successMsg.Pos, ref successMsg.Size, successMsg.FailList);
}
示例6: OnRemoveSplit
private static void OnRemoveSplit(MySyncGrid grid, ref RemoveSplitMsg msg, MyNetworkClient sender)
{
MyCubeGrid m_grid;
if (MyEntities.TryGetEntityById(msg.GridEntityId, out m_grid))
{
m_tmpBlockListReceive.Clear();
foreach (var position in msg.RemovedBlocks)
{
var block = m_grid.GetCubeBlock(position);
Debug.Assert(block != null, "Block was null when trying to remove a grid split. Desync?");
if (block == null)
{
MySandboxGame.Log.WriteLine("Block was null when trying to remove a grid split. Desync?");
continue;
}
m_tmpBlockListReceive.Add(block);
}
MyCubeGrid.RemoveSplit(m_grid, m_tmpBlockListReceive, 0, m_tmpBlockListReceive.Count, sync: false);
m_tmpBlockListReceive.Clear();
}
}
示例7: OnBuildBlockRequest
private static void OnBuildBlockRequest(MySyncGrid sync, ref BuildBlockMsg msg, MyNetworkClient sender)
{
MyCubeGrid.MyBlockLocation? builtBlock = null;
MyEntity builder = null;
MyEntities.TryGetEntityById(msg.BuilderEntityId, out builder);
var buildHandler = sync.BlockBuilt;
if (buildHandler != null) buildHandler(ColorExtensions.UnpackHSVFromUint(msg.ColorMaskHsv), msg.Location, msg.BlockObjectBuilder, ref builtBlock, builder);
if (Sync.IsServer)
{
Sync.Layer.SendMessageToAll(ref msg);
}
var afterHandler = sync.AfterBlockBuilt;
if (afterHandler != null && builtBlock != null) afterHandler(builtBlock.Value);
}
示例8: OnModifyGroupSuccess
private static void OnModifyGroupSuccess(MySyncGrid sync, ref ModifyBlockGroupMsg msg, MyNetworkClient sender)
{
if (msg.Blocks == null || msg.Blocks.Count() == 0)
foreach (var group in sync.Entity.BlockGroups)
{
if (group.Name.ToString().Equals(msg.Name))
{
sync.Entity.RemoveGroup(group);
break;
}
}
else
{
MyBlockGroup group = new MyBlockGroup(sync.Entity);
group.Name.Clear().Append(msg.Name);
foreach (var blockId in msg.Blocks)
{
MyTerminalBlock block = null;
if (MyEntities.TryGetEntityById(blockId, out block))
group.Blocks.Add(block);
}
sync.Entity.AddGroup(group);
}
}
示例9: OnConvertedToShipRequest
private static void OnConvertedToShipRequest(MySyncGrid sync, ref ConvertToShipMsg msg, MyNetworkClient sender)
{
if (!sync.Entity.IsStatic)
{
Debug.Assert(false, "Grid was not static!");
return;
}
if (Sync.IsServer)
Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
}
示例10: OnStockpileFillRequest
private static void OnStockpileFillRequest(MySyncGrid sync, ref StockpileFillRequestMsg msg, MyNetworkClient sender)
{
var block = sync.Entity.GetCubeBlock(msg.BlockPosition);
Debug.Assert(block != null, "Could not find block whose stockpile fill was requested");
if (block == null) return;
MyEntity ownerEntity = null;
if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity))
{
Debug.Assert(false, "Stockpile fill inventory owner entity was null");
return;
}
var owner = (ownerEntity as IMyInventoryOwner);
Debug.Assert(owner != null, "Stockpile fill inventory owner was not an inventory owner");
var inventory = owner.GetInventory(msg.InventoryIndex);
Debug.Assert(inventory != null, "Stockpile fill inventory owner did not have the given inventory");
block.MoveItemsToConstructionStockpile(inventory);
}
示例11: OnSetToConstructionRequest
private static void OnSetToConstructionRequest(MySyncGrid sync, ref SetToConstructionRequestMsg msg, MyNetworkClient sender)
{
var block = sync.Entity.GetCubeBlock(msg.BlockPosition);
Debug.Assert(block != null, "Could not find block to set to construction site");
if (block == null) return;
block.SetToConstructionSite();
MyEntity ownerEntity = null;
if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity))
{
Debug.Assert(false, "Set to construction site inventory owner entity was null");
return;
}
var owner = (ownerEntity as IMyInventoryOwner);
Debug.Assert(owner != null, "Set to construction site inventory owner was not an inventory owner");
var inventory = owner.GetInventory(msg.InventoryIndex);
Debug.Assert(inventory != null, "Set to construction site inventory owner did not have the given inventory");
block.MoveItemsToConstructionStockpile(inventory);
block.IncreaseMountLevel(MyWelder.WELDER_AMOUNT_PER_SECOND * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, msg.RequestingPlayer);
}
示例12: OnStockpileChanged
private static void OnStockpileChanged(MySyncGrid sync, ref StockpileChangedMsg msg, MyNetworkClient sender)
{
if (sync.BlockStockpileChanged != null)
sync.BlockStockpileChanged(msg.BlockPosition, msg.SubBlockId, msg.Changes);
}
示例13: OnIntegrityChanged
private static void OnIntegrityChanged(MySyncGrid sync, ref IntegrityChangedMsg msg, MyNetworkClient sender)
{
if (sync.BlockIntegrityChanged != null)
sync.BlockIntegrityChanged(msg.BlockPosition, msg.SubBlockId, msg.BuildIntegrity, msg.Integrity, msg.IntegrityChangeType, msg.ToolOwner);
}
示例14: OnThrustReceived
private static void OnThrustReceived(MySyncGrid sync, ref ThrustMsg msg, MyNetworkClient sender)
{
sync.Entity.GridSystems.ThrustSystem.ControlThrust = msg.Thrust;
}
示例15: OnChangeDisplayName
private static void OnChangeDisplayName(MySyncGrid grid, ref ChangeDisplayNameMsg msg, MyNetworkClient sender)
{
MyCubeGrid m_grid;
if (MyEntities.TryGetEntityById(msg.GridEntityId, out m_grid))
m_grid.DisplayName = msg.DisplayName;
}