public virtual bool SharedCanInteract(ICharacter character, TWorldObject worldObject, bool writeToLog) { if (!this.IsInteractableObject) { return(false); } if (StatusEffectDazed.SharedIsCharacterDazed(character, Notification_CannotInteractWhileDazed)) { return(false); } if (character.GetPublicState <ICharacterPublicState>().IsDead) { return(false); } return(this.SharedIsInsideCharacterInteractionArea(character, worldObject, writeToLog)); }
public static void SharedUpdateCurrentWeapon( ICharacter character, WeaponState state, double deltaTime) { var protoWeapon = state.ActiveProtoWeapon; if (protoWeapon == null) { return; } if (state.CooldownSecondsRemains > 0) { // decrease cooldown state.CooldownSecondsRemains -= deltaTime; } if (!state.IsFiring) { WeaponAmmoSystem.SharedUpdateReloading(state, character, ref deltaTime); } if (deltaTime <= 0) { // the weapon reloading process is consumed the whole delta time return; } if (state.SharedGetInputIsFiring() && !character.IsOnline) { state.SetInputIsFiring(false); } if (state.SharedGetInputIsFiring() && StatusEffectDazed.SharedIsCharacterDazed(character, StatusEffectDazed.NotificationCannotAttackWhileDazed)) { state.SetInputIsFiring(false); } // check ammo (if applicable to this weapon prototype) var canFire = protoWeapon.SharedCanFire(character, state); if (state.CooldownSecondsRemains > 0) { // firing cooldown is not completed if (!state.SharedGetInputIsFiring() && state.IsEventWeaponStartSent) { // not firing anymore SharedCallOnWeaponInputStop(state, character); } return; } var wasFiring = state.IsFiring; if (!state.IsFiring) { state.IsFiring = state.SharedGetInputIsFiring(); } else // if IsFiring { if (!SharedShouldFireMore(state)) { state.IsFiring = state.SharedGetInputIsFiring(); } } if (!canFire) { // cannot fire (no ammo, etc) state.IsFiring = false; } if (!state.IsFiring) { if (wasFiring) { // just stopped firing SharedCallOnWeaponFinished(state, character); } // the character is not firing // reset delay for the next shot (it will be set when firing starts next time) state.DamageApplyDelaySecondsRemains = 0; return; } // let's process what happens when we're in the firing mode if (!state.IsEventWeaponStartSent) { // started firing SharedCallOnWeaponStart(state, character); } if (state.DamageApplyDelaySecondsRemains <= 0) { // initialize delay to next shot state.DamageApplyDelaySecondsRemains = protoWeapon.DamageApplyDelay; SharedCallOnWeaponShot(character); } // decrease the remaining time to the damage application state.DamageApplyDelaySecondsRemains -= deltaTime; if (state.DamageApplyDelaySecondsRemains > 0) { // firing delay not completed return; } // firing delay completed state.ShotsDone++; //Logger.Dev("Weapon fired, shots done: " + state.ShotsDone); SharedFireWeapon(character, state.ActiveItemWeapon, protoWeapon, state); state.CooldownSecondsRemains += protoWeapon.FireInterval - protoWeapon.DamageApplyDelay; if (!protoWeapon.IsLoopedAttackAnimation) { // we don't want to stuck this animation in the last frame // that's fix for the issue: // "Fix extended animation "stuck" issue for mobs (like limbs stuck in the end position and movement animation appears broken)" state.IsEventWeaponStartSent = false; } }