public void StopShooting(MyEntity attacker) { Debug.Assert(Sync.IsServer); if (!IsShooting) { return; } float delaySec = 0; MyCharacter attackerCharacter = attacker as MyCharacter; if (attackerCharacter != null) { MyHandToolBase attackerHandTool = attackerCharacter.CurrentWeapon as MyHandToolBase; if (attackerHandTool != null && attackerHandTool.m_shotToolAction != null) { delaySec = attackerHandTool.m_shotToolAction.Value.HitDuration - (float)(MySandboxGame.Static.UpdateTime - attackerHandTool.m_lastShot).Seconds; } } float attackDelay = delaySec > 0 ? delaySec : AFTER_SHOOT_HIT_DELAY; // Send stop to clients MyMultiplayer.RaiseStaticEvent(s => MyHandToolBase.StopShootingRequest, EntityId, attackDelay); // Set stop on server StopShooting(attackDelay); }
private static void StopShootingRequest(long entityId, float attackDelay) { MyEntity entity = null; MyEntities.TryGetEntityById(entityId, out entity); MyHandToolBase handTool = entity as MyHandToolBase; if (handTool == null) return; handTool.StopShooting(attackDelay); }
public MyBlockingBody(MyHandToolBase tool, MyEntity owner) : base(owner, RigidBodyFlag.RBF_KINEMATIC) { HandTool = tool; }