Ejemplo n.º 1
0
    private bool ValidateFloating(Vector3 origin, Vector3 goal)
    {
        //		Logger.Log( $"{gameObject.name} check {origin}->{goal}. Speed={serverState.Speed}" );
        var startPosition  = Vector3Int.RoundToInt(origin);
        var targetPosition = Vector3Int.RoundToInt(goal);

        var info = serverState.ActiveThrow;
        IReadOnlyCollection <LivingHealthBehaviour> creaturesToHit =
            Vector3Int.RoundToInt(serverState.ActiveThrow.OriginWorldPos) == targetPosition ?
            null : LivingCreaturesInPosition(targetPosition);

        if (serverState.Speed > SpeedHitThreshold)
        {
            OnHit(targetPosition, info, creaturesToHit);
            DamageTiles(targetPosition, info, MatrixManager.GetDamageableTilemapsAt(targetPosition));
        }

        if (CanDriftTo(startPosition, targetPosition, isServer: true))
        {
            //if we can keep drifting and didn't hit anything, keep floating. If we did hit something, only stop if we are impassable (we bonked something),
            //otherwise keep drifting through (we sliced / glanced off them)
            return((creaturesToHit == null || creaturesToHit.Count == 0) || (registerTile && registerTile.IsPassable(true)));
        }

        return(false);
    }
Ejemplo n.º 2
0
    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 = null;

        if (serverState.Speed > SpeedHitThreshold && HittingSomething(intGoal, info.ThrownBy, out hitDamageables))
        {
            OnHit(intGoal, info, hitDamageables, MatrixManager.GetDamageableTilemapsAt(intGoal));
            if (info.ThrownBy != null)
            {
                return(false);
            }
        }

        if (CanDriftTo(intOrigin, intGoal, isServer: true))
        {
            //if we can keep drifting and didn't hit anything, keep floating. If we did hit something, only stop if we are impassable (we bonked something),
            //otherwise keep drifting through (we sliced / glanced off them)
            return((hitDamageables == null || hitDamageables.Count == 0) || (registerTile && registerTile.IsPassable(true)));
        }

        return(false);
    }
	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.GetDamageableTilemapsAt(intGoal));
			if (info.ThrownBy != null)
			{
				return false;
			}
		}

		if (CanDriftTo(intOrigin, intGoal, isServer : true))
		{
			return (registerTile && registerTile.IsPassable(true));
		}

		return false;
	}