private bool ValidateFloating(Vector3 origin, Vector3 goal) { // Logger.Log( $"{gameObject.name} check {origin}->{goal}. Speed={serverState.Speed}" ); Vector3Int intOrigin = Vector3Int.RoundToInt(origin); Vector3Int intGoal = Vector3Int.RoundToInt(goal); var info = serverState.ActiveThrow; List <LivingHealthBehaviour> hitDamageables; if (CanDriftTo(intOrigin, intGoal, isServer: true) & !HittingSomething(intGoal, info.ThrownBy, out hitDamageables)) { //if object is solid, check if player is nearby to make it stop return(registerTile && registerTile.IsPassable(true) || !IsPlayerNearby(serverState)); } if (serverState.Speed > SpeedHitThreshold) { serverState.ActiveThrow = new ThrowInfo { Aim = BodyPartType.Chest.Randomize(0), OriginPos = origin, TargetPos = goal, SpinMode = SpinMode.None }; info = serverState.ActiveThrow; } //Can't drift to goal for some reason: OnHit(intGoal, info, hitDamageables, MatrixManager.GetDamagetableTilemapsAt(intGoal)); return(false); }
private void OnHighSpeedCollision(CollisionInfo collision) { bool collided = false; foreach (var living in MatrixManager.GetAt <LivingHealthBehaviour>(collision.CollisionTile, true)) { living.ApplyDamage(gameObject, collision.Damage, AttackType.Melee, DamageType.Brute, BodyPartType.Chest.Randomize(0)); collided = true; } foreach (var tile in MatrixManager.GetDamagetableTilemapsAt(collision.CollisionTile)) { tile.DoMeleeDamage(collision.CollisionTile.To2Int(), gameObject, (int)collision.Damage); collided = true; } if (collided) { //Damage self as bad as the thing you collide with GetComponent <LivingHealthBehaviour>()?.ApplyDamage(gameObject, collision.Damage, AttackType.Melee, DamageType.Brute, BodyPartType.Chest.Randomize(0)); Logger.LogFormat("{0}: collided with something at {2}, both received {1} damage", Category.Health, gameObject.name, collision.Damage, collision.CollisionTile); } }
private bool ValidateFloating(Vector3 origin, Vector3 goal) { // Logger.Log( $"{gameObject.name} check {origin}->{goal}. Speed={serverState.Speed}" ); Vector3Int intOrigin = Vector3Int.RoundToInt(origin); Vector3Int intGoal = Vector3Int.RoundToInt(goal); var info = serverState.ActiveThrow; List <LivingHealthBehaviour> hitDamageables; if (serverState.Speed > SpeedHitThreshold && HittingSomething(intGoal, info.ThrownBy, out hitDamageables)) { OnHit(intGoal, info, hitDamageables, MatrixManager.GetDamagetableTilemapsAt(intGoal)); if (info.ThrownBy != null) { return(false); } } if (CanDriftTo(intOrigin, intGoal, isServer: true)) { return(registerTile && registerTile.IsPassable(true)); } return(false); }