Example #1
0
    /// <summary>
    /// Hit for thrown (non-tile-snapped) items
    /// </summary>
    private void OnHit(Vector3Int pos, ThrowInfo info, IReadOnlyCollection <LivingHealthMasterBase> hitCreatures)
    {
        if (ItemAttributes == null)
        {
            return;
        }
        if (hitCreatures == null || hitCreatures.Count <= 0)
        {
            return;
        }

        foreach (var creature in hitCreatures)
        {
            if (creature.gameObject == info.ThrownBy)
            {
                continue;
            }
            //Remove cast to int when moving health values to float
            var damage  = (int)(ItemAttributes.ServerThrowDamage);
            var hitZone = info.Aim.Randomize();
            creature.ApplyDamageToBodyPart(info.ThrownBy, damage, AttackType.Melee, DamageType.Brute, hitZone);
            Chat.AddThrowHitMsgToChat(gameObject, creature.gameObject, hitZone);
            AudioSourceParameters audioSourceParameters = new AudioSourceParameters(pitch: 1f);
            SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.GenericHit, transform.position, audioSourceParameters, sourceObj: gameObject);
        }
    }
        private bool TryStun(MatrixManager.CustomPhysicsHit hit)
        {
            var coll = hit.CollisionHit.GameObject;

            if (coll == null)
            {
                return(false);
            }
            var player = coll.GetComponent <RegisterPlayer>();

            if (player == null)
            {
                return(false);
            }

            player.ServerStun(stunTime, willDisarm);

            if (doMsg)
            {
                Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
            }
            Logger.LogTraceFormat($"{shooter} stunned {player.gameObject.name} for {stunTime} seconds with {weapon.OrNull()?.name}", Category.Firearms);

            return(true);
        }
	/// <summary>
	/// Hit for thrown (non-tile-snapped) items
	/// </summary>
	protected virtual void OnHit(Vector3Int pos, ThrowInfo info, List<LivingHealthBehaviour> objects, List<TilemapDamage> tiles)
	{
		if (ItemAttributes == null)
		{
			Logger.LogWarningFormat("{0}: Tried to hit stuff at pos {1} but have no ItemAttributes.", Category.Throwing, gameObject.name, pos);
			return;
		}
		//Hurting tiles
		for (var i = 0; i < tiles.Count; i++)
		{
			var tileDmg = tiles[i];
			var damage = (int)(ItemAttributes.ServerThrowDamage * 2);
			tileDmg.DoThrowDamage(pos, info, damage);
		}

		//Hurting objects
		if (objects != null && objects.Count > 0)
		{
			for (var i = 0; i < objects.Count; i++)
			{
				//Remove cast to int when moving health values to float
				var damage = (int)(ItemAttributes.ServerThrowDamage * 2);
				var hitZone = info.Aim.Randomize();
				objects[i].ApplyDamageToBodypart(info.ThrownBy, damage, AttackType.Melee, DamageType.Brute, hitZone);
				Chat.AddThrowHitMsgToChat(gameObject,objects[i].gameObject, hitZone);
			}
			//hit sound
			SoundManager.PlayNetworkedAtPos("GenericHit", transform.position, 1f);
		}
		else
		{
			//todo different sound for no-damage hit?
			SoundManager.PlayNetworkedAtPos("GenericHit", transform.position, 0.8f);
		}
	}
        private bool TryDamage(MatrixManager.CustomPhysicsHit hit)
        {
            if (hit.CollisionHit.GameObject == null)
            {
                return(false);
            }
            var coll      = hit.CollisionHit.GameObject;
            var integrity = coll.GetComponent <Integrity>();

            if (integrity == null)
            {
                return(false);
            }
            if (damageData == null)
            {
                return(true);
            }

            integrity.ApplyDamage(damageData.Damage, damageData.AttackType, damageData.DamageType);

            Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
            Logger.LogTraceFormat("Hit {0} for {1} with Integrity! bullet absorbed", Category.Firearms,
                                  integrity.gameObject.name, damageData.Damage);

            foreach (var hitDetect in coll.GetComponents <IOnHitDetect>())
            {
                hitDetect.OnHitDetect(damageData);
            }

            return(true);
        }
        private bool TryDamage(MatrixManager.CustomPhysicsHit hit)
        {
            var coll = hit.CollisionHit.GameObject;

            if (coll == null)
            {
                return(true);
            }
            var livingHealth = coll.GetComponent <LivingHealthBehaviour>();

            if (livingHealth == null)
            {
                return(false);
            }

            var newDamage = projectileKineticDamage.DamageByPressureModifier(damageData.Damage);

            livingHealth.ApplyDamageToBodypart(shooter, newDamage, damageData.AttackType, damageData.DamageType, targetZone);

            Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);

            Logger.LogTraceFormat(
                "Hit {0} for {1} with HealthBehaviour! bullet absorbed",
                Category.Firearms,
                livingHealth.gameObject.name,
                newDamage);

            return(true);
        }
