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, 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); }
internal void DoDamage(float damage, MyStringHash damageType, MyHitInfo?hitInfo, long attackerId) { float num = 0f; foreach (KeyValuePair <ushort, MySlimBlock> pair in this.m_mapIdToBlock) { num += pair.Value.MaxIntegrity; } for (int i = this.m_blocks.Count - 1; i >= 0; i--) { MySlimBlock block = this.m_blocks[i]; block.DoDamage(damage * (block.MaxIntegrity / num), damageType, hitInfo, true, attackerId); } }