static void DoDamageSlimBlock(ref DoDamageSlimBlockMsg msg, MyNetworkClient sender) { Debug.Assert(!Sync.IsServer); MyCubeGrid grid; if (!MyEntities.TryGetEntityById <MyCubeGrid>(msg.GridEntityId, out grid)) { return; } var block = grid.GetCubeBlock(msg.Position); if (block == null) { return; } if (msg.CompoundBlockId != 0xFFFFFFFF && block.FatBlock is MyCompoundCubeBlock) { var compound = block.FatBlock as MyCompoundCubeBlock; var blockInCompound = compound.GetBlock((ushort)msg.CompoundBlockId); if (blockInCompound != null) { block = blockInCompound; } } block.DoDamage(msg.Damage, msg.Type, hitInfo: msg.HitInfo, attackerId: msg.AttackerEntityId); }
internal static void DoDamageSynced(MySlimBlock block, float damage, MyStringHash damageType, MyHitInfo?hitInfo, long attackerId) { Debug.Assert(Sync.IsServer); var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; msg.HitInfo = hitInfo; msg.AttackerEntityId = attackerId; msg.CompoundBlockId = 0xFFFFFFFF; // Get compound block id var blockOnPosition = block.CubeGrid.GetCubeBlock(block.Position); if (blockOnPosition != null && block != blockOnPosition && blockOnPosition.FatBlock is MyCompoundCubeBlock) { MyCompoundCubeBlock compound = blockOnPosition.FatBlock as MyCompoundCubeBlock; ushort?compoundBlockId = compound.GetBlockId(block); if (compoundBlockId != null) { msg.CompoundBlockId = compoundBlockId.Value; } } block.DoDamage(damage, damageType, hitInfo: hitInfo, attackerId: attackerId); Sync.Layer.SendMessageToAll <DoDamageSlimBlockMsg>(ref msg); }
internal static void DoDamageSynced(MySlimBlock block, float damage, MyDamageType damageType) { Debug.Assert(Sync.IsServer); var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; block.DoDamage(damage, damageType); Sync.Layer.SendMessageToAll<DoDamageSlimBlockMsg>(ref msg); }
internal static void DoDamageSynced(MySlimBlock block, float damage, MyDamageType damageType) { Debug.Assert(Sync.IsServer); var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; block.DoDamage(damage, damageType); Sync.Layer.SendMessageToAll <DoDamageSlimBlockMsg>(ref msg); }
internal static void DoDamageSynced(MySlimBlock block, float damage, MyStringHash damageType, MyHitInfo?hitInfo, long attackerId) { Debug.Assert(Sync.IsServer); var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; msg.HitInfo = hitInfo; msg.AttackerEntityId = attackerId; block.DoDamage(damage, damageType, hitInfo: hitInfo, attackerId: attackerId); Sync.Layer.SendMessageToAll <DoDamageSlimBlockMsg>(ref msg); }
static void DoDamageSlimBlock(ref DoDamageSlimBlockMsg msg, MyNetworkClient sender) { Debug.Assert(!Sync.IsServer); MyCubeGrid grid; if (!MyEntities.TryGetEntityById <MyCubeGrid>(msg.GridEntityId, out grid)) { return; } var block = grid.GetCubeBlock(msg.Position); if (block == null) { return; } block.DoDamage(msg.Damage, msg.Type, hitInfo: msg.HitInfo, attackerId: msg.AttackerEntityId); }
static void DoDamageSlimBlock(DoDamageSlimBlockMsg msg) { Debug.Assert(!Sync.IsServer); MyCubeGrid grid; if (!MyEntities.TryGetEntityById<MyCubeGrid>(msg.GridEntityId, out grid)) return; var block = grid.GetCubeBlock(msg.Position); if (block == null) return; if (msg.CompoundBlockId != 0xFFFFFFFF && block.FatBlock is MyCompoundCubeBlock) { var compound = block.FatBlock as MyCompoundCubeBlock; var blockInCompound = compound.GetBlock((ushort)msg.CompoundBlockId); if (blockInCompound != null) block = blockInCompound; } block.DoDamage(msg.Damage, msg.Type, hitInfo: msg.HitInfo, attackerId: msg.AttackerEntityId); }
static void DoDamageSynced(MySlimBlock block, float damage, MyStringHash damageType, MyHitInfo? hitInfo, long attackerId) { var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; msg.HitInfo = hitInfo; msg.AttackerEntityId = attackerId; msg.CompoundBlockId = 0xFFFFFFFF; // Get compound block id var blockOnPosition = block.CubeGrid.GetCubeBlock(block.Position); if (blockOnPosition != null && block != blockOnPosition && blockOnPosition.FatBlock is MyCompoundCubeBlock) { MyCompoundCubeBlock compound = blockOnPosition.FatBlock as MyCompoundCubeBlock; ushort? compoundBlockId = compound.GetBlockId(block); if (compoundBlockId != null) msg.CompoundBlockId = compoundBlockId.Value; } block.DoDamage(damage, damageType, hitInfo: hitInfo, attackerId: attackerId); #if !XB1_NOMULTIPLAYER MyMultiplayer.RaiseStaticEvent(s => MySlimBlock.DoDamageSlimBlock, msg); #endif // !XB1_NOMULTIPLAYER }
static void DoDamageSlimBlock(ref DoDamageSlimBlockMsg msg, MyNetworkClient sender) { Debug.Assert(!Sync.IsServer); MyCubeGrid grid; if (!MyEntities.TryGetEntityById<MyCubeGrid>(msg.GridEntityId, out grid)) return; var block = grid.GetCubeBlock(msg.Position); if (block == null) return; block.DoDamage(msg.Damage, msg.Type, hitInfo: msg.HitInfo, attackerId:msg.AttackerEntityId); }
internal static void DoDamageSynced(MySlimBlock block, float damage, MyStringHash damageType, MyHitInfo? hitInfo, long attackerId) { Debug.Assert(Sync.IsServer); var msg = new DoDamageSlimBlockMsg(); msg.GridEntityId = block.CubeGrid.EntityId; msg.Position = block.Position; msg.Damage = damage; msg.HitInfo = hitInfo; msg.AttackerEntityId = attackerId; block.DoDamage(damage, damageType, hitInfo: hitInfo, attackerId: attackerId); Sync.Layer.SendMessageToAll<DoDamageSlimBlockMsg>(ref msg); }