Example #6
0
        private bool TryDamage(MatrixManager.CustomPhysicsHit hit)
        {
            var coll = hit.CollisionHit.GameObject;

            if (coll == null)
            {
                return(false);
            }
            var integrity = coll.GetComponent <Integrity>();

            if (integrity == null)
            {
                return(false);
            }

            float newDamage = projectileKineticDamage.DamageByPressureModifier(damageData.Damage);

            integrity.ApplyDamage(newDamage, damageData.AttackType, damageData.DamageType);

            Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);

            Logger.LogTraceFormat(
                "Hit {0} for {1} with Integrity! bullet absorbed",
                Category.Firearms,
                integrity.gameObject.name,
                newDamage);

            return(true);
        }
Example #7
0
        private bool TryDamage(RaycastHit2D hit)
        {
            var coll      = hit.collider;
            var integrity = coll.GetComponent <Integrity>();

            if (integrity == null)
            {
                return(false);
            }

            integrity.ApplyDamage(damageData.Damage, damageData.AttackType, damageData.DamageType);

            Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
            Logger.LogTraceFormat("Hit {0} for {1} with HealthBehaviour! bullet absorbed", Category.Firearms,
                                  integrity.gameObject.name, damageData.Damage);

            return(true);
        }
Example #8
0
        private bool TryDamage(RaycastHit2D hit)
        {
            var coll         = hit.collider;
            var livingHealth = coll.GetComponent <LivingHealthBehaviour>();

            if (livingHealth == null)
            {
                return(false);
            }


            livingHealth.ApplyDamageToBodypart(shooter, damageData.Damage, damageData.AttackType, damageData.DamageType, targetZone);

            Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
            Logger.LogTraceFormat("Hit {0} for {1} with HealthBehaviour! bullet absorbed", Category.Firearms,
                                  livingHealth.gameObject.name, damageData.Damage);

            return(true);
        }
Example #9
0
        private bool TryDamage(MatrixManager.CustomPhysicsHit hit)
        {
            var coll = hit.CollisionHit.GameObject;

            if (coll == null)
            {
                return(false);
            }

            //TODO REMOVE AFTER SWITCHING MOBS TO LivingHealthMasterBase or else guns wont kill them
            var livingHealth = coll.GetComponent <LivingHealthBehaviour>();

            if (livingHealth != null)
            {
                livingHealth.ApplyDamageToBodyPart(shooter, damageData.Damage, damageData.AttackType, damageData.DamageType, targetZone);


                Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
                Logger.LogTraceFormat("Hit {0} for {1} with HealthBehaviour! bullet absorbed", Category.Firearms,
                                      livingHealth.gameObject.name, damageData.Damage);

                return(true);
            }

            //TODO REMOVE AFTER SWITCHING MOBS TO
            var health = coll.GetComponent <LivingHealthMasterBase>();

            if (health != null)
            {
                health.ApplyDamageToBodyPart(shooter, damageData.Damage, damageData.AttackType, damageData.DamageType, targetZone);

                Chat.AddThrowHitMsgToChat(gameObject, coll.gameObject, targetZone);
                Logger.LogTraceFormat("Hit {0} for {1} with HealthBehaviour! bullet absorbed", Category.Firearms,
                                      health.gameObject.name, damageData.Damage);

                return(true);
            }


            return(false);
        }
Example #10
0
    /// <summary>
    /// Hit for thrown (non-tile-snapped) items
    /// </summary>
    private void OnHit(Vector3Int pos, ThrowInfo info, IReadOnlyCollection <LivingHealthBehaviour> hitCreatures)
    {
        if (ItemAttributes == null)
        {
            return;
        }
        if (hitCreatures == null || hitCreatures.Count <= 0)
        {
            return;
        }

        foreach (var creature in hitCreatures)
        {
            //Remove cast to int when moving health values to float
            var damage  = (int)(ItemAttributes.ServerThrowDamage);
            var hitZone = info.Aim.Randomize();
            creature.ApplyDamageToBodypart(info.ThrownBy, damage, AttackType.Melee, DamageType.Brute, hitZone);
            Chat.AddThrowHitMsgToChat(gameObject, creature.gameObject, hitZone);
        }

        SoundManager.PlayNetworkedAtPos("GenericHit", transform.position, 1f, sourceObj: gameObject);
    